From f65665473016ed8bf816c37a0f31b872d210cfaf Mon Sep 17 00:00:00 2001 From: Oliver Strickson Date: Tue, 11 Jun 2024 17:46:02 +0100 Subject: [PATCH 1/2] Add POST versions of the message endpoints --- reginald/models/app.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/reginald/models/app.py b/reginald/models/app.py index b64b90c0..dd17ad5b 100644 --- a/reginald/models/app.py +++ b/reginald/models/app.py @@ -47,10 +47,19 @@ async def ping(): return "pong" # set up direct_message endpoint + # + # See the note on the below 'POST' endpoint and consider deprecating @app.get("/direct_message") async def direct_message(query: Query): - response = response_model.direct_message(query.message, query.user_id) - return response + return response_model.direct_message(query.message, query.user_id) + + # A POST direct_message endpoint, equivalent to the above. + # This provides a version of the endpoint that avoids a surprising use of + # the message body for a GET request. Provided as an additional endpoint + # instead of replacing the GET endpoint to avoid breaking things. + @app.post("/direct_message") + async def direct_message(query: Query): + return response_model.direct_message(query.message, query.user_id) # set up channel_mention endpoint @app.get("/channel_mention") @@ -58,6 +67,12 @@ async def channel_mention(query: Query): response = response_model.channel_mention(query.message, query.user_id) return response + # POST channel_mention endpoint: see comment on direct_message + @app.post("/channel_mention") + async def channel_mention(query: Query): + response = response_model.channel_mention(query.message, query.user_id) + return response + uvicorn.run(app, host="0.0.0.0", port=8000) From 57fcd1a13d27a3f1bd328f3d56e6fbb2adfaf096 Mon Sep 17 00:00:00 2001 From: rchan Date: Wed, 12 Jun 2024 10:27:52 +0100 Subject: [PATCH 2/2] add oliver to pyproject.toml --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 989e9892..ace64619 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,8 @@ authors = ["Evelina Gabasova ", "Tomas Lazauskas ", "David Beavan ", "Levan Bokeria ", - "Martin O'Reilly "] + "Martin O'Reilly ", + "Oliver Strickson "] readme = "README.md" [tool.poetry.dependencies]