From e2a1b1098999869d77fa7a69f01a7d69f0639214 Mon Sep 17 00:00:00 2001 From: chomp Date: Thu, 20 Jul 2023 19:27:28 +0000 Subject: [PATCH] Fixed bug to when talking with another user. Player messages shows like its being send from player instead of reciever. (!105) Co-authored-by: Kaeno Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/105 --- project/src/controllers/DialogueController.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/project/src/controllers/DialogueController.ts b/project/src/controllers/DialogueController.ts index 71143e90..47a451d9 100644 --- a/project/src/controllers/DialogueController.ts +++ b/project/src/controllers/DialogueController.ts @@ -20,7 +20,8 @@ export class DialogueController constructor( @inject("SaveServer") protected saveServer: SaveServer, @inject("TimeUtil") protected timeUtil: TimeUtil, - @inject("DialogueHelper") protected dialogueHelper: DialogueHelper + @inject("DialogueHelper") protected dialogueHelper: DialogueHelper, + @inject("HashUtil") protected hashUtil: HashUtil ) { } @@ -93,12 +94,32 @@ export class DialogueController "new": dialogue.new, "attachmentsNew": dialogue.attachmentsNew, "pinned": dialogue.pinned, - Users: dialogue.Users ? dialogue.Users : undefined + Users: this.getDialogueUsers(dialogue.Users, dialogue.type, sessionID) }; return result; } + public getDialogueUsers(users: IUserDialogInfo[], messageType: MessageType, sessionID: string): IUserDialogInfo[] + { + const profile = this.saveServer.getProfile(sessionID); + + if (messageType === MessageType.USER_MESSAGE && !users.find(x => x._id === profile.characters.pmc._id)) + { + users.push({ + _id: profile.characters.pmc._id, + info: { + Level: profile.characters.pmc.Info.Level, + Nickname: profile.characters.pmc.Info.Nickname, + Side: profile.characters.pmc.Info.Side, + MemberCategory: profile.characters.pmc.Info.MemberCategory + } + }); + } + + return users ? users : undefined; + } + /** * Handle client/mail/dialog/view * Handle player clicking 'messenger' and seeing all the messages they've recieved @@ -270,7 +291,7 @@ export class DialogueController dt: this.timeUtil.getTimestamp(), hasRewards: false, items: {}, - uid: sessionId, + uid: profile.characters.pmc._id, type: MessageType.USER_MESSAGE, rewardCollected: false, text: request.text