Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/modules/chat/services/ChatMentionsService.server.ts
T

32 lines
1.1 KiB
TypeScript

import { listChatMentionSuggestions, type ChatMentionSuggestion } from "@hivegrid/chat/mentions.server";
import { buildChatMentionAutocompleteVM, type ChatMentionAutocompleteVM } from "@hivegrid/view-models";
import type { ChatRouteContext } from "../routes/chatAccess.server";
export async function loadChatMentionSuggestions(input: {
readonly context: ChatRouteContext;
readonly tenantSlug: string;
readonly chatId: string;
readonly query: string;
readonly type: ChatMentionSuggestion["type"] | null;
}): Promise<ChatMentionAutocompleteVM> {
const suggestions = await listChatMentionSuggestions({
tenantId: input.context.tenantId,
userId: input.context.userId,
permissions: input.context.permissions,
chatId: input.chatId,
query: input.query,
type: input.type,
limit: 10,
});
return buildChatMentionAutocompleteVM({
tenantSlug: input.tenantSlug,
suggestions: suggestions.map((suggestion) => ({
kind: suggestion.type,
id: suggestion.id,
label: suggestion.label,
detail: suggestion.detail,
})),
});
}