0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 02:30:43 -05:00

restructured Notification interfaces...

- Restructured notification interfaces
- Added some missing enums
This commit is contained in:
TheSparta 2024-05-15 23:47:37 +01:00
parent 9d127cbb6c
commit f147bb64eb
31 changed files with 233 additions and 58 deletions

View File

@ -1,8 +1,10 @@
import { inject, injectable } from "tsyringe";
import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier";
import { Dialogue, IUserDialogInfo, Message } from "@spt-aki/models/eft/profile/IAkiProfile";
import { IWsChatMessageReceived } from "@spt-aki/models/eft/ws/IWsChatMessageReceived";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
import { MessageType } from "@spt-aki/models/enums/MessageType";
import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType";
import { SaveServer } from "@spt-aki/servers/SaveServer";
import { WebSocketServer } from "@spt-aki/servers/WebSocketServer";
import { NotificationService } from "@spt-aki/services/NotificationService";
@ -24,7 +26,7 @@ export class NotificationSendHelper
* @param sessionID
* @param notificationMessage
*/
public sendMessage(sessionID: string, notificationMessage: INotification): void
public sendMessage(sessionID: string, notificationMessage: IWsNotificationEvent): void
{
if (this.webSocketServer.isConnectionWebSocket(sessionID))
{
@ -65,8 +67,8 @@ export class NotificationSendHelper
};
dialog.messages.push(message);
const notification: INotification = {
type: NotificationType.NEW_MESSAGE,
const notification: IWsChatMessageReceived = {
type: NotificationEventType.CHAT_MESSAGE_RECEIVED,
eventId: message._id,
dialogId: message.uid,
message: message,

View File

@ -1,7 +1,10 @@
import { inject, injectable } from "tsyringe";
import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper";
import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier";
import { Message, MessageContentRagfair } from "@spt-aki/models/eft/profile/IAkiProfile";
import { IWsChatMessageReceived } from "@spt-aki/models/eft/ws/IWsChatMessageReceived";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { IWsRagfairOfferSold } from "@spt-aki/models/eft/ws/IWsRagfairOfferSold";
import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType";
@injectable()
export class NotifierHelper
@ -9,12 +12,12 @@ export class NotifierHelper
/**
* The default notification sent when waiting times out.
*/
protected defaultNotification: INotification = { type: NotificationType.PING, eventId: "ping" };
protected defaultNotification: IWsNotificationEvent = { type: NotificationEventType.PING, eventId: "ping" };
constructor(@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper)
{}
public getDefaultNotification(): INotification
public getDefaultNotification(): IWsNotificationEvent
{
return this.defaultNotification;
}
@ -28,12 +31,11 @@ export class NotifierHelper
public createRagfairOfferSoldNotification(
dialogueMessage: Message,
ragfairData: MessageContentRagfair,
): INotification
): IWsRagfairOfferSold
{
return {
type: NotificationType.RAGFAIR_OFFER_SOLD,
type: NotificationEventType.RAGFAIR_OFFER_SOLD,
eventId: dialogueMessage._id,
dialogId: dialogueMessage.uid,
...ragfairData,
};
}
@ -43,10 +45,10 @@ export class NotifierHelper
* @param dialogueMessage
* @returns
*/
public createNewMessageNotification(dialogueMessage: Message): INotification
public createNewMessageNotification(dialogueMessage: Message): IWsChatMessageReceived
{
return {
type: NotificationType.NEW_MESSAGE,
type: NotificationEventType.CHAT_MESSAGE_RECEIVED,
eventId: dialogueMessage._id,
dialogId: dialogueMessage.uid,
message: dialogueMessage,

View File

@ -1,49 +1,9 @@
import { Message } from "@spt-aki/models/eft/profile/IAkiProfile";
export interface INotifierChannel
{
server: string
// eslint-disable-next-line @typescript-eslint/naming-convention
channel_id: string
url: string
notifierServer: string
ws: string
}
export interface INotification
{
type: NotificationType
eventId: string
dialogId?: string
message?: Message
}
export enum NotificationType
{
RAGFAIR_OFFER_SOLD = "RagfairOfferSold",
RAGFAIR_RATING_CHANGE = "RagfairRatingChange",
/** ChatMessageReceived */
NEW_MESSAGE = "new_message",
PING = "ping",
TRADER_SUPPLY = "TraderSupply",
TRADER_STANDING = "TraderStanding",
UNLOCK_TRADER = "UnlockTrader",
GROUP_MATCH_RAID_SETTINGS = "groupMatchRaidSettings",
GROUP_MATCH_RAID_NOT_READY = "groupMatchRaidNotReady",
GROUP_MATCH_RAID_READY = "groupMatchRaidReady",
GROUP_MATCH_INVITE_ACCEPT = "groupMatchInviteAccept",
GROUP_MATCH_INVITE_DECLINE = "groupMatchInviteDecline",
GROUP_MATCH_INVITE_SEND = "groupMatchInviteSend",
GROUP_MATCH_LEADER_CHANGED = "groupMatchLeaderChanged",
GROUP_MATCH_START_GAME = "groupMatchStartGame",
GROUP_MATCH_USER_LEAVE = "groupMatchUserLeave",
GROUP_MATCH_WAS_REMOVED = "groupMatchWasRemoved",
GROUP_MATCH_USER_BAD_VERSION = "groupMatchUserHasBadVersion",
USER_CONFIRMED = "userConfirmed",
CHANNEL_DELETED = "channel_deleted",
FRIEND_LIST_REQUEST_ACCEPTED = "friendListRequestAccept",
FRIEND_LIST_REQUEST_DECLINED = "friendListRequestDecline",
FRIEND_LIST_NEW_REQUEST = "friendListNewRequest",
FRIEND_LIST_REMOVED_FROM_FRIEND_LIST = "youAreRemovedFromFriendList",
YOU_ARE_ADDED_TO_IGNORE_LIST = "YouWereAddedToIgnoreList",
YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList",
}

View File

@ -0,0 +1,6 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsAid extends IWsNotificationEvent
{
aid: number
}

View File

@ -0,0 +1,7 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsAidNickname extends IWsNotificationEvent
{
aid: number
Nickname: string
}

View File

@ -0,0 +1,10 @@
import { Message } from "@spt-aki/models/eft/profile/IAkiProfile";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { IGroupCharacter } from "../match/IGroupCharacter";
export interface IWsChatMessageReceived extends IWsNotificationEvent
{
dialogId: string
message: Message
profiles?: IGroupCharacter[]
}

View File

@ -0,0 +1,6 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupId extends IWsNotificationEvent
{
groupId: string
}

View File

@ -0,0 +1,7 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { IGroupCharacter } from "../match/IGroupCharacter";
export interface IWsGroupMatchInviteAccept extends IWsNotificationEvent, IGroupCharacter
{
}

View File

@ -0,0 +1,7 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupMatchInviteDecline extends IWsNotificationEvent
{
aid: number
Nickname: string
}

View File

@ -0,0 +1,9 @@
import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupMatchInviteSend extends IWsNotificationEvent
{
requestId: string
from: number
members: IGroupCharacter[]
}

View File

@ -0,0 +1,6 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupMatchLeaderChanged extends IWsNotificationEvent
{
owner: number
}

View File

@ -0,0 +1,7 @@
import { IGroupCharacter } from "@spt-aki/models/eft/match/IGroupCharacter";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupMatchRaidReady extends IWsNotificationEvent
{
extendedProfile: IGroupCharacter
}

View File

@ -0,0 +1,7 @@
import { IRaidSettings } from "@spt-aki/models/eft/match/IRaidSettings";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsGroupMatchRaidSettings extends IWsNotificationEvent
{
raidSettings: IRaidSettings
}

View File

@ -0,0 +1,5 @@
export interface IWsNotificationEvent
{
type: string
eventId: string
}

View File

@ -0,0 +1,6 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsPing extends IWsNotificationEvent
{
}

View File

@ -0,0 +1,8 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
export interface IWsRagfairOfferSold extends IWsNotificationEvent
{
offerId: string
count: number
handbookId: string
}

View File

@ -0,0 +1,20 @@
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { ProfileStatus } from "@spt-aki/models/enums/ProfileStatus";
import { RaidMode } from "@spt-aki/models/enums/RaidMode";
export interface IWsUserConfirmed extends IWsNotificationEvent
{
profileid: string
profileToken: string
status: ProfileStatus
ip: string
port: number
sid: string
version: string
location: string
raidMode: RaidMode
mode: string
shortId: string
// eslint-disable-next-line @typescript-eslint/naming-convention
additional_info: any[]
}

View File

@ -0,0 +1,5 @@
export enum DateTime
{
CURR = "CURR",
PAST = "PAST",
}

View File

@ -0,0 +1,29 @@
export enum NotificationEventType
{
RAGFAIR_OFFER_SOLD = "RagfairOfferSold",
RAGFAIR_RATING_CHANGE = "RagfairRatingChange",
CHAT_MESSAGE_RECEIVED = "new_message",
PING = "ping",
TRADER_SUPPLY = "TraderSupply",
TRADER_STANDING = "TraderStanding",
UNLOCK_TRADER = "UnlockTrader",
GROUP_MATCH_RAID_SETTINGS = "groupMatchRaidSettings",
GROUP_MATCH_RAID_NOT_READY = "groupMatchRaidNotReady",
GROUP_MATCH_RAID_READY = "groupMatchRaidReady",
GROUP_MATCH_INVITE_ACCEPT = "groupMatchInviteAccept",
GROUP_MATCH_INVITE_DECLINE = "groupMatchInviteDecline",
GROUP_MATCH_INVITE_SEND = "groupMatchInviteSend",
GROUP_MATCH_LEADER_CHANGED = "groupMatchLeaderChanged",
GROUP_MATCH_START_GAME = "groupMatchStartGame",
GROUP_MATCH_USER_LEAVE = "groupMatchUserLeave",
GROUP_MATCH_WAS_REMOVED = "groupMatchWasRemoved",
GROUP_MATCH_USER_BAD_VERSION = "groupMatchUserHasBadVersion",
USER_CONFIRMED = "userConfirmed",
CHANNEL_DELETED = "channel_deleted",
FRIEND_LIST_REQUEST_ACCEPTED = "friendListRequestAccept",
FRIEND_LIST_REQUEST_DECLINED = "friendListRequestDecline",
FRIEND_LIST_NEW_REQUEST = "friendListNewRequest",
FRIEND_LIST_REMOVED_FROM_FRIEND_LIST = "youAreRemovedFromFriendList",
YOU_ARE_ADDED_TO_IGNORE_LIST = "YouWereAddedToIgnoreList",
YOU_ARE_REMOVED_FROM_IGNORE_LIST = "youAreRemoveFromIgnoreList",
}

View File

@ -0,0 +1,6 @@
export enum PlayersSpawnPlace
{
SAME_PLACE = "SamePlace",
DIFFERENT_PLACES = "DifferentPlaces",
AT_THE_ENDS_OF_THE_MAP = "AtTheEndsOfTheMap",
}

View File

@ -0,0 +1,8 @@
export enum ProfileStatus
{
FREE = "Free",
MATCH_WAIT = "MatchWait",
BUSY = "Busy",
LEAVING = "Leaving",
TRANSFER = "Transfer",
}

View File

@ -1,6 +1,7 @@
export enum BotAmount
{
AS_ONLINE = "AsOnline",
NO_BOTS = "NoBots",
LOW = "Low",
MEDIUM = "Medium",
HIGH = "High",

View File

@ -0,0 +1,9 @@
export enum CloudinessType
{
CLEAR = "Clear",
PARTLY_CLOUDY = "PartlyCloudy",
CLOUDY = "Cloudy",
CLOUDY_WITH_GAPS = "CloudyWithGaps",
HEAVY_CLOUD_COVER = "HeavyCloudCover",
THUNDER_CLOUD = "Thundercloud",
}

View File

@ -0,0 +1,8 @@
export enum FogType
{
NO_FOG = "NoFog",
FAINT = "Faint",
FOG = "Fog",
HEAVY = "Heavy",
CONTINUOUS = "Continuous",
}

View File

@ -0,0 +1,8 @@
export enum RainType
{
NO_RAIN = "NoRain",
DRIZZLING = "Drizzling",
RAIN = "Rain",
HEAVY = "Heavy",
SHOWER = "Shower",
}

View File

@ -0,0 +1,11 @@
export enum TimeFlowType
{
X0 = "x0",
X0_14 = "x0_14",
X0_25 = "x0_25",
X0_5 = "x0_5",
X1 = "x1",
X2 = "x2",
X4 = "x4",
X8 = "x8",
}

View File

@ -0,0 +1,8 @@
export enum WindSpeed
{
LIGHT = "Light",
MODERATE = "Moderate",
STRONG = "Strong",
VERY_STRONG = "VeryStrong",
HURRICANE = "Hurricane",
}

View File

@ -0,0 +1,6 @@
export enum SideType
{
PMC = "Pmc",
SAVAGE = "Savage",
RANDOM = "Random",
}

View File

@ -3,8 +3,9 @@ import { inject, injectable } from "tsyringe";
import WebSocket from "ws";
import { HttpServerHelper } from "@spt-aki/helpers/HttpServerHelper";
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
import { INotification, NotificationType } from "@spt-aki/models/eft/notifier/INotifier";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { NotificationEventType } from "@spt-aki/models/enums/NotificationEventType";
import { IHttpConfig } from "@spt-aki/models/spt/config/IHttpConfig";
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
@ -29,7 +30,7 @@ export class WebSocketServer
}
protected httpConfig: IHttpConfig;
protected defaultNotification: INotification = { type: NotificationType.PING, eventId: "ping" };
protected defaultNotification: IWsNotificationEvent = { type: NotificationEventType.PING, eventId: "ping" };
protected webSocketServer: WebSocket.Server;
protected webSockets: Record<string, WebSocket.WebSocket> = {};
@ -62,7 +63,7 @@ export class WebSocketServer
this.webSocketServer.addListener("connection", this.wsOnConnection.bind(this));
}
public sendMessage(sessionID: string, output: INotification): void
public sendMessage(sessionID: string, output: IWsNotificationEvent): void
{
try
{

View File

@ -1,5 +1,5 @@
import { injectable } from "tsyringe";
import { INotification } from "@spt-aki/models/eft/notifier/INotifier";
import { IWsNotificationEvent } from "@spt-aki/models/eft/ws/IWsNotificationEvent";
@injectable()
export class NotificationService
@ -37,7 +37,7 @@ export class NotificationService
/**
* Add message to queue
*/
public add(sessionID: string, message: INotification): void
public add(sessionID: string, message: IWsNotificationEvent): void
{
this.get(sessionID).push(message);
}