fix
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
import { Server, Socket } from 'socket.io';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { MessagesService } from './messages.service';
|
||||
import { CreateMessageDto } from './dto';
|
||||
import { Logger } from '@nestjs/common';
|
||||
@@ -37,6 +38,7 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
|
||||
private readonly messagesService: MessagesService,
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly configService: ConfigService,
|
||||
private readonly eventEmitter: EventEmitter2,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -186,6 +188,19 @@ export class MessagesGateway implements OnGatewayConnection, OnGatewayDisconnect
|
||||
? participants.agentUserId
|
||||
: participants.userId;
|
||||
this.sendToUser(otherUserId, 'new_message', message);
|
||||
|
||||
// Emit push notification event
|
||||
const senderProfile = message.sender?.agentProfile || message.sender?.userProfile;
|
||||
const senderName = senderProfile
|
||||
? `${senderProfile.firstName || ''} ${senderProfile.lastName || ''}`.trim()
|
||||
: 'Someone';
|
||||
|
||||
this.eventEmitter.emit('notification.message', {
|
||||
recipientUserId: otherUserId,
|
||||
senderName,
|
||||
messagePreview: data.message.content?.substring(0, 100) || '',
|
||||
conversationId: data.conversationId,
|
||||
});
|
||||
}
|
||||
|
||||
return { success: true, message };
|
||||
|
||||
Reference in New Issue
Block a user