From 4d5beef79e1315baf7117ad532b456a4d8167aff Mon Sep 17 00:00:00 2001 From: AntoniaBK Date: Wed, 27 Mar 2024 10:29:52 +0100 Subject: [PATCH] Made send_email available from the API --- website/web/genericapi.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/website/web/genericapi.py b/website/web/genericapi.py index 0e1a29f7..144778ea 100644 --- a/website/web/genericapi.py +++ b/website/web/genericapi.py @@ -380,7 +380,19 @@ class CaptureCookies(Resource): # type: ignore[misc] def get(self, capture_uuid: str) -> dict[str, Any]: return json.loads(lookyloo.get_cookies(capture_uuid).read()) - +@api.route('/json//report') +@api.doc(description='Reports the url by sending an email to the investigation team', + params={'capture_uuid': 'The UUID of the capture'}) +class CaptureReport(Resource): # type: ignore[misc] + @api.param('email', 'Email of the reporter, used by the analyst to get in touch.') # type: ignore[misc] + @api.param('comment', 'Description of the URL, will be given to the analyst.') # type: ignore[misc] + def post(self, capture_uuid) -> str: + parameters: dict[str, Any] = request.get_json(force=True) + answer = lookyloo.send_mail(capture_uuid, parameters.get('email'), parameters.get('comment')) + if answer is None: + return "Successfully sent an email to the investigation" + else: + return "Error: " + str(answer) # Just text auto_report_model = api.model('AutoReportModel', {