2023-03-03 16:23:46 +01:00
|
|
|
import { inject, injectable } from "tsyringe";
|
|
|
|
|
2023-10-19 19:21:17 +02:00
|
|
|
import { ProfileController } from "@spt-aki/controllers/ProfileController";
|
|
|
|
import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData";
|
|
|
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
|
|
|
import { IGetBodyResponseData } from "@spt-aki/models/eft/httpResponse/IGetBodyResponseData";
|
|
|
|
import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullResponseData";
|
|
|
|
import { IGetMiniProfileRequestData } from "@spt-aki/models/eft/launcher/IGetMiniProfileRequestData";
|
|
|
|
import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData";
|
|
|
|
import { IGetProfileSettingsRequest } from "@spt-aki/models/eft/profile/IGetProfileSettingsRequest";
|
|
|
|
import { IProfileChangeNicknameRequestData } from "@spt-aki/models/eft/profile/IProfileChangeNicknameRequestData";
|
|
|
|
import { IProfileChangeVoiceRequestData } from "@spt-aki/models/eft/profile/IProfileChangeVoiceRequestData";
|
|
|
|
import { IProfileCreateRequestData } from "@spt-aki/models/eft/profile/IProfileCreateRequestData";
|
|
|
|
import { ISearchFriendRequestData } from "@spt-aki/models/eft/profile/ISearchFriendRequestData";
|
|
|
|
import { ISearchFriendResponse } from "@spt-aki/models/eft/profile/ISearchFriendResponse";
|
|
|
|
import { IValidateNicknameRequestData } from "@spt-aki/models/eft/profile/IValidateNicknameRequestData";
|
|
|
|
import { HttpResponseUtil } from "@spt-aki/utils/HttpResponseUtil";
|
|
|
|
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
2023-03-03 16:23:46 +01:00
|
|
|
|
|
|
|
/** Handle profile related client events */
|
|
|
|
@injectable()
|
|
|
|
export class ProfileCallbacks
|
|
|
|
{
|
|
|
|
constructor(
|
|
|
|
@inject("HttpResponseUtil") protected httpResponse: HttpResponseUtil,
|
|
|
|
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
2023-11-16 22:42:06 +01:00
|
|
|
@inject("ProfileController") protected profileController: ProfileController,
|
|
|
|
)
|
|
|
|
{}
|
2023-03-03 16:23:46 +01:00
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle client/game/profile/create
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public createProfile(url: string, info: IProfileCreateRequestData, sessionID: string): IGetBodyResponseData<any>
|
|
|
|
{
|
|
|
|
this.profileController.createProfile(info, sessionID);
|
|
|
|
return this.httpResponse.getBody({ uid: `pmc${sessionID}` });
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/game/profile/list
|
2023-03-03 16:23:46 +01:00
|
|
|
* Get the complete player profile (scav + pmc character)
|
|
|
|
*/
|
|
|
|
public getProfileData(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IPmcData[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.profileController.getCompleteProfile(sessionID));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/game/profile/savage/regenerate
|
2023-03-03 16:23:46 +01:00
|
|
|
* Handle the creation of a scav profile for player
|
|
|
|
* Occurs post-raid and when profile first created immediately after character details are confirmed by player
|
2023-11-16 22:42:06 +01:00
|
|
|
* @param url
|
2023-03-03 16:23:46 +01:00
|
|
|
* @param info empty
|
|
|
|
* @param sessionID Session id
|
|
|
|
* @returns Profile object
|
|
|
|
*/
|
|
|
|
public regenerateScav(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IPmcData[]>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody([this.profileController.generatePlayerScav(sessionID)]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle client/game/profile/voice/change event
|
|
|
|
*/
|
|
|
|
public changeVoice(url: string, info: IProfileChangeVoiceRequestData, sessionID: string): INullResponseData
|
|
|
|
{
|
|
|
|
this.profileController.changeVoice(info, sessionID);
|
|
|
|
return this.httpResponse.nullResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle client/game/profile/nickname/change event
|
|
|
|
* Client allows player to adjust their profile name
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public changeNickname(
|
|
|
|
url: string,
|
|
|
|
info: IProfileChangeNicknameRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<any>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
const output = this.profileController.changeNickname(info, sessionID);
|
|
|
|
|
|
|
|
if (output === "taken")
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(null, 255, "The nickname is already in use");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (output === "tooshort")
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(null, 1, "The nickname is too short");
|
|
|
|
}
|
|
|
|
|
2023-11-16 22:42:06 +01:00
|
|
|
return this.httpResponse.getBody({ status: 0, nicknamechangedate: this.timeUtil.getTimestamp() });
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle client/game/profile/nickname/validate
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public validateNickname(
|
|
|
|
url: string,
|
|
|
|
info: IValidateNicknameRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<any>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
const output = this.profileController.validateNickname(info, sessionID);
|
|
|
|
|
|
|
|
if (output === "taken")
|
|
|
|
{
|
2023-10-10 13:03:20 +02:00
|
|
|
return this.httpResponse.getBody(null, 255, "225 - ");
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (output === "tooshort")
|
|
|
|
{
|
2023-10-10 13:03:20 +02:00
|
|
|
return this.httpResponse.getBody(null, 256, "256 - ");
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
2023-11-16 22:42:06 +01:00
|
|
|
return this.httpResponse.getBody({ status: "ok" });
|
2023-03-03 16:23:46 +01:00
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle client/game/profile/nickname/reserved
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
|
|
public getReservedNickname(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<string>
|
|
|
|
{
|
|
|
|
return this.httpResponse.getBody("SPTarkov");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-07-15 11:56:00 +02:00
|
|
|
* Handle client/profile/status
|
2023-03-03 16:23:46 +01:00
|
|
|
* Called when creating a character when choosing a character face/voice
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public getProfileStatus(
|
|
|
|
url: string,
|
|
|
|
info: IEmptyRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<GetProfileStatusResponseData>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
const response: GetProfileStatusResponseData = {
|
|
|
|
maxPveCountExceeded: false,
|
2023-11-16 22:42:06 +01:00
|
|
|
profiles: [{
|
|
|
|
profileid: `scav${sessionID}`,
|
|
|
|
profileToken: null,
|
|
|
|
status: "Free",
|
|
|
|
sid: "",
|
|
|
|
ip: "",
|
|
|
|
port: 0,
|
|
|
|
version: "live",
|
|
|
|
location: "bigmap",
|
|
|
|
raidMode: "Online",
|
|
|
|
mode: "deathmatch",
|
|
|
|
shortId: "xxx1x1",
|
|
|
|
}, { profileid: `pmc${sessionID}`, profileToken: null, status: "Free", sid: "", ip: "", port: 0 }],
|
2023-03-03 16:23:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return this.httpResponse.getBody(response);
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle client/profile/settings
|
|
|
|
*/
|
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 getProfileSettings(
|
|
|
|
url: string,
|
|
|
|
info: IGetProfileSettingsRequest,
|
|
|
|
sessionId: string,
|
|
|
|
): IGetBodyResponseData<string>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.emptyResponse();
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle client/game/profile/search
|
|
|
|
*/
|
2023-11-16 22:42:06 +01:00
|
|
|
public searchFriend(
|
|
|
|
url: string,
|
|
|
|
info: ISearchFriendRequestData,
|
|
|
|
sessionID: string,
|
|
|
|
): IGetBodyResponseData<ISearchFriendResponse[]>
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.getBody(this.profileController.getFriends(info, sessionID));
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle launcher/profile/info
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
public getMiniProfile(url: string, info: IGetMiniProfileRequestData, sessionID: string): string
|
|
|
|
{
|
|
|
|
return this.httpResponse.noBody(this.profileController.getMiniProfile(sessionID));
|
|
|
|
}
|
|
|
|
|
2023-07-15 11:56:00 +02:00
|
|
|
/**
|
|
|
|
* Handle /launcher/profiles
|
|
|
|
*/
|
2023-03-03 16:23:46 +01:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2023-07-20 14:22:47 +02:00
|
|
|
public getAllMiniProfiles(url: string, info: IEmptyRequestData, sessionID: string): string
|
2023-03-03 16:23:46 +01:00
|
|
|
{
|
|
|
|
return this.httpResponse.noBody(this.profileController.getMiniProfiles());
|
|
|
|
}
|
2023-11-16 22:42:06 +01:00
|
|
|
}
|