diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2023-10-11 20:08:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 20:08:11 -0400 |
commit | cc865fffc0e556005a6ab596717a77230ba82ee7 (patch) | |
tree | 9ca606b24dd07b73edbb89bc1803e98034c812f2 /synapse/rest | |
parent | Convert simple_select_many_batch, simple_select_many_txn to tuples. (#16444) (diff) | |
download | synapse-cc865fffc0e556005a6ab596717a77230ba82ee7.tar.xz |
Convert user_get_threepids response to attrs. (#16468)
This improves type annotations by not having a dictionary of Any values.
Diffstat (limited to 'synapse/rest')
-rw-r--r-- | synapse/rest/admin/users.py | 3 | ||||
-rw-r--r-- | synapse/rest/client/account.py | 4 |
2 files changed, 4 insertions, 3 deletions
diff --git a/synapse/rest/admin/users.py b/synapse/rest/admin/users.py index cd995e8dbb..7fe16130e7 100644 --- a/synapse/rest/admin/users.py +++ b/synapse/rest/admin/users.py @@ -329,9 +329,8 @@ class UserRestServletV2(RestServlet): if threepids is not None: # get changed threepids (added and removed) - # convert List[Dict[str, Any]] into Set[Tuple[str, str]] cur_threepids = { - (threepid["medium"], threepid["address"]) + (threepid.medium, threepid.address) for threepid in await self.store.user_get_threepids(user_id) } add_threepids = new_threepids - cur_threepids diff --git a/synapse/rest/client/account.py b/synapse/rest/client/account.py index e74a87af4d..641390cb30 100644 --- a/synapse/rest/client/account.py +++ b/synapse/rest/client/account.py @@ -24,6 +24,8 @@ if TYPE_CHECKING or HAS_PYDANTIC_V2: from pydantic.v1 import StrictBool, StrictStr, constr else: from pydantic import StrictBool, StrictStr, constr + +import attr from typing_extensions import Literal from twisted.web.server import Request @@ -595,7 +597,7 @@ class ThreepidRestServlet(RestServlet): threepids = await self.datastore.user_get_threepids(requester.user.to_string()) - return 200, {"threepids": threepids} + return 200, {"threepids": [attr.asdict(t) for t in threepids]} # NOTE(dmr): I have chosen not to use Pydantic to parse this request's body, because # the endpoint is deprecated. (If you really want to, you could do this by reusing |