-
Notifications
You must be signed in to change notification settings - Fork 396
Fix deactivation running off the main process #18716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a2b3513
Make AuthHandler.delete_local_threepid work on workers
sandhose 0e488f8
Move user_set_password_hash to the RegistrationWorkerStore
sandhose cd6d500
Make deleting all pushers for a user go through replication
sandhose 1116407
Make deactivation work off the main process
sandhose 26a0bb1
Newsfile
sandhose 8b93e8a
Move /account/deactivate to workers in tests
sandhose 77c13a5
Mount the DeactivateAccountRestServlet on workers as well
sandhose 8edd6c2
Move add_user_pending_deactivation to RegistrationWorkerStore
sandhose 64ba192
Move mark_user_(not_)erased to UserErasureWorkerStore
sandhose 36071b8
Use keyword arguments for consistency
sandhose File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix user failing to deactivate with MAS when `/_synapse/mas` is handled by a worker. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# | ||
# This file is licensed under the Affero General Public License (AGPL) version 3. | ||
# | ||
# Copyright (C) 2023 New Vector, Ltd | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Affero General Public License as | ||
# published by the Free Software Foundation, either version 3 of the | ||
# License, or (at your option) any later version. | ||
# | ||
# See the GNU Affero General Public License for more details: | ||
# <https://www.gnu.org/licenses/agpl-3.0.html>. | ||
# | ||
# Originally licensed under the Apache License, Version 2.0: | ||
# <http://www.apache.org/licenses/LICENSE-2.0>. | ||
# | ||
# [This file includes modifications made by New Vector Limited] | ||
# | ||
# | ||
|
||
import logging | ||
from typing import TYPE_CHECKING, Tuple | ||
|
||
from twisted.web.server import Request | ||
|
||
from synapse.http.server import HttpServer | ||
from synapse.replication.http._base import ReplicationEndpoint | ||
from synapse.types import JsonDict | ||
|
||
if TYPE_CHECKING: | ||
from synapse.server import HomeServer | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ReplicationNotifyAccountDeactivatedServlet(ReplicationEndpoint): | ||
"""Notify that an account has been deactivated. | ||
|
||
Request format: | ||
|
||
POST /_synapse/replication/notify_account_deactivated/:user_id | ||
|
||
{ | ||
"by_admin": true, | ||
} | ||
|
||
""" | ||
|
||
NAME = "notify_account_deactivated" | ||
PATH_ARGS = ("user_id",) | ||
|
||
def __init__(self, hs: "HomeServer"): | ||
super().__init__(hs) | ||
self.deactivate_account_handler = hs.get_deactivate_account_handler() | ||
|
||
@staticmethod | ||
async def _serialize_payload( # type: ignore[override] | ||
user_id: str, | ||
by_admin: bool, | ||
) -> JsonDict: | ||
""" | ||
Args: | ||
user_id: The user ID which has been deactivated. | ||
by_admin: Whether the user was deactivated by an admin. | ||
""" | ||
return { | ||
"by_admin": by_admin, | ||
} | ||
|
||
async def _handle_request( # type: ignore[override] | ||
self, request: Request, content: JsonDict, user_id: str | ||
) -> Tuple[int, JsonDict]: | ||
by_admin = content["by_admin"] | ||
await self.deactivate_account_handler.notify_account_deactivated( | ||
user_id, by_admin=by_admin | ||
) | ||
return 200, {} | ||
|
||
|
||
def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: | ||
ReplicationNotifyAccountDeactivatedServlet(hs).register(http_server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.