feat(guild-messaging): support message metadata for reply mentions and attachments
This commit is contained in:
@@ -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) ?? [];
|
||||
|
||||
Reference in New Issue
Block a user