2023-03-03 16:23:46 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
|
2023-10-19 19:21:17 +02:00
|
|
|
import { DialogueController } from "@spt-aki/controllers/DialogueController";
|
|
|
|
import { OnUpdate } from "@spt-aki/di/OnUpdate";
|
|
|
|
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
2023-11-16 22:42:06 +01:00
|
|
|
import {
|
|
|
|
IAcceptFriendRequestData,
|
|
|
|
ICancelFriendRequestData,
|
|
|
|
} from "@spt-aki/models/eft/dialog/IAcceptFriendRequestData";
|
2023-10-19 19:21:17 +02:00
|
|
|
import { IChatServer } from "@spt-aki/models/eft/dialog/IChatServer";
|
|
|
|
import { IClearMailMessageRequest } from "@spt-aki/models/eft/dialog/IClearMailMessageRequest";
|
|
|
|
import { IDeleteFriendRequest } from "@spt-aki/models/eft/dialog/IDeleteFriendRequest";
|
|
|
|
import { IFriendRequestData } from "@spt-aki/models/eft/dialog/IFriendRequestData";
|
|
|
|
import { IFriendRequestSendResponse } from "@spt-aki/models/eft/dialog/IFriendRequestSendResponse";
|
|
|
|
import { IGetAllAttachmentsRequestData } from "@spt-aki/models/eft/dialog/IGetAllAttachmentsRequestData";
|
|
|
|
import { IGetAllAttachmentsResponse } from "@spt-aki/models/eft/dialog/IGetAllAttachmentsResponse";
|
|
|
|
import { IGetChatServerListRequestData } from "@spt-aki/models/eft/dialog/IGetChatServerListRequestData";
|
|
|
|
import { IGetFriendListDataResponse } from "@spt-aki/models/eft/dialog/IGetFriendListDataResponse";
|
|
|
|
import { IGetMailDialogInfoRequestData } from "@spt-aki/models/eft/dialog/IGetMailDialogInfoRequestData";
|
|
|
|
import { IGetMailDialogListRequestData } from "@spt-aki/models/eft/dialog/IGetMailDialogListRequestData";
|
|
|
|
import { IGetMailDialogViewRequestData } from "@spt-aki/models/eft/dialog/IGetMailDialogViewRequestData";
|
|
|
|
import { IGetMailDialogViewResponseData } from "@spt-aki/models/eft/dialog/IGetMailDialogViewResponseData";
|
|
|
|
import { IPinDialogRequestData } from "@spt-aki/models/eft/dialog/IPinDialogRequestData";
|
|
|
|
import { IRemoveDialogRequestData } from "@spt-aki/models/eft/dialog/IRemoveDialogRequestData";
|
|
|
|
import { IRemoveMailMessageRequest } from "@spt-aki/models/eft/dialog/IRemoveMailMessageRequest";
|
|
|
|
import { ISendMessageRequest } from "@spt-aki/models/eft/dialog/ISendMessageRequest";
|
|
|
|
import { ISetDialogReadRequestData } from "@spt-aki/models/eft/dialog/ISetDialogReadRequestData";
|
|
|
|
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
|
|
|
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
|
|
|
|
import { DialogueInfo } from "@spt-aki/models/eft/profile/IAkiProfile";
|
|
|
|
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
|
|
|
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
|
|
|
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
@injectable()
|
|
|
|
export class DialogueCallbacks implements OnUpdate
|
|
|
|
{
|
|
|
|
constructor(
|
|
|
|
@inject("HashUtil") protected hashUtil: HashUtil,
|
|
|
|
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
|
|
|
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
|
2023-11-16 22:42:06 +01:00
|
|
|
@inject("DialogueController") protected dialogueController: DialogueController,
|
2023-03-03 16:23:46 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/friend/list
|
2023-03-03 16:23:46 +01:00
|
|
|
* @returns IGetFriendListDataResponse
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public getFriendList(
|
|
|
|
url: string,
|
|
|
|
info: IEmptyRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IGetFriendListDataResponse>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.dialogueController.getFriendList(sessionID));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/chatServer/list
|
|
|
|
* @returns IChatServer[]
|
2023-03-03 16:23:46 +01:00
|
|
|
*/
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-11-16 22:42:06 +01:00
|
|
|
public getChatServerList(
|
|
|
|
url: string,
|
|
|
|
info: IGetChatServerListRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IChatServer[]>
|
|
|
|
{
|
|
|
|
const chatServer: IChatServer = {
|
|
|
|
_id: this.hashUtil.generate(),
|
|
|
|
RegistrationId: 20,
|
|
|
|
DateTime: this.timeUtil.getTimestamp(),
|
|
|
|
IsDeveloper: true,
|
|
|
|
Regions: ["EUR"],
|
|
|
|
VersionId: "bgkidft87ddd",
|
|
|
|
Ip: "",
|
|
|
|
Port: 0,
|
|
|
|
Chats: [{ _id: "0", Members: 0 }],
|
|
|
|
};
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
return this.httpResponse.getBody([chatServer]);
|
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
/** Handle client/mail/dialog/list */
|
2023-11-16 22:42:06 +01:00
|
|
|
public getMailDialogList(
|
|
|
|
url: string,
|
|
|
|
info: IGetMailDialogListRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<DialogueInfo[]>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.dialogueController.generateDialogueList(sessionID));
|
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
/** Handle client/mail/dialog/view */
|
2023-11-16 22:42:06 +01:00
|
|
|
public getMailDialogView(
|
|
|
|
url: string,
|
|
|
|
info: IGetMailDialogViewRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IGetMailDialogViewResponseData>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
2023-07-15 16:01:23 +02:00
|
|
|
return this.httpResponse.getBody(this.dialogueController.generateDialogueView(info, sessionID));
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
/** Handle client/mail/dialog/info */
|
2023-11-16 22:42:06 +01:00
|
|
|
public getMailDialogInfo(
|
|
|
|
url: string,
|
|
|
|
info: IGetMailDialogInfoRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<DialogueInfo>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.dialogueController.getDialogueInfo(info.dialogId, sessionID));
|
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
/** Handle client/mail/dialog/remove */
|
2023-03-03 16:23:46 +01:00
|
|
|
public removeDialog(url: string, info: IRemoveDialogRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
this.dialogueController.removeDialogue(info.dialogId, sessionID);
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/** Handle client/mail/dialog/pin */
|
2023-03-03 16:23:46 +01:00
|
|
|
public pinDialog(url: string, info: IPinDialogRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
this.dialogueController.setDialoguePin(info.dialogId, true, sessionID);
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/** Handle client/mail/dialog/unpin */
|
2023-03-03 16:23:46 +01:00
|
|
|
public unpinDialog(url: string, info: IPinDialogRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
this.dialogueController.setDialoguePin(info.dialogId, false, sessionID);
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/** Handle client/mail/dialog/read */
|
2023-03-03 16:23:46 +01:00
|
|
|
public setRead(url: string, info: ISetDialogReadRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
this.dialogueController.setRead(info.dialogs, sessionID);
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/mail/dialog/getAllAttachments
|
2023-03-03 16:23:46 +01:00
|
|
|
* @returns IGetAllAttachmentsResponse
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public getAllAttachments(
|
|
|
|
url: string,
|
|
|
|
info: IGetAllAttachmentsRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IGetAllAttachmentsResponse>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.dialogueController.getAllAttachments(info.dialogId, sessionID));
|
|
|
|
}
|
|
|
|
|
2023-07-15 16:01:23 +02:00
|
|
|
/** Handle client/mail/msg/send */
|
|
|
|
public sendMessage(url: string, request: ISendMessageRequest, sessionID: string): IGetBodyResponseData<string>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.dialogueController.sendMessage(sessionID, request));
|
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
/** Handle client/friend/request/list/outbox */
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public listOutbox(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody([]);
|
|
|
|
}
|
|
|
|
|
2023-07-14 14:03:55 +02:00
|
|
|
/**
|
|
|
|
* Handle client/friend/request/list/inbox
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public listInbox(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody([]);
|
|
|
|
}
|
|
|
|
|
2023-07-14 14:03:55 +02:00
|
|
|
/**
|
|
|
|
* Handle client/friend/request/send
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-11-16 22:42:06 +01:00
|
|
|
public sendFriendRequest(
|
|
|
|
url: string,
|
|
|
|
request: IFriendRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<IFriendRequestSendResponse>
|
2023-03-07 23:25:23 +01:00
|
|
|
{
|
2023-11-16 22:42:06 +01:00
|
|
|
return this.httpResponse.getBody({ status: 0, requestid: "12345", retryAfter: 600 });
|
2023-03-07 23:25:23 +01:00
|
|
|
}
|
|
|
|
|
2023-07-14 14:03:55 +02:00
|
|
|
/**
|
|
|
|
* Handle client/friend/request/accept
|
|
|
|
*/
|
2023-05-20 19:37:39 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-11-16 22:42:06 +01:00
|
|
|
public acceptFriendRequest(
|
|
|
|
url: string,
|
|
|
|
request: IAcceptFriendRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<boolean>
|
2023-05-20 19:37:39 +02:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(true);
|
|
|
|
}
|
|
|
|
|
2023-07-14 14:03:55 +02:00
|
|
|
/**
|
|
|
|
* Handle client/friend/request/cancel
|
|
|
|
*/
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-11-16 22:42:06 +01:00
|
|
|
public cancelFriendRequest(
|
|
|
|
url: string,
|
|
|
|
request: ICancelFriendRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<boolean>
|
2023-07-14 14:03:55 +02:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(true);
|
|
|
|
}
|
|
|
|
|
2023-07-15 15:49:25 +02:00
|
|
|
/** Handle client/friend/delete */
|
2023-03-07 23:25:23 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public deleteFriend(url: string, request: IDeleteFriendRequest, sessionID: string): INullResponseData
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.nullResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-15 15:49:25 +02:00
|
|
|
/** Handle client/friend/ignore/set */
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-12-20 01:27:27 +01:00
|
|
|
public ignoreFriend(url: string, request: { uid: string; }, sessionID: string): INullResponseData
|
2023-07-15 16:01:23 +02:00
|
|
|
{
|
|
|
|
return this.httpResponse.nullResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-20 15:02:53 +02:00
|
|
|
/** Handle client/friend/ignore/remove */
|
2023-07-15 16:01:23 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-12-20 01:27:27 +01:00
|
|
|
public unIgnoreFriend(url: string, request: { uid: string; }, sessionID: string): INullResponseData
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
2023-07-15 16:01:23 +02:00
|
|
|
return this.httpResponse.nullResponse();
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
2023-03-07 23:25:23 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public clearMail(url: string, request: IClearMailMessageRequest, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public removeMail(url: string, request: IRemoveMailMessageRequest, sessionID: string): IGetBodyResponseData<any[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.emptyArrayResponse();
|
|
|
|
}
|
|
|
|
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public async onUpdate(timeSinceLastRun: number): Promise<boolean>
|
|
|
|
{
|
|
|
|
this.dialogueController.update();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public getRoute(): string
|
|
|
|
{
|
|
|
|
return "aki-dialogue";
|
|
|
|
}
|
|
|
|
}
|