From badfaa07d343c892c1569c7598675dec554060e3 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 14 Jan 2023 15:46:40 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=94=B6=E4=BB=B6?= =?UTF-8?q?=E7=AE=B1=E5=B7=B2=E8=AF=BB=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/models/chat/inbox.ts | 8 ++++++ .../services/core/chat/inbox.service.dev.ts | 25 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/server/models/chat/inbox.ts b/server/models/chat/inbox.ts index 6161ea31..5ea0d005 100644 --- a/server/models/chat/inbox.ts +++ b/server/models/chat/inbox.ts @@ -57,6 +57,14 @@ export class Inbox extends TimeStamps implements Base { type: () => InboxMessage, }) message?: InboxMessage; + + /** + * 是否已读 + */ + @prop({ + default: false, + }) + readed: boolean; } export type InboxDocument = DocumentType; diff --git a/server/services/core/chat/inbox.service.dev.ts b/server/services/core/chat/inbox.service.dev.ts index b183ca67..663a7d7e 100644 --- a/server/services/core/chat/inbox.service.dev.ts +++ b/server/services/core/chat/inbox.service.dev.ts @@ -78,6 +78,11 @@ class InboxService extends TcService { }, }); this.registerAction('all', this.all); + this.registerAction('ack', this.ack, { + params: { + inboxItemId: 'string', + }, + }); } async appendMessage( @@ -152,6 +157,26 @@ class InboxService extends TcService { return await this.transformDocuments(ctx, {}, list); } + /** + * 标记收件箱内容已读 + */ + async ack(ctx: TcContext<{ inboxItemId: string }>) { + const inboxItemId = ctx.params.inboxItemId; + const userId = ctx.meta.userId; + + await this.adapter.model.updateOne( + { + _id: inboxItemId, + userId, + }, + { + readed: true, + } + ); + + return true; + } + /** * 发送通知群组信息发生变更 *