feat: Add chat embeds v1

Youtube and Website metadata embeds
This commit is contained in:
2026-04-04 04:47:04 +02:00
parent 35352923a5
commit 84fa45985a
25 changed files with 759 additions and 24 deletions

View File

@@ -18,7 +18,8 @@ export async function handleSaveMessage(command: SaveMessageCommand, dataSource:
timestamp: message.timestamp,
editedAt: message.editedAt ?? null,
isDeleted: message.isDeleted ? 1 : 0,
replyToId: message.replyToId ?? null
replyToId: message.replyToId ?? null,
linkMetadata: message.linkMetadata ? JSON.stringify(message.linkMetadata) : null
});
await repo.save(entity);

View File

@@ -13,29 +13,35 @@ export async function handleUpdateMessage(command: UpdateMessageCommand, dataSou
if (!existing)
return;
if (updates.channelId !== undefined)
existing.channelId = updates.channelId ?? null;
const directFields = [
'senderId',
'senderName',
'content',
'timestamp'
] as const;
const entity = existing as unknown as Record<string, unknown>;
if (updates.senderId !== undefined)
existing.senderId = updates.senderId;
for (const field of directFields) {
if (updates[field] !== undefined)
entity[field] = updates[field];
}
if (updates.senderName !== undefined)
existing.senderName = updates.senderName;
const nullableFields = [
'channelId',
'editedAt',
'replyToId'
] as const;
if (updates.content !== undefined)
existing.content = updates.content;
if (updates.timestamp !== undefined)
existing.timestamp = updates.timestamp;
if (updates.editedAt !== undefined)
existing.editedAt = updates.editedAt ?? null;
for (const field of nullableFields) {
if (updates[field] !== undefined)
entity[field] = updates[field] ?? null;
}
if (updates.isDeleted !== undefined)
existing.isDeleted = updates.isDeleted ? 1 : 0;
if (updates.replyToId !== undefined)
existing.replyToId = updates.replyToId ?? null;
if (updates.linkMetadata !== undefined)
existing.linkMetadata = updates.linkMetadata ? JSON.stringify(updates.linkMetadata) : null;
await repo.save(existing);

View File

@@ -35,7 +35,8 @@ export function rowToMessage(row: MessageEntity, reactions: ReactionPayload[] =
editedAt: row.editedAt ?? undefined,
reactions: isDeleted ? [] : reactions,
isDeleted,
replyToId: row.replyToId ?? undefined
replyToId: row.replyToId ?? undefined,
linkMetadata: row.linkMetadata ? JSON.parse(row.linkMetadata) : undefined
};
}

View File

@@ -50,6 +50,7 @@ export interface MessagePayload {
reactions?: ReactionPayload[];
isDeleted?: boolean;
replyToId?: string;
linkMetadata?: { url: string; title?: string; description?: string; imageUrl?: string; siteName?: string; failed?: boolean }[];
}
export interface ReactionPayload {