From a19456994664fe9c892ce7076314ecbf9d9a10cf Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 30 Dec 2023 16:41:20 +0000 Subject: [PATCH] Basic implementation for viewing other profiles --- project/src/callbacks/ProfileCallbacks.ts | 8 ++++--- project/src/controllers/ProfileController.ts | 22 +++++++++++++++++++ .../eft/profile/IGetOtherProfileRequest.ts | 4 ++++ .../eft/profile/IGetOtherProfileResponse.ts | 17 ++++++++++++++ 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 project/src/models/eft/profile/IGetOtherProfileRequest.ts create mode 100644 project/src/models/eft/profile/IGetOtherProfileResponse.ts diff --git a/project/src/callbacks/ProfileCallbacks.ts b/project/src/callbacks/ProfileCallbacks.ts index 3da09fd0..86137b16 100644 --- a/project/src/callbacks/ProfileCallbacks.ts +++ b/project/src/callbacks/ProfileCallbacks.ts @@ -8,6 +8,8 @@ import { INullResponseData } from "@spt-aki/models/eft/httpResponse/INullRespons import { IGetMiniProfileRequestData } from "@spt-aki/models/eft/launcher/IGetMiniProfileRequestData"; import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData"; import { ICreateProfileResponse } from "@spt-aki/models/eft/profile/ICreateProfileResponse"; +import { IGetOtherProfileRequest } from "@spt-aki/models/eft/profile/IGetOtherProfileRequest"; +import { IGetOtherProfileResponse } from "@spt-aki/models/eft/profile/IGetOtherProfileResponse"; 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"; @@ -147,11 +149,11 @@ export class ProfileCallbacks */ public getOtherProfile( url: string, - info: IEmptyRequestData, + request: IGetOtherProfileRequest, sessionID: string, - ): any + ): IGetBodyResponseData { - throw new Error("Not implemented"); + return this.httpResponse.getBody(this.profileController.getOtherProfile(sessionID, request)); } /** diff --git a/project/src/controllers/ProfileController.ts b/project/src/controllers/ProfileController.ts index 36239b86..90322482 100644 --- a/project/src/controllers/ProfileController.ts +++ b/project/src/controllers/ProfileController.ts @@ -13,6 +13,8 @@ import { IMiniProfile } from "@spt-aki/models/eft/launcher/IMiniProfile"; import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData"; import { IAkiProfile, Inraid, Vitality } from "@spt-aki/models/eft/profile/IAkiProfile"; import { ICompletedAchievementsResponse } from "@spt-aki/models/eft/profile/ICompletedAchievementsResponse"; +import { IGetOtherProfileRequest } from "@spt-aki/models/eft/profile/IGetOtherProfileRequest"; +import { IGetOtherProfileResponse } from "@spt-aki/models/eft/profile/IGetOtherProfileResponse"; 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"; @@ -394,4 +396,24 @@ export class ProfileController return {elements: profile.achievements}; } + + public getOtherProfile(sessionId: string, request: IGetOtherProfileRequest): IGetOtherProfileResponse + { + const player = this.profileHelper.getFullProfile(sessionId); + const playerPmc = player.characters.pmc; + + // return player for now + return { + id: playerPmc._id, + aid: playerPmc.aid, + info: playerPmc.Info, + customization: playerPmc.Customization, + skills: playerPmc.Skills, + equipment: playerPmc.Inventory, + achievements: playerPmc.Achievements, + favoriteItems: playerPmc.Inventory.favoriteItems, + pmcStats: playerPmc.Stats, + scavStats: player.characters.scav.Stats + }; + } } diff --git a/project/src/models/eft/profile/IGetOtherProfileRequest.ts b/project/src/models/eft/profile/IGetOtherProfileRequest.ts new file mode 100644 index 00000000..28f098cc --- /dev/null +++ b/project/src/models/eft/profile/IGetOtherProfileRequest.ts @@ -0,0 +1,4 @@ +export interface IGetOtherProfileRequest +{ + accountId: string; +} \ No newline at end of file diff --git a/project/src/models/eft/profile/IGetOtherProfileResponse.ts b/project/src/models/eft/profile/IGetOtherProfileResponse.ts new file mode 100644 index 00000000..ba603b44 --- /dev/null +++ b/project/src/models/eft/profile/IGetOtherProfileResponse.ts @@ -0,0 +1,17 @@ + +import { Customization, Inventory, Skills, Stats } from "@spt-aki/models/eft/common/tables/IBotBase" +import { Info } from "types/models/eft/common/tables/IBotBase" + +export interface IGetOtherProfileResponse +{ + id: string + aid: number + info: Info + customization: Customization + skills: Skills + equipment: Inventory + achievements: Record + favoriteItems: string[] + pmcStats: Stats + scavStats: Stats +} \ No newline at end of file