Server/project/src/helpers/NotifierHelper.ts
Refringe 4ac12ef70a Formatting/Linting Changes (!168)
These are the formatting & linting configuration changes from the `3.8.0` branch and the changes that they make to the overall project.

The majority of these changes are from running two commands:

`npm run lint:fix`
`npm run style:fix`

This has already been run on the `3.8.0` branch and this PR should make `master` play nicer when it comes to merges going forward.

There are now four VSCode plugins recommended for server development. They've been added to the workspace file and a user should get a UI notification when the workspace is opened if they're not installed.

The four plugins are:
https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
https://marketplace.visualstudio.com/items?itemName=dprint.dprint
https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
https://marketplace.visualstudio.com/items?itemName=biomejs.biome

Once installed they should just work within the workspace.

Also, be sure to `npm i` to get the new dprint application.

Co-authored-by: Refringe <brownelltyler@gmail.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/168
2023-11-16 21:42:06 +00:00

62 lines
1.9 KiB
TypeScript

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";
@injectable()
export class NotifierHelper
{
/**
* The default notification sent when waiting times out.
*/
protected defaultNotification: INotification = { type: NotificationType.PING, eventId: "ping" };
constructor(@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper)
{}
public getDefaultNotification(): INotification
{
return this.defaultNotification;
}
/**
* 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: NotificationType.RAGFAIR_OFFER_SOLD,
eventId: dialogueMessage._id,
dialogId: dialogueMessage.uid,
...ragfairData,
};
}
/**
* Create a new notification with the specified dialogueMessage object
* @param dialogueMessage
* @returns
*/
public createNewMessageNotification(dialogueMessage: Message): INotification
{
return {
type: NotificationType.NEW_MESSAGE,
eventId: dialogueMessage._id,
dialogId: dialogueMessage.uid,
message: dialogueMessage,
};
}
public getWebSocketServer(sessionID: string): string
{
return `${this.httpServerHelper.getWebsocketUrl()}/notifierServer/getwebsocket/${sessionID}`;
}
}