2023-03-03 16:23:46 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
|
2023-07-24 16:19:31 +02:00
|
|
|
import { INotification, NotificationType } from "../models/eft/notifier/INotifier";
|
2023-03-03 16:23:46 +01:00
|
|
|
import { Message, MessageContentRagfair } from "../models/eft/profile/IAkiProfile";
|
|
|
|
import { HttpServerHelper } from "./HttpServerHelper";
|
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class NotifierHelper
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The default notification sent when waiting times out.
|
|
|
|
*/
|
|
|
|
protected defaultNotification: INotification = {
|
2023-07-24 16:19:31 +02:00
|
|
|
type: NotificationType.PING,
|
2023-03-03 16:23:46 +01:00
|
|
|
eventId: "ping"
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper
|
|
|
|
)
|
|
|
|
{}
|
|
|
|
|
|
|
|
public getDefaultNotification(): INotification
|
|
|
|
{
|
|
|
|
return this.defaultNotification;
|
|
|
|
}
|
|
|
|
|
2023-07-24 16:19:31 +02:00
|
|
|
/**
|
|
|
|
* Create a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside
|
|
|
|
* @param dialogueMessage Message from dialog that was sent
|
|
|
|
* @param ragfairData Ragfair data to attach to notification
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public createRagfairOfferSoldNotification(dialogueMessage: Message, ragfairData: MessageContentRagfair): INotification
|
|
|
|
{
|
|
|
|
return {
|
2023-07-24 16:19:31 +02:00
|
|
|
type: NotificationType.RAGFAIR_OFFER_SOLD,
|
|
|
|
eventId: dialogueMessage._id,
|
|
|
|
dialogId: dialogueMessage.uid,
|
2023-03-03 16:23:46 +01:00
|
|
|
...ragfairData
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2023-07-24 16:19:31 +02:00
|
|
|
/**
|
|
|
|
* Create a new notification with the specified dialogueMessage object
|
|
|
|
* @param dialogueMessage
|
|
|
|
* @returns
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public createNewMessageNotification(dialogueMessage: Message): INotification
|
|
|
|
{
|
|
|
|
return {
|
2023-07-24 16:19:31 +02:00
|
|
|
type: NotificationType.NEW_MESSAGE,
|
2023-03-03 16:23:46 +01:00
|
|
|
eventId: dialogueMessage._id,
|
|
|
|
dialogId: dialogueMessage.uid,
|
|
|
|
message: dialogueMessage
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public getWebSocketServer(sessionID: string): string
|
|
|
|
{
|
|
|
|
return `${this.httpServerHelper.getWebsocketUrl()}/notifierServer/getwebsocket/${sessionID}`;
|
|
|
|
}
|
|
|
|
}
|