Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Do not require messages, but no-op if it is not available.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Dec 29, 2020
1 parent 5319108 commit 3d98329
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions synapse/rest/client/v2_alpha/sendtodevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
# limitations under the License.

import logging
from typing import Tuple

from synapse.http import servlet
from synapse.http.servlet import assert_params_in_dict, parse_json_object_from_request
from synapse.http.servlet import parse_json_object_from_request
from synapse.logging.opentracing import set_tag, trace
from synapse.rest.client.transactions import HttpTransactionCache

Expand Down Expand Up @@ -54,16 +53,18 @@ async def _put(self, request, message_type, txn_id):
requester = await self.auth.get_user_by_req(request, allow_guest=True)

content = parse_json_object_from_request(request)
assert_params_in_dict(content, ("messages",))

sender_user_id = requester.user.to_string()
# Messages is optional, but there is nothing for the server to do if it
# is not provided (or is empty).
messages = content.get("messages")
if messages:
sender_user_id = requester.user.to_string()

await self.device_message_handler.send_device_message(
sender_user_id, message_type, content["messages"]
)
await self.device_message_handler.send_device_message(
sender_user_id, message_type, messages
)

response = (200, {}) # type: Tuple[int, dict]
return response
return 200, {}


def register_servlets(hs, http_server):
Expand Down

0 comments on commit 3d98329

Please sign in to comment.