Add enum for notification type
This commit is contained in:
parent
40149edeb2
commit
5c6aafea51
@ -1,6 +1,6 @@
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
import { INotification } from "../models/eft/notifier/INotifier";
|
||||
import { INotification, NotificationType } from "../models/eft/notifier/INotifier";
|
||||
import { Dialogue, IUserDialogInfo, Message } from "../models/eft/profile/IAkiProfile";
|
||||
import { MemberCategory } from "../models/enums/MemberCategory";
|
||||
import { MessageType } from "../models/enums/MessageType";
|
||||
@ -62,7 +62,7 @@ export class NotificationSendHelper
|
||||
dialog.messages.push(message);
|
||||
|
||||
const notification: INotification = {
|
||||
type: "new_message",
|
||||
type: NotificationType.NEW_MESSAGE,
|
||||
eventId: message._id,
|
||||
dialogId: message.uid,
|
||||
message: message
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { inject, injectable } from "tsyringe";
|
||||
|
||||
import { INotification } from "../models/eft/notifier/INotifier";
|
||||
import { INotification, NotificationType } from "../models/eft/notifier/INotifier";
|
||||
import { Message, MessageContentRagfair } from "../models/eft/profile/IAkiProfile";
|
||||
import { HttpServerHelper } from "./HttpServerHelper";
|
||||
|
||||
@ -11,7 +11,7 @@ export class NotifierHelper
|
||||
* The default notification sent when waiting times out.
|
||||
*/
|
||||
protected defaultNotification: INotification = {
|
||||
type: "ping",
|
||||
type: NotificationType.PING,
|
||||
eventId: "ping"
|
||||
};
|
||||
|
||||
@ -25,22 +25,31 @@ export class NotifierHelper
|
||||
return this.defaultNotification;
|
||||
}
|
||||
|
||||
/** Creates a new notification that displays the "Your offer was sold!" prompt and removes sold offer from "My Offers" on clientside */
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public createRagfairOfferSoldNotification(dialogueMessage: Message, ragfairData: MessageContentRagfair): INotification
|
||||
{
|
||||
return {
|
||||
"type": "RagfairOfferSold",
|
||||
"eventId": dialogueMessage._id,
|
||||
"dialogId": dialogueMessage.uid,
|
||||
type: NotificationType.RAGFAIR_OFFER_SOLD,
|
||||
eventId: dialogueMessage._id,
|
||||
dialogId: dialogueMessage.uid,
|
||||
...ragfairData
|
||||
};
|
||||
}
|
||||
|
||||
/** Creates a new notification with the specified dialogueMessage object. */
|
||||
/**
|
||||
* Create a new notification with the specified dialogueMessage object
|
||||
* @param dialogueMessage
|
||||
* @returns
|
||||
*/
|
||||
public createNewMessageNotification(dialogueMessage: Message): INotification
|
||||
{
|
||||
return {
|
||||
type: "new_message",
|
||||
type: NotificationType.NEW_MESSAGE,
|
||||
eventId: dialogueMessage._id,
|
||||
dialogId: dialogueMessage.uid,
|
||||
message: dialogueMessage
|
||||
|
@ -12,8 +12,15 @@ export interface INotifierChannel
|
||||
|
||||
export interface INotification
|
||||
{
|
||||
type: "RagfairOfferSold" | "new_message" | "ping";
|
||||
type: NotificationType;
|
||||
eventId: string
|
||||
dialogId?: string
|
||||
message?: Message
|
||||
}
|
||||
|
||||
export enum NotificationType
|
||||
{
|
||||
RAGFAIR_OFFER_SOLD = "RagfairOfferSold",
|
||||
NEW_MESSAGE = "new_message",
|
||||
PING = "ping"
|
||||
}
|
@ -3,7 +3,7 @@ import { inject, injectable } from "tsyringe";
|
||||
import WebSocket from "ws";
|
||||
|
||||
import { HttpServerHelper } from "../helpers/HttpServerHelper";
|
||||
import { INotification } from "../models/eft/notifier/INotifier";
|
||||
import { INotification, NotificationType } from "../models/eft/notifier/INotifier";
|
||||
import { ConfigTypes } from "../models/enums/ConfigTypes";
|
||||
import { IHttpConfig } from "../models/spt/config/IHttpConfig";
|
||||
import { ILogger } from "../models/spt/utils/ILogger";
|
||||
@ -28,7 +28,7 @@ export class WebSocketServer
|
||||
|
||||
protected httpConfig: IHttpConfig;
|
||||
protected defaultNotification: INotification = {
|
||||
type: "ping",
|
||||
type: NotificationType.PING,
|
||||
eventId: "ping"
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user