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