From bf84f7814f919c2e904d754fde97d4c6d0a0dbff Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Sat, 21 Mar 2020 16:36:46 +0100 Subject: [PATCH] Can cancel the response to a survey --- src/controllers/Routes.ts | 2 ++ src/controllers/SurveyController.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index add1e22..a7ba4c9 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -225,6 +225,8 @@ export const Routes : Route[] = [ // Surveys controller {path: "/surveys/send_response", cb: (h) => SurveyController.SendResponse(h)}, + {path: "/surveys/cancel_response", cb: (h) => SurveyController.CancelResponse(h)}, + // Notifications controller {path: "/notifications/count_unread", cb: (h) => NotificationsController.CountUnread(h)}, diff --git a/src/controllers/SurveyController.ts b/src/controllers/SurveyController.ts index 26659d5..3fcbaa8 100644 --- a/src/controllers/SurveyController.ts +++ b/src/controllers/SurveyController.ts @@ -29,6 +29,19 @@ export class SurveyController { h.success(); } + /** + * Cancel the repsonse to a request + * + * @param h Request handler + */ + public static async CancelResponse(h: RequestHandler) { + const surveyID = await this.PostSurveyIDFromPostID(h, "postID"); + + await SurveyHelper.CancelResponse(h.getUserId(), surveyID); + + h.success(); + } + /** * Turn a survey into an API entry