From eafa390c7245675a7b90eb4891cc3b6a0b857741 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 18 Nov 2024 10:13:47 +0000 Subject: [PATCH] Fixed survey not implemented errors --- project/assets/configs/core.json | 141 ++++++++++++++++++ project/src/callbacks/GameCallbacks.ts | 24 ++- project/src/controllers/GameController.ts | 5 + .../eft/game/ISendSurveyOpinionRequest.ts | 10 ++ .../models/eft/game/ISurveyResponseData.ts | 40 +++++ project/src/models/spt/config/ICoreConfig.ts | 2 + .../src/routers/static/GameStaticRouter.ts | 20 ++- 7 files changed, 240 insertions(+), 2 deletions(-) create mode 100644 project/src/models/eft/game/ISendSurveyOpinionRequest.ts create mode 100644 project/src/models/eft/game/ISurveyResponseData.ts diff --git a/project/assets/configs/core.json b/project/assets/configs/core.json index 342cf484..0a53ef3c 100644 --- a/project/assets/configs/core.json +++ b/project/assets/configs/core.json @@ -17,6 +17,147 @@ "fixShotgunDispersion": true, "removeModItemsFromProfile": false, "fixProfileBreakingInventoryItemIssues": false + }, + "survey": { + "locale": { + "en": { + "question_1": "How off-topic is general chat on the SPT discord?", + "question_1_answer_1": "Not at all", + "question_1_answer_2": "A little", + "question_1_answer_3": "Sometimes", + "question_1_answer_4": "Somewhat often", + "question_1_answer_5": "Quite often", + "question_1_answer_6": "Most of the time", + "question_1_answer_7": "Almost always", + "question_1_answer_8": "Always", + "question_1_answer_9": "NOT OFF TOPIC ENOUGH", + "question_1_answer_10": "I LIVE TO MAKE GENERAL CHAT OFF TOPIC", + "question_1_answer_11": "I am posting gifs to general chat as we speak", + "question_2": "When you download a mod from the hub do you read the readme/mod description?", + "question_2_answer_1": "What's a description", + "question_2_answer_2": "I can't read", + "question_2_answer_3": "I am illiterate", + "question_2_answer_4": "I am too busy making general chat off-topic to read", + "question_2_answer_5": "YOU WILL NEVER MAKE ME READ TEXT I WILL ASK IN GENERAL CHAT INSTEAD", + "title": "Feedback survey", + "time": "About 1 minute", + "description": "This is the first SPT survey! Your survey doesn't get sent anywhere, its just for modders to see how it works and maybe make use of.", + "farewell": "I told you at the start the survey doesn't get sent anywhere and yet you still completed it, curious." + } + }, + "survey": { + "id": 1, + "welcomePageData": { + "titleLocaleKey": "title", + "timeLocaleKey": "time", + "descriptionLocaleKey": "description" + }, + "farewellPageData": { + "textLocaleKey": "farewell" + }, + "pages": [[0, 1]], + "questions": [{ + "id": 0, + "sortIndex": 1, + "titleLocaleKey": "question_1", + "hintLocaleKey": "", + "answerLimit": 10, + "answerType": "MultiOption", + "answers": [{ + "id": 0, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_1" + }, { + "id": 1, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_2" + }, { + "id": 2, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_3" + }, { + "id": 3, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_4" + }, { + "id": 4, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_5" + }, { + "id": 5, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_6" + }, { + "id": 6, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_7" + }, { + "id": 7, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_8" + }, { + "id": 8, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_9" + }, { + "id": 9, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_10" + }, { + "id": 10, + "questionId": 0, + "sortIndex": 1, + "localeKey": "question_1_answer_11" + } + ] + }, { + "id": 1, + "sortIndex": 1, + "titleLocaleKey": "question_2", + "hintLocaleKey": "", + "answerLimit": 5, + "answerType": "SingleOption", + "answers": [{ + "id": 0, + "questionId": 1, + "sortIndex": 1, + "localeKey": "question_2_answer_1" + }, { + "id": 1, + "questionId": 1, + "sortIndex": 1, + "localeKey": "question_2_answer_2" + }, { + "id": 2, + "questionId": 1, + "sortIndex": 1, + "localeKey": "question_2_answer_3" + }, { + "id": 3, + "questionId": 1, + "sortIndex": 1, + "localeKey": "question_2_answer_4" + }, { + "id": 4, + "questionId": 1, + "sortIndex": 1, + "localeKey": "question_2_answer_5" + } + ] + } + ], + "isNew": false + } }, "features": { "autoInstallModDependencies": false, diff --git a/project/src/callbacks/GameCallbacks.ts b/project/src/callbacks/GameCallbacks.ts index 6b898862..3f27b17b 100644 --- a/project/src/callbacks/GameCallbacks.ts +++ b/project/src/callbacks/GameCallbacks.ts @@ -13,7 +13,9 @@ import { IGameModeResponse } from "@spt/models/eft/game/IGameModeResponse"; import { IGameStartResponse } from "@spt/models/eft/game/IGameStartResponse"; import { IGetRaidTimeRequest } from "@spt/models/eft/game/IGetRaidTimeRequest"; import { IGetRaidTimeResponse } from "@spt/models/eft/game/IGetRaidTimeResponse"; +import { ISendSurveyOpinionRequest } from "@spt/models/eft/game/ISendSurveyOpinionRequest"; import { IServerDetails } from "@spt/models/eft/game/IServerDetails"; +import { ISurveyResponseData } from "@spt/models/eft/game/ISurveyResponseData"; import { IVersionValidateRequestData } from "@spt/models/eft/game/IVersionValidateRequestData"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData"; @@ -169,7 +171,27 @@ export class GameCallbacks implements OnLoad { * Handle /client/survey * @returns INullResponseData */ - public getSurvey(url: string, request: IEmptyRequestData, sessionID: string): INullResponseData { + public getSurvey( + url: string, + request: IEmptyRequestData, + sessionId: string, + ): INullResponseData | IGetBodyResponseData { + return this.httpResponse.getBody(this.gameController.getSurvey(sessionId)); + } + + /** + * Handle client/survey/view + * @returns INullResponseData + */ + public getSurveyView(url: string, request: any, sessionId: string): INullResponseData { + return this.httpResponse.nullResponse(); + } + + /** + * Handle client/survey/opinion + * @returns INullResponseData + */ + public sendSurveyOpinion(url: string, request: ISendSurveyOpinionRequest, sessionId: string): INullResponseData { return this.httpResponse.nullResponse(); } } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index be08ef44..1a47975c 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -17,6 +17,7 @@ import { ESessionMode } from "@spt/models/eft/game/IGameModeResponse"; import { IGetRaidTimeRequest } from "@spt/models/eft/game/IGetRaidTimeRequest"; import { IGetRaidTimeResponse } from "@spt/models/eft/game/IGetRaidTimeResponse"; import { IServerDetails } from "@spt/models/eft/game/IServerDetails"; +import { ISurveyResponseData } from "@spt/models/eft/game/ISurveyResponseData"; import { ISptProfile } from "@spt/models/eft/profile/ISptProfile"; import { BonusType } from "@spt/models/enums/BonusType"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; @@ -549,4 +550,8 @@ export class GameController { this.logger.debug(`Debug enabled: ${globalThis.G_DEBUG_CONFIGURATION}`); this.logger.debug(`Mods enabled: ${globalThis.G_MODS_ENABLED}`); } + + public getSurvey(sessionId: string): ISurveyResponseData { + return this.coreConfig.survey; + } } diff --git a/project/src/models/eft/game/ISendSurveyOpinionRequest.ts b/project/src/models/eft/game/ISendSurveyOpinionRequest.ts new file mode 100644 index 00000000..9a989de6 --- /dev/null +++ b/project/src/models/eft/game/ISendSurveyOpinionRequest.ts @@ -0,0 +1,10 @@ +export interface ISendSurveyOpinionRequest { + surveyId: number; + answers: ISurveyOpinionAnswer[]; +} + +export interface ISurveyOpinionAnswer { + questionId: number; + answerType: string; + answers: any; +} diff --git a/project/src/models/eft/game/ISurveyResponseData.ts b/project/src/models/eft/game/ISurveyResponseData.ts new file mode 100644 index 00000000..f0edba9e --- /dev/null +++ b/project/src/models/eft/game/ISurveyResponseData.ts @@ -0,0 +1,40 @@ +export interface ISurveyResponseData { + locale: Record>; + survey: ISurvey; +} + +export interface ISurvey { + id: number; + welcomePageData: IWelcomePageData; + farewellPageData: IFarewellPageData; + pages: number[][]; + questions: ISurveyQuestion[]; + isNew: boolean; +} + +export interface IWelcomePageData { + titleLocaleKey: string; + timeLocaleKey: string; + descriptionLocaleKey: string; +} + +export interface IFarewellPageData { + textLocaleKey: string; +} + +export interface ISurveyQuestion { + id: number; + sortIndex: number; + titleLocaleKey: string; + hintLocaleKey: string; + answerLimit: number; + answerType: string; + answers: ISurveyAnswer[]; +} + +export interface ISurveyAnswer { + id: number; + questionId: number; + sortIndex: number; + localeKey: string; +} diff --git a/project/src/models/spt/config/ICoreConfig.ts b/project/src/models/spt/config/ICoreConfig.ts index 0fdc727a..6475a278 100644 --- a/project/src/models/spt/config/ICoreConfig.ts +++ b/project/src/models/spt/config/ICoreConfig.ts @@ -1,3 +1,4 @@ +import { ISurveyResponseData } from "@spt/models/eft/game/ISurveyResponseData"; import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig"; export interface ICoreConfig extends IBaseConfig { @@ -12,6 +13,7 @@ export interface ICoreConfig extends IBaseConfig { bsgLogging: IBsgLogging; release: IRelease; fixes: IGameFixes; + survey: ISurveyResponseData; features: IServerFeatures; /** Commit hash build server was created from */ commit?: string; diff --git a/project/src/routers/static/GameStaticRouter.ts b/project/src/routers/static/GameStaticRouter.ts index 9facd699..39757275 100644 --- a/project/src/routers/static/GameStaticRouter.ts +++ b/project/src/routers/static/GameStaticRouter.ts @@ -10,6 +10,7 @@ import { IGameStartResponse } from "@spt/models/eft/game/IGameStartResponse"; import { IGetRaidTimeResponse } from "@spt/models/eft/game/IGetRaidTimeResponse"; import { ISendReportRequest } from "@spt/models/eft/game/ISendReportRequest"; import { IServerDetails } from "@spt/models/eft/game/IServerDetails"; +import { ISurveyResponseData } from "@spt/models/eft/game/ISurveyResponseData"; import { IGetBodyResponseData } from "@spt/models/eft/httpResponse/IGetBodyResponseData"; import { INullResponseData } from "@spt/models/eft/httpResponse/INullResponseData"; import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil"; @@ -147,10 +148,27 @@ export class GameStaticRouter extends StaticRouter { ), new RouteAction( "/client/survey", - async (url: string, info: any, sessionID: string, output: string): Promise => { + async ( + url: string, + info: any, + sessionID: string, + output: string, + ): Promise> => { return this.gameCallbacks.getSurvey(url, info, sessionID); }, ), + new RouteAction( + "/client/survey/view", + async (url: string, info: any, sessionID: string, output: string): Promise => { + return this.gameCallbacks.getSurveyView(url, info, sessionID); + }, + ), + new RouteAction( + "/client/survey/opinion", + async (url: string, info: any, sessionID: string, output: string): Promise => { + return this.gameCallbacks.sendSurveyOpinion(url, info, sessionID); + }, + ), ]); } }