mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 22:44:56 -04:00
Allow moving account data and receipts streams off master (#9104)
This commit is contained in:
parent
f08ef64926
commit
6633a4015a
27 changed files with 854 additions and 279 deletions
|
@ -37,24 +37,16 @@ class AccountDataServlet(RestServlet):
|
|||
super().__init__()
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastore()
|
||||
self.notifier = hs.get_notifier()
|
||||
self._is_worker = hs.config.worker_app is not None
|
||||
self.handler = hs.get_account_data_handler()
|
||||
|
||||
async def on_PUT(self, request, user_id, account_data_type):
|
||||
if self._is_worker:
|
||||
raise Exception("Cannot handle PUT /account_data on worker")
|
||||
|
||||
requester = await self.auth.get_user_by_req(request)
|
||||
if user_id != requester.user.to_string():
|
||||
raise AuthError(403, "Cannot add account data for other users.")
|
||||
|
||||
body = parse_json_object_from_request(request)
|
||||
|
||||
max_id = await self.store.add_account_data_for_user(
|
||||
user_id, account_data_type, body
|
||||
)
|
||||
|
||||
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
|
||||
await self.handler.add_account_data_for_user(user_id, account_data_type, body)
|
||||
|
||||
return 200, {}
|
||||
|
||||
|
@ -89,13 +81,9 @@ class RoomAccountDataServlet(RestServlet):
|
|||
super().__init__()
|
||||
self.auth = hs.get_auth()
|
||||
self.store = hs.get_datastore()
|
||||
self.notifier = hs.get_notifier()
|
||||
self._is_worker = hs.config.worker_app is not None
|
||||
self.handler = hs.get_account_data_handler()
|
||||
|
||||
async def on_PUT(self, request, user_id, room_id, account_data_type):
|
||||
if self._is_worker:
|
||||
raise Exception("Cannot handle PUT /account_data on worker")
|
||||
|
||||
requester = await self.auth.get_user_by_req(request)
|
||||
if user_id != requester.user.to_string():
|
||||
raise AuthError(403, "Cannot add account data for other users.")
|
||||
|
@ -109,12 +97,10 @@ class RoomAccountDataServlet(RestServlet):
|
|||
" Use /rooms/!roomId:server.name/read_markers",
|
||||
)
|
||||
|
||||
max_id = await self.store.add_account_data_to_room(
|
||||
await self.handler.add_account_data_to_room(
|
||||
user_id, room_id, account_data_type, body
|
||||
)
|
||||
|
||||
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
|
||||
|
||||
return 200, {}
|
||||
|
||||
async def on_GET(self, request, user_id, room_id, account_data_type):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue