diff options
author | Dirk Klimpel <5740567+dklimpel@users.noreply.github.com> | 2021-11-29 23:19:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-29 22:19:45 +0000 |
commit | e8ae94a22367a81049582dfdb16c743a45ca4e8b (patch) | |
tree | 79953e11bf825844817cfdf0423d2eb09045bac4 /synapse/rest/admin/server_notice_servlet.py | |
parent | Refactor `backfilled` into specific behavior function arguments (`_persist_ev... (diff) | |
download | synapse-e8ae94a22367a81049582dfdb16c743a45ca4e8b.tar.xz |
Convert status codes to `HTTPStatus` in `synapse.rest.admin` (#11452)
Diffstat (limited to 'synapse/rest/admin/server_notice_servlet.py')
-rw-r--r-- | synapse/rest/admin/server_notice_servlet.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/synapse/rest/admin/server_notice_servlet.py b/synapse/rest/admin/server_notice_servlet.py index 19f84f33f2..b295fb078b 100644 --- a/synapse/rest/admin/server_notice_servlet.py +++ b/synapse/rest/admin/server_notice_servlet.py @@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from http import HTTPStatus from typing import TYPE_CHECKING, Awaitable, Optional, Tuple from synapse.api.constants import EventTypes @@ -82,11 +83,15 @@ class SendServerNoticeServlet(RestServlet): # but worker processes still need to initialise SendServerNoticeServlet (as it is part of the # admin api). if not self.server_notices_manager.is_enabled(): - raise SynapseError(400, "Server notices are not enabled on this server") + raise SynapseError( + HTTPStatus.BAD_REQUEST, "Server notices are not enabled on this server" + ) target_user = UserID.from_string(body["user_id"]) if not self.hs.is_mine(target_user): - raise SynapseError(400, "Server notices can only be sent to local users") + raise SynapseError( + HTTPStatus.BAD_REQUEST, "Server notices can only be sent to local users" + ) if not await self.admin_handler.get_user(target_user): raise NotFoundError("User not found") @@ -99,7 +104,7 @@ class SendServerNoticeServlet(RestServlet): txn_id=txn_id, ) - return 200, {"event_id": event.event_id} + return HTTPStatus.OK, {"event_id": event.event_id} def on_PUT( self, request: SynapseRequest, txn_id: str |