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