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 <e>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/105
This commit is contained in:
chomp 2023-07-20 19:27:28 +00:00
parent b324d6ff6e
commit e2a1b10989

View File

@ -20,7 +20,8 @@ export class DialogueController
constructor( constructor(
@inject("SaveServer") protected saveServer: SaveServer, @inject("SaveServer") protected saveServer: SaveServer,
@inject("TimeUtil") protected timeUtil: TimeUtil, @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, "new": dialogue.new,
"attachmentsNew": dialogue.attachmentsNew, "attachmentsNew": dialogue.attachmentsNew,
"pinned": dialogue.pinned, "pinned": dialogue.pinned,
Users: dialogue.Users ? dialogue.Users : undefined Users: this.getDialogueUsers(dialogue.Users, dialogue.type, sessionID)
}; };
return result; 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 client/mail/dialog/view
* Handle player clicking 'messenger' and seeing all the messages they've recieved * Handle player clicking 'messenger' and seeing all the messages they've recieved
@ -270,7 +291,7 @@ export class DialogueController
dt: this.timeUtil.getTimestamp(), dt: this.timeUtil.getTimestamp(),
hasRewards: false, hasRewards: false,
items: {}, items: {},
uid: sessionId, uid: profile.characters.pmc._id,
type: MessageType.USER_MESSAGE, type: MessageType.USER_MESSAGE,
rewardCollected: false, rewardCollected: false,
text: request.text text: request.text