feat(chat): add private message unlock flow
This commit is contained in:
@@ -49,17 +49,25 @@ export const chatRepo: IChatRepository = chatRepository;
|
||||
*/
|
||||
export function localMessagesToUi(
|
||||
records: ReadonlyArray<{
|
||||
id?: string;
|
||||
content: string;
|
||||
role: string;
|
||||
createdAt: string;
|
||||
imageUrl?: string | null;
|
||||
isPrivate?: boolean | null;
|
||||
privateLocked?: boolean | null;
|
||||
privateHint?: string | null;
|
||||
}>,
|
||||
): UiMessage[] {
|
||||
return records.map((m) => ({
|
||||
...(m.id ? { id: m.id } : {}),
|
||||
content: m.content,
|
||||
isFromAI: m.role === "assistant",
|
||||
date: messageDateFromCreatedAt(m.createdAt),
|
||||
...(m.imageUrl ? { imageUrl: m.imageUrl } : {}),
|
||||
...(m.isPrivate != null ? { isPrivate: m.isPrivate } : {}),
|
||||
...(m.privateLocked != null ? { privateLocked: m.privateLocked } : {}),
|
||||
...(m.privateHint != null ? { privateHint: m.privateHint } : {}),
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -76,6 +84,7 @@ function messageDateFromCreatedAt(createdAt: string): string {
|
||||
*/
|
||||
export function sendResponseToUiMessage(response: ChatSendResponse): UiMessage {
|
||||
return {
|
||||
...(response.messageId ? { id: response.messageId } : {}),
|
||||
content: response.reply,
|
||||
isFromAI: true,
|
||||
date: todayString(new Date(response.timestamp)),
|
||||
|
||||
Reference in New Issue
Block a user