diff --git a/pyproject.toml b/pyproject.toml index 6395eabf..7cf4f34f 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] 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)