diff options
author | Brendan Abolivier <babolivier@matrix.org> | 2022-02-22 16:10:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 15:10:10 +0000 |
commit | 250104d357c17a1c87fa46af35bbf3612f4ef171 (patch) | |
tree | 240530842209062c8366f22170dc0651d6f0fae5 /synapse/rest/client/account.py | |
parent | Prune setup.cfg some more (#12059) (diff) | |
download | synapse-250104d357c17a1c87fa46af35bbf3612f4ef171.tar.xz |
Implement account status endpoints (MSC3720) (#12001)
See matrix-org/matrix-doc#3720 Co-authored-by: Sean Quah <8349537+squahtx@users.noreply.github.com>
Diffstat (limited to 'synapse/rest/client/account.py')
-rw-r--r-- | synapse/rest/client/account.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/synapse/rest/client/account.py b/synapse/rest/client/account.py index efe299e698..5802de5b7c 100644 --- a/synapse/rest/client/account.py +++ b/synapse/rest/client/account.py @@ -896,6 +896,36 @@ class WhoamiRestServlet(RestServlet): return 200, response +class AccountStatusRestServlet(RestServlet): + PATTERNS = client_patterns( + "/org.matrix.msc3720/account_status$", unstable=True, releases=() + ) + + def __init__(self, hs: "HomeServer"): + super().__init__() + self._auth = hs.get_auth() + self._store = hs.get_datastore() + self._is_mine = hs.is_mine + self._federation_client = hs.get_federation_client() + self._account_handler = hs.get_account_handler() + + async def on_POST(self, request: SynapseRequest) -> Tuple[int, JsonDict]: + await self._auth.get_user_by_req(request) + + body = parse_json_object_from_request(request) + if "user_ids" not in body: + raise SynapseError( + 400, "Required parameter 'user_ids' is missing", Codes.MISSING_PARAM + ) + + statuses, failures = await self._account_handler.get_account_statuses( + body["user_ids"], + allow_remote=True, + ) + + return 200, {"account_statuses": statuses, "failures": failures} + + def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: EmailPasswordRequestTokenRestServlet(hs).register(http_server) PasswordRestServlet(hs).register(http_server) @@ -910,3 +940,6 @@ def register_servlets(hs: "HomeServer", http_server: HttpServer) -> None: ThreepidUnbindRestServlet(hs).register(http_server) ThreepidDeleteRestServlet(hs).register(http_server) WhoamiRestServlet(hs).register(http_server) + + if hs.config.experimental.msc3720_enabled: + AccountStatusRestServlet(hs).register(http_server) |