dialogs-profiles-refresh (!320)

This PR updates a few interfaces and consequently a few functions returned data,

it also handles 2 new routes:
`/client/friend/request/decline`
`/client/friend/request/accept-all`

Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/320
Co-authored-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-committed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
This commit is contained in:
TheSparta 2024-05-03 22:54:48 +00:00 committed by chomp
parent 99444c7237
commit d2e1624618
7 changed files with 63 additions and 7 deletions

View File

@ -6,6 +6,7 @@ import { IEmptyRequestData } from "@spt-aki/models/eft/common/IEmptyRequestData"
import {
IAcceptFriendRequestData,
ICancelFriendRequestData,
IDeclineFriendRequestData,
} from "@spt-aki/models/eft/dialog/IAcceptFriendRequestData";
import { IChatServer } from "@spt-aki/models/eft/dialog/IChatServer";
import { IClearMailMessageRequest } from "@spt-aki/models/eft/dialog/IClearMailMessageRequest";
@ -186,7 +187,16 @@ export class DialogueCallbacks implements OnUpdate
sessionID: string,
): IGetBodyResponseData<IFriendRequestSendResponse>
{
return this.httpResponse.getBody({ status: 0, requestid: "12345", retryAfter: 600 });
return this.httpResponse.getBody({ status: 0, requestId: "12345", retryAfter: 600 });
}
/**
* Handle client/friend/request/accept-all
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public acceptAllFriendRequests(url: string, request: IEmptyRequestData, sessionID: string): INullResponseData
{
return this.httpResponse.nullResponse();
}
/**
@ -202,6 +212,19 @@ export class DialogueCallbacks implements OnUpdate
return this.httpResponse.getBody(true);
}
/**
* Handle client/friend/request/decline
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
public declineFriendRequest(
url: string,
request: IDeclineFriendRequestData,
sessionID: string,
): IGetBodyResponseData<boolean>
{
return this.httpResponse.getBody(true);
}
/**
* Handle client/friend/request/cancel
*/

View File

@ -394,7 +394,19 @@ export class ProfileController
*/
public getFriends(info: ISearchFriendRequestData, sessionID: string): ISearchFriendResponse[]
{
return [{ _id: this.hashUtil.generate(), Info: { Level: 1, Side: "Bear", Nickname: info.nickname } }];
const profile = this.saveServer.getProfile(sessionID);
// return some of the current player info for now
return [{
_id: profile.characters.pmc._id,
aid: profile.characters.pmc.aid,
Info: {
Nickname: info.nickname,
Side: "Bear",
Level: 1,
MemberCategory: profile.characters.pmc.Info.MemberCategory,
},
}];
}
/**
@ -422,6 +434,7 @@ export class ProfileController
{
const player = this.profileHelper.getFullProfile(sessionId);
const playerPmc = player.characters.pmc;
const playerScav = player.characters.scav;
// return player for now
return {
@ -458,8 +471,8 @@ export class ProfileController
},
scavStats: {
eft: {
totalInGameTime: player.characters.scav.Stats.Eft.TotalInGameTime,
overAllCounters: player.characters.scav.Stats.Eft.OverallCounters,
totalInGameTime: playerScav.Stats.Eft.TotalInGameTime,
overAllCounters: playerScav.Stats.Eft.OverallCounters,
},
},
};

View File

@ -6,7 +6,11 @@ export interface ICancelFriendRequestData extends IBaseFriendRequest
{
}
export interface IDeclineFriendRequestData extends IBaseFriendRequest
{
}
export interface IBaseFriendRequest
{
request_id: string;
profileId: string;
}

View File

@ -1,6 +1,6 @@
export interface IFriendRequestSendResponse
{
status: number;
requestid: string;
requestId: string;
retryAfter: number;
}

View File

@ -1,5 +1,5 @@
import { OverallCounters, Skills } from "@spt-aki/models/eft/common/tables/IBotBase";
import { Item } from "../common/tables/IItem";
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
export interface IGetOtherProfileResponse
{

View File

@ -1,6 +1,7 @@
export interface ISearchFriendResponse
{
_id: string;
aid: number;
Info: Info;
}
@ -9,4 +10,5 @@ export interface Info
Nickname: string;
Side: string;
Level: number;
MemberCategory: number;
}

View File

@ -115,6 +115,13 @@ export class DialogStaticRouter extends StaticRouter
return this.dialogueCallbacks.sendFriendRequest(url, info, sessionID);
},
),
new RouteAction(
"/client/friend/request/accept-all",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dialogueCallbacks.acceptAllFriendRequests(url, info, sessionID);
},
),
new RouteAction(
"/client/friend/request/accept",
(url: string, info: any, sessionID: string, output: string): any =>
@ -122,6 +129,13 @@ export class DialogStaticRouter extends StaticRouter
return this.dialogueCallbacks.acceptFriendRequest(url, info, sessionID);
},
),
new RouteAction(
"/client/friend/request/decline",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.dialogueCallbacks.declineFriendRequest(url, info, sessionID);
},
),
new RouteAction(
"/client/friend/request/cancel",
(url: string, info: any, sessionID: string, output: string): any =>