From 1c601cc33eae197ea920940ebc32902b2ce664e2 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 9 Jul 2024 14:22:01 +0100 Subject: [PATCH] Removed unused endpoint + related service --- project/src/callbacks/InraidCallbacks.ts | 10 --- project/src/controllers/InraidController.ts | 12 ---- project/src/di/Container.ts | 5 -- .../routers/dynamic/InraidDynamicRouter.ts | 7 -- project/src/services/TraderServicesService.ts | 65 ------------------- 5 files changed, 99 deletions(-) delete mode 100644 project/src/services/TraderServicesService.ts diff --git a/project/src/callbacks/InraidCallbacks.ts b/project/src/callbacks/InraidCallbacks.ts index 94d48052..cc58fb6d 100644 --- a/project/src/callbacks/InraidCallbacks.ts +++ b/project/src/callbacks/InraidCallbacks.ts @@ -82,16 +82,6 @@ export class InraidCallbacks return this.httpResponse.noBody(this.inraidController.getBTRConfig()); } - /** - * Handle singleplayer/traderServices/getTraderServices - */ - public getTraderServices(url: string, info: IEmptyRequestData, sessionId: string): string - { - const lastSlashPos = url.lastIndexOf("/"); - const traderId = url.substring(lastSlashPos + 1); - return this.httpResponse.noBody(this.inraidController.getTraderServices(sessionId, traderId)); - } - public getTraitorScavHostileChance(url: string, info: IEmptyRequestData, sessionId: string): string { return this.httpResponse.noBody(this.inraidController.getTraitorScavHostileChance(url, sessionId)); diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index 8163de8f..e314b82b 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -27,7 +27,6 @@ import { IInRaidConfig } from "@spt/models/spt/config/IInRaidConfig"; import { ILocationConfig } from "@spt/models/spt/config/ILocationConfig"; import { IRagfairConfig } from "@spt/models/spt/config/IRagfairConfig"; import { ITraderConfig } from "@spt/models/spt/config/ITraderConfig"; -import { ITraderServiceModel } from "@spt/models/spt/services/ITraderServiceModel"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ConfigServer } from "@spt/servers/ConfigServer"; import { SaveServer } from "@spt/servers/SaveServer"; @@ -37,7 +36,6 @@ import { LocalisationService } from "@spt/services/LocalisationService"; import { MailSendService } from "@spt/services/MailSendService"; import { MatchBotDetailsCacheService } from "@spt/services/MatchBotDetailsCacheService"; import { PmcChatResponseService } from "@spt/services/PmcChatResponseService"; -import { TraderServicesService } from "@spt/services/TraderServicesService"; import { RandomUtil } from "@spt/utils/RandomUtil"; import { TimeUtil } from "@spt/utils/TimeUtil"; @@ -69,7 +67,6 @@ export class InraidController @inject("PlayerScavGenerator") protected playerScavGenerator: PlayerScavGenerator, @inject("HealthHelper") protected healthHelper: HealthHelper, @inject("TraderHelper") protected traderHelper: TraderHelper, - @inject("TraderServicesService") protected traderServicesService: TraderServicesService, @inject("LocalisationService") protected localisationService: LocalisationService, @inject("InsuranceService") protected insuranceService: InsuranceService, @inject("InRaidHelper") protected inRaidHelper: InRaidHelper, @@ -651,15 +648,6 @@ export class InraidController return this.btrConfig; } - /** - * Handle singleplayer/traderServices/getTraderServices - * @returns Trader services data - */ - public getTraderServices(sessionId: string, traderId: string): ITraderServiceModel[] - { - return this.traderServicesService.getTraderServices(sessionId, traderId); - } - public getTraitorScavHostileChance(url: string, sessionID: string): number { return this.inRaidConfig.playerScavHostileChancePercent; diff --git a/project/src/di/Container.ts b/project/src/di/Container.ts index ac73e894..d2653ab2 100644 --- a/project/src/di/Container.ts +++ b/project/src/di/Container.ts @@ -246,7 +246,6 @@ import { RepairService } from "@spt/services/RepairService"; import { SeasonalEventService } from "@spt/services/SeasonalEventService"; import { TraderAssortService } from "@spt/services/TraderAssortService"; import { TraderPurchasePersisterService } from "@spt/services/TraderPurchasePersisterService"; -import { TraderServicesService } from "@spt/services/TraderServicesService"; import { App } from "@spt/utils/App"; import { AsyncQueue } from "@spt/utils/AsyncQueue"; import type { ICloner } from "@spt/utils/cloners/ICloner"; @@ -709,10 +708,6 @@ export class Container depContainer.register("TraderAssortService", TraderAssortService, { lifecycle: Lifecycle.Singleton, }); - depContainer.register("TraderServicesService", TraderServicesService, { - lifecycle: Lifecycle.Singleton, - }); - depContainer.register("RagfairPriceService", RagfairPriceService, { lifecycle: Lifecycle.Singleton, }); diff --git a/project/src/routers/dynamic/InraidDynamicRouter.ts b/project/src/routers/dynamic/InraidDynamicRouter.ts index 8080c461..ef118b6f 100644 --- a/project/src/routers/dynamic/InraidDynamicRouter.ts +++ b/project/src/routers/dynamic/InraidDynamicRouter.ts @@ -16,13 +16,6 @@ export class InraidDynamicRouter extends DynamicRouter return this.inraidCallbacks.registerPlayer(url, info, sessionID); }, ), - new RouteAction( - "/singleplayer/traderServices/getTraderServices/", - async (url: string, info: any, sessionID: string, output: string): Promise => - { - return this.inraidCallbacks.getTraderServices(url, info, sessionID); - }, - ), ]); } diff --git a/project/src/services/TraderServicesService.ts b/project/src/services/TraderServicesService.ts deleted file mode 100644 index 5140ba12..00000000 --- a/project/src/services/TraderServicesService.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { inject, injectable } from "tsyringe"; -import { ProfileHelper } from "@spt/helpers/ProfileHelper"; -import { QuestStatus } from "@spt/models/enums/QuestStatus"; -import { TraderServiceType } from "@spt/models/enums/TraderServiceType"; -import { ITraderServiceModel } from "@spt/models/spt/services/ITraderServiceModel"; -import { ILogger } from "@spt/models/spt/utils/ILogger"; -import { DatabaseService } from "@spt/services/DatabaseService"; -import { ICloner } from "@spt/utils/cloners/ICloner"; - -@injectable() -export class TraderServicesService -{ - constructor( - @inject("ProfileHelper") protected profileHelper: ProfileHelper, - @inject("PrimaryLogger") protected logger: ILogger, - @inject("DatabaseService") protected databaseService: DatabaseService, - @inject("PrimaryCloner") protected cloner: ICloner, - ) - {} - - public getTraderServices(sessionId: string, traderId: string): ITraderServiceModel[] - { - const pmcData = this.profileHelper.getPmcProfile(sessionId); - let traderServices = this.cloner.clone(this.databaseService.getTrader(traderId).services); - if (!traderServices) - { - return []; - } - - // Filter out any service the user doesn't meet the conditions for - const servicesToDelete: TraderServiceType[] = []; - for (const service of traderServices) - { - if (service.requirements?.standings) - { - for (const [standingTrader, standing] of Object.entries(service.requirements.standings)) - { - if (pmcData.TradersInfo[standingTrader].standing < standing) - { - servicesToDelete.push(service.serviceType); - break; - } - } - } - - if (service.requirements?.completedQuests) - { - for (const questId of service.requirements.completedQuests) - { - const quest = pmcData.Quests.find((questStatus) => questStatus.qid === questId); - if (!quest || quest.status !== QuestStatus.Success) - { - servicesToDelete.push(service.serviceType); - break; - } - } - } - } - - // Clear any unavailable services from the list - traderServices = traderServices.filter((service) => !servicesToDelete.includes(service.serviceType)); - - return traderServices; - } -}