Merge pull request #820 from Hexastack/810-investigate-sync-message-cross-browser-tabsmultiple-users-using-the-same-account
Some checks failed
Build and Push Docker API Image / build-and-push (push) Has been cancelled
Build and Push Docker Base Image / build-and-push (push) Has been cancelled
Build and Push Docker UI Image / build-and-push (push) Has been cancelled

fix: synchronized sent messages cross account tabs
This commit is contained in:
Med Marrouchi 2025-03-21 08:37:27 +01:00 committed by GitHub
commit e0a77302cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,6 +47,19 @@ export class ChatService {
private readonly attachmentService: AttachmentService,
) {}
/**
* Synchronize sent messages cross opened websocket connections of the same account
*
* @param event - The received event
*/
private broadcastSentMessages(event: EventWrapper<any, any>) {
this.websocketGateway.broadcast(
event.getSender(),
event.getEventType(),
event._adapter.raw,
);
}
/**
* Ends a given conversation (sets active to false)
*
@ -268,6 +281,7 @@ export class ChatService {
// Already existing user profile
// Exec lastvisit hook
this.eventEmitter.emit('hook:user:lastvisit', subscriber);
this.broadcastSentMessages(event);
}
this.websocketGateway.broadcastSubscriberUpdate(subscriber);