Fixed new profiles failing to start game during christmas/new years event
Add new function in dialog helper for getting dialogs frm profile - creates empty object if none found Set gift collection time to 48 hours if none supplied
This commit is contained in:
parent
0c37a76ff6
commit
cbcd431f09
@ -215,7 +215,8 @@
|
|||||||
"sender": "System",
|
"sender": "System",
|
||||||
"messageText": "Merry christmas!",
|
"messageText": "Merry christmas!",
|
||||||
"timestampToSend": 42069,
|
"timestampToSend": 42069,
|
||||||
"associatedEvent": "Christmas"
|
"associatedEvent": "Christmas",
|
||||||
|
"collectionTimeHours": 48,
|
||||||
},
|
},
|
||||||
"1CLICKDRESSUP": {
|
"1CLICKDRESSUP": {
|
||||||
"items": [{
|
"items": [{
|
||||||
|
@ -72,7 +72,7 @@ export class DialogueController
|
|||||||
public generateDialogueList(sessionID: string): DialogueInfo[]
|
public generateDialogueList(sessionID: string): DialogueInfo[]
|
||||||
{
|
{
|
||||||
const data: DialogueInfo[] = [];
|
const data: DialogueInfo[] = [];
|
||||||
for (const dialogueId in this.saveServer.getProfile(sessionID).dialogues)
|
for (const dialogueId in this.dialogueHelper.getDialogsForProfile(sessionID).dialogues)
|
||||||
{
|
{
|
||||||
data.push(this.getDialogueInfo(dialogueId, sessionID));
|
data.push(this.getDialogueInfo(dialogueId, sessionID));
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ export class DialogueController
|
|||||||
*/
|
*/
|
||||||
public getDialogueInfo(dialogueID: string, sessionID: string): DialogueInfo
|
public getDialogueInfo(dialogueID: string, sessionID: string): DialogueInfo
|
||||||
{
|
{
|
||||||
const dialogue = this.saveServer.getProfile(sessionID).dialogues[dialogueID];
|
const dialogue = this.dialogueHelper.getDialogsForProfile(sessionID).dialogues[dialogueID];
|
||||||
|
|
||||||
const result: DialogueInfo = {
|
const result: DialogueInfo = {
|
||||||
_id: dialogueID,
|
_id: dialogueID,
|
||||||
@ -277,8 +277,7 @@ export class DialogueController
|
|||||||
/** Handle client/mail/dialog/pin && Handle client/mail/dialog/unpin */
|
/** Handle client/mail/dialog/pin && Handle client/mail/dialog/unpin */
|
||||||
public setDialoguePin(dialogueId: string, shouldPin: boolean, sessionId: string): void
|
public setDialoguePin(dialogueId: string, shouldPin: boolean, sessionId: string): void
|
||||||
{
|
{
|
||||||
const profile = this.saveServer.getProfile(sessionId);
|
const dialog = this.dialogueHelper.getDialogsForProfile(sessionId)[dialogueId];
|
||||||
const dialog = profile.dialogues[dialogueId];
|
|
||||||
if (!dialog)
|
if (!dialog)
|
||||||
{
|
{
|
||||||
this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`);
|
this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`);
|
||||||
@ -297,8 +296,7 @@ export class DialogueController
|
|||||||
*/
|
*/
|
||||||
public setRead(dialogueIds: string[], sessionId: string): void
|
public setRead(dialogueIds: string[], sessionId: string): void
|
||||||
{
|
{
|
||||||
const profile = this.saveServer.getProfile(sessionId);
|
const dialogs = this.dialogueHelper.getDialogsForProfile(sessionId);
|
||||||
const dialogs = profile.dialogues;
|
|
||||||
if (!dialogs)
|
if (!dialogs)
|
||||||
{
|
{
|
||||||
this.logger.error(`No dialog object in profile: ${sessionId}`);
|
this.logger.error(`No dialog object in profile: ${sessionId}`);
|
||||||
@ -322,8 +320,8 @@ export class DialogueController
|
|||||||
*/
|
*/
|
||||||
public getAllAttachments(dialogueId: string, sessionId: string): IGetAllAttachmentsResponse
|
public getAllAttachments(dialogueId: string, sessionId: string): IGetAllAttachmentsResponse
|
||||||
{
|
{
|
||||||
const profile = this.saveServer.getProfile(sessionId);
|
const dialogs = this.dialogueHelper.getDialogsForProfile(sessionId);
|
||||||
const dialog = profile.dialogues[dialogueId];
|
const dialog = dialogs[dialogueId];
|
||||||
if (!dialog)
|
if (!dialog)
|
||||||
{
|
{
|
||||||
this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`);
|
this.logger.error(`No dialog in profile: ${sessionId} found with id: ${dialogueId}`);
|
||||||
@ -434,7 +432,8 @@ export class DialogueController
|
|||||||
protected getActiveMessagesFromDialog(sessionId: string, dialogueId: string): Message[]
|
protected getActiveMessagesFromDialog(sessionId: string, dialogueId: string): Message[]
|
||||||
{
|
{
|
||||||
const timeNow = this.timeUtil.getTimestamp();
|
const timeNow = this.timeUtil.getTimestamp();
|
||||||
return this.saveServer.getProfile(sessionId).dialogues[dialogueId].messages.filter(x => timeNow < (x.dt + x.maxStorageTime));
|
const dialogs = this.dialogueHelper.getDialogsForProfile(sessionId);
|
||||||
|
return dialogs[dialogueId].messages.filter(x => timeNow < (x.dt + x.maxStorageTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -453,7 +452,7 @@ export class DialogueController
|
|||||||
*/
|
*/
|
||||||
protected removeExpiredItemsFromMessages(sessionId: string): void
|
protected removeExpiredItemsFromMessages(sessionId: string): void
|
||||||
{
|
{
|
||||||
for (const dialogueId in this.saveServer.getProfile(sessionId).dialogues)
|
for (const dialogueId in this.dialogueHelper.getDialogsForProfile(sessionId))
|
||||||
{
|
{
|
||||||
this.removeExpiredItemsFromMessage(sessionId, dialogueId);
|
this.removeExpiredItemsFromMessage(sessionId, dialogueId);
|
||||||
}
|
}
|
||||||
@ -466,7 +465,14 @@ export class DialogueController
|
|||||||
*/
|
*/
|
||||||
protected removeExpiredItemsFromMessage(sessionId: string, dialogueId: string): void
|
protected removeExpiredItemsFromMessage(sessionId: string, dialogueId: string): void
|
||||||
{
|
{
|
||||||
for (const message of this.saveServer.getProfile(sessionId).dialogues[dialogueId].messages)
|
const dialogs = this.dialogueHelper.getDialogsForProfile(sessionId);
|
||||||
|
const dialog = dialogs[dialogueId];
|
||||||
|
if (!dialog.messages)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const message of dialog.messages)
|
||||||
{
|
{
|
||||||
if (this.messageHasExpired(message))
|
if (this.messageHasExpired(message))
|
||||||
{
|
{
|
||||||
|
@ -223,4 +223,20 @@ export class DialogueHelper
|
|||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the dialogs dictionary for a profile, create if doesnt exist
|
||||||
|
* @param sessionId Session/player id
|
||||||
|
* @returns Dialog dictionary
|
||||||
|
*/
|
||||||
|
public getDialogsForProfile(sessionId: string): Record<string, Dialogue>
|
||||||
|
{
|
||||||
|
const profile = this.saveServer.getProfile(sessionId);
|
||||||
|
if (!profile.dialogues)
|
||||||
|
{
|
||||||
|
profile.dialogues = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return profile.dialogues;
|
||||||
|
}
|
||||||
}
|
}
|
@ -61,6 +61,11 @@ export class GiftService
|
|||||||
return GiftSentResult.FAILED_GIFT_ALREADY_RECEIVED;
|
return GiftSentResult.FAILED_GIFT_ALREADY_RECEIVED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (giftData.items?.length > 0 && !giftData.collectionTimeHours)
|
||||||
|
{
|
||||||
|
this.logger.warning(`Gift ${giftId} has items but no collection time limit, defaulting to 48 hours`);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle system messsages
|
// Handle system messsages
|
||||||
if (giftData.sender === GiftSenderType.SYSTEM)
|
if (giftData.sender === GiftSenderType.SYSTEM)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { DialogueHelper } from "../helpers/DialogueHelper";
|
||||||
import { ItemHelper } from "../helpers/ItemHelper";
|
import { ItemHelper } from "../helpers/ItemHelper";
|
||||||
import { NotificationSendHelper } from "../helpers/NotificationSendHelper";
|
import { NotificationSendHelper } from "../helpers/NotificationSendHelper";
|
||||||
import { NotifierHelper } from "../helpers/NotifierHelper";
|
import { NotifierHelper } from "../helpers/NotifierHelper";
|
||||||
@ -26,6 +27,7 @@ export class MailSendService
|
|||||||
@inject("SaveServer") protected saveServer: SaveServer,
|
@inject("SaveServer") protected saveServer: SaveServer,
|
||||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||||
@inject("NotifierHelper") protected notifierHelper: NotifierHelper,
|
@inject("NotifierHelper") protected notifierHelper: NotifierHelper,
|
||||||
|
@inject("DialogueHelper") protected dialogueHelper: DialogueHelper,
|
||||||
@inject("NotificationSendHelper") protected notificationSendHelper: NotificationSendHelper,
|
@inject("NotificationSendHelper") protected notificationSendHelper: NotificationSendHelper,
|
||||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||||
@inject("ItemHelper") protected itemHelper: ItemHelper
|
@inject("ItemHelper") protected itemHelper: ItemHelper
|
||||||
@ -361,7 +363,7 @@ export class MailSendService
|
|||||||
*/
|
*/
|
||||||
protected getDialog(messageDetails: ISendMessageDetails): Dialogue
|
protected getDialog(messageDetails: ISendMessageDetails): Dialogue
|
||||||
{
|
{
|
||||||
const dialogsInProfile = this.saveServer.getProfile(messageDetails.recipientId).dialogues;
|
const dialogsInProfile = this.dialogueHelper.getDialogsForProfile(messageDetails.recipientId);
|
||||||
const senderId = this.getMessageSenderIdByType(messageDetails);
|
const senderId = this.getMessageSenderIdByType(messageDetails);
|
||||||
|
|
||||||
// Does dialog exist
|
// Does dialog exist
|
||||||
|
Loading…
Reference in New Issue
Block a user