Skip to content
Snippets Groups Projects
Commit f95325e2 authored by Erik Johnston's avatar Erik Johnston
Browse files

Port synaps/rest/client/server_notice_servlet.py to async/await

parent 281f8870
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
import re import re
from twisted.internet import defer
from synapse.api.constants import EventTypes from synapse.api.constants import EventTypes
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError
from synapse.http.servlet import ( from synapse.http.servlet import (
...@@ -69,9 +67,8 @@ class SendServerNoticeServlet(RestServlet): ...@@ -69,9 +67,8 @@ class SendServerNoticeServlet(RestServlet):
self.__class__.__name__, self.__class__.__name__,
) )
@defer.inlineCallbacks async def on_POST(self, request, txn_id=None):
def on_POST(self, request, txn_id=None): await assert_requester_is_admin(self.auth, request)
yield assert_requester_is_admin(self.auth, request)
body = parse_json_object_from_request(request) body = parse_json_object_from_request(request)
assert_params_in_dict(body, ("user_id", "content")) assert_params_in_dict(body, ("user_id", "content"))
event_type = body.get("type", EventTypes.Message) event_type = body.get("type", EventTypes.Message)
...@@ -85,7 +82,7 @@ class SendServerNoticeServlet(RestServlet): ...@@ -85,7 +82,7 @@ class SendServerNoticeServlet(RestServlet):
if not self.hs.is_mine_id(user_id): if not self.hs.is_mine_id(user_id):
raise SynapseError(400, "Server notices can only be sent to local users") raise SynapseError(400, "Server notices can only be sent to local users")
event = yield self.snm.send_notice( event = await self.snm.send_notice(
user_id=body["user_id"], user_id=body["user_id"],
type=event_type, type=event_type,
state_key=state_key, state_key=state_key,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment