mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Only add player to users inside getProfilesForMail() if they dont exist
This commit is contained in:
parent
8178f40b5d
commit
b16d849280
@ -99,16 +99,17 @@ export class DialogueController
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Todo
|
* Get the users involved in a dialog (player + other party)
|
||||||
* @param users
|
* @param dialog The dialog to check for users
|
||||||
* @param messageType
|
* @param messageType What type of message is being sent
|
||||||
* @param sessionID
|
* @param sessionID Player id
|
||||||
* @returns
|
* @returns IUserDialogInfo array
|
||||||
*/
|
*/
|
||||||
public getDialogueUsers(dialog: Dialogue, messageType: MessageType, sessionID: string): IUserDialogInfo[]
|
public getDialogueUsers(dialog: Dialogue, messageType: MessageType, sessionID: string): IUserDialogInfo[]
|
||||||
{
|
{
|
||||||
const profile = this.saveServer.getProfile(sessionID);
|
const profile = this.saveServer.getProfile(sessionID);
|
||||||
|
|
||||||
|
// User to user messages are special in that they need the player to exist in them, add if they don't
|
||||||
if (messageType === MessageType.USER_MESSAGE && !dialog.Users?.find(x => x._id === profile.characters.pmc._id))
|
if (messageType === MessageType.USER_MESSAGE && !dialog.Users?.find(x => x._id === profile.characters.pmc._id))
|
||||||
{
|
{
|
||||||
if (!dialog.Users)
|
if (!dialog.Users)
|
||||||
@ -142,9 +143,10 @@ export class DialogueController
|
|||||||
public generateDialogueView(request: IGetMailDialogViewRequestData, sessionId: string): IGetMailDialogViewResponseData
|
public generateDialogueView(request: IGetMailDialogViewRequestData, sessionId: string): IGetMailDialogViewResponseData
|
||||||
{
|
{
|
||||||
const dialogueId = request.dialogId;
|
const dialogueId = request.dialogId;
|
||||||
const profile = this.saveServer.getProfile(sessionId);
|
const fullProfile = this.saveServer.getProfile(sessionId);
|
||||||
const dialogue = this.getDialogByIdFromProfile(profile, request);
|
const dialogue = this.getDialogByIdFromProfile(fullProfile, request);
|
||||||
|
|
||||||
|
// Dialog was opened, remove the little [1] on screen
|
||||||
dialogue.new = 0;
|
dialogue.new = 0;
|
||||||
|
|
||||||
// Set number of new attachments, but ignore those that have expired.
|
// Set number of new attachments, but ignore those that have expired.
|
||||||
@ -152,7 +154,7 @@ export class DialogueController
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
messages: dialogue.messages,
|
messages: dialogue.messages,
|
||||||
profiles: this.getProfilesForMail(profile, dialogue.Users),
|
profiles: this.getProfilesForMail(fullProfile, dialogue.Users),
|
||||||
hasMessagesWithRewards: this.messagesHaveUncollectedRewards(dialogue.messages)
|
hasMessagesWithRewards: this.messagesHaveUncollectedRewards(dialogue.messages)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -186,27 +188,32 @@ export class DialogueController
|
|||||||
return profile.dialogues[request.dialogId];
|
return profile.dialogues[request.dialogId];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* TODO
|
* Get the users involved in a mail between two entities
|
||||||
* @param pmcProfile
|
* @param fullProfile Player profile
|
||||||
* @param dialogUsers
|
* @param dialogUsers The participants of the mail
|
||||||
* @returns
|
* @returns IUserDialogInfo array
|
||||||
*/
|
*/
|
||||||
protected getProfilesForMail(pmcProfile: IAkiProfile, dialogUsers: IUserDialogInfo[]): IUserDialogInfo[]
|
protected getProfilesForMail(fullProfile: IAkiProfile, dialogUsers: IUserDialogInfo[]): IUserDialogInfo[]
|
||||||
{
|
{
|
||||||
const result: IUserDialogInfo[] = [];
|
const result: IUserDialogInfo[] = [];
|
||||||
if (dialogUsers)
|
if (dialogUsers)
|
||||||
{
|
{
|
||||||
result.push(...dialogUsers);
|
result.push(...dialogUsers);
|
||||||
const profile = pmcProfile.characters.pmc;
|
|
||||||
result.push({
|
// Plyer doesnt exist, add them in before returning
|
||||||
_id: pmcProfile.info.id,
|
if (!result.find(x => x._id === fullProfile.info.id))
|
||||||
info: {
|
{
|
||||||
Nickname: profile.Info.Nickname,
|
const pmcProfile = fullProfile.characters.pmc;
|
||||||
Side: profile.Info.Side,
|
result.push({
|
||||||
Level: profile.Info.Level,
|
_id: fullProfile.info.id,
|
||||||
MemberCategory: profile.Info.MemberCategory
|
info: {
|
||||||
}
|
Nickname: pmcProfile.Info.Nickname,
|
||||||
});
|
Side: pmcProfile.Info.Side,
|
||||||
|
Level: pmcProfile.Info.Level,
|
||||||
|
MemberCategory: pmcProfile.Info.MemberCategory
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user