Skip to content

Commit

Permalink
feat: 增加收件箱已读标识
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Jan 14, 2023
1 parent 692e66d commit badfaa0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server/models/chat/inbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export class Inbox extends TimeStamps implements Base {
type: () => InboxMessage,
})
message?: InboxMessage;

/**
* 是否已读
*/
@prop({
default: false,
})
readed: boolean;
}

export type InboxDocument = DocumentType<Inbox>;
Expand Down
25 changes: 25 additions & 0 deletions server/services/core/chat/inbox.service.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class InboxService extends TcService {
},
});
this.registerAction('all', this.all);
this.registerAction('ack', this.ack, {
params: {
inboxItemId: 'string',
},
});
}

async appendMessage(
Expand Down Expand Up @@ -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;
}

/**
* 发送通知群组信息发生变更
*
Expand Down

0 comments on commit badfaa0

Please sign in to comment.