feat(guild-messaging): support message metadata for reply mentions and attachments

This commit is contained in:
nav
2026-05-12 10:28:02 +00:00
parent ceaece754e
commit d3fdc3dd1e
6 changed files with 124 additions and 4 deletions

View File

@@ -1,9 +1,15 @@
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { CreateMessageDto } from './dto.create-message.dto';
type Message = {
messageId: string;
seq: number;
content: string;
authorUserId: string;
replyToMessageId: string | null;
mentions: string[];
attachments: Array<{ url: string; name?: string; mimeType?: string }>;
createdAt: string;
};
@Controller('channels/:id/messages')
@@ -12,14 +18,19 @@ export class MessagingController {
private messagesByChannel = new Map<string, Message[]>();
@Post()
create(@Param('id') channelId: string, @Body() body: { content?: string; messageId?: string }) {
create(@Param('id') channelId: string, @Body() body: CreateMessageDto) {
const next = (this.seqByChannel.get(channelId) ?? 0) + 1;
this.seqByChannel.set(channelId, next);
const message: Message = {
messageId: body.messageId ?? `m-${channelId}-${next}`,
messageId: body.clientMessageId ?? `m-${channelId}-${next}`,
seq: next,
content: body.content ?? '',
content: body.content,
authorUserId: body.authorUserId ?? 'anonymous',
replyToMessageId: body.replyToMessageId ?? null,
mentions: body.mentions ?? [],
attachments: body.attachments ?? [],
createdAt: new Date().toISOString(),
};
const arr = this.messagesByChannel.get(channelId) ?? [];