import { Injectable } from '@nestjs/common' ; import { MessageEntity , MessageRepository } from '@notifire/dal' ; import { ChannelTypeEnum } from '@notifire/shared' ; import { QueueService } from '../../../shared/services/queue' ; import { MarkMessageAsSeenCommand } from './mark-message-as-seen.command' ; @ Injectable ( ) export class MarkMessageAsSeen { constructor ( private messageRepository , private queueService ) { } async execute ( command ) { await this . messageRepository . changeSeenStatus ( command . subscriberId , command . messageId , true ) ; const count = await this . messageRepository . getUnseenCount ( command . applicationId , command . subscriberId , ChannelTypeEnum . IN_APP ) ; this . queueService . wsSocketQueue . add ( { event : 'unseen_count_changed' , userId : command . subscriberId , payload : { unseenCount : count , } , } ) ; return await this . messageRepository . findById ( command . messageId ) ; } }