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

Fallback if 'approved' isn't included in a registration replication request #14135

Merged
merged 4 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/14135.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.69.0rc1 which would cause registration replication requests to fail if the worker sending the request is not running Synapse 1.69.
18 changes: 17 additions & 1 deletion synapse/replication/http/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ def __init__(self, hs: "HomeServer"):
self.store = hs.get_datastores().main
self.registration_handler = hs.get_registration_handler()

# Default value if the worker that sent the replication request did not include
# an 'approved' property.
if (
hs.config.experimental.msc3866.enabled
and hs.config.experimental.msc3866.require_approval_for_new_accounts
):
self._approval_default = False
else:
self._approval_default = True

@staticmethod
async def _serialize_payload( # type: ignore[override]
user_id: str,
Expand Down Expand Up @@ -92,6 +102,12 @@ async def _handle_request( # type: ignore[override]

await self.registration_handler.check_registration_ratelimit(content["address"])

# Always default admin users to approved (since it means they were created by
# an admin).
approved_default = self._approval_default
if content["admin"]:
approved_default = True

await self.registration_handler.register_with_store(
user_id=user_id,
password_hash=content["password_hash"],
Expand All @@ -103,7 +119,7 @@ async def _handle_request( # type: ignore[override]
user_type=content["user_type"],
address=content["address"],
shadow_banned=content["shadow_banned"],
approved=content["approved"],
approved=content.get("approved", approved_default),
)

return 200, {}
Expand Down