From 334802ba05e305c109b67067e0822d7a2e345380 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 18 May 2020 19:04:50 +0200 Subject: [PATCH] Can get information about a single survey --- src/controllers/Routes.ts | 2 ++ src/controllers/SurveyController.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 388f3a3..10e4540 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -276,6 +276,8 @@ export const Routes : Route[] = [ // Surveys controller + {path: "/surveys/get_info", cb: (h) => SurveyController.GetInfoSingle(h)}, + {path: "/surveys/send_response", cb: (h) => SurveyController.SendResponse(h)}, {path: "/surveys/cancel_response", cb: (h) => SurveyController.CancelResponse(h)}, diff --git a/src/controllers/SurveyController.ts b/src/controllers/SurveyController.ts index f1742d2..bbb5103 100644 --- a/src/controllers/SurveyController.ts +++ b/src/controllers/SurveyController.ts @@ -12,6 +12,18 @@ import { PostAccessLevel } from "../entities/Post"; export class SurveyController { + /** + * Get information about a single survey + * + * @param h Request handler + */ + public static async GetInfoSingle(h: RequestHandler) { + const surveyID = await this.PostSurveyIDFromPostID(h, "postID"); + const survey = await SurveyHelper.GetInfoBySurveyID(surveyID); + + h.send(await this.SurveyToAPI(h, survey)); + } + /** * Send the response to a survey to the server *