diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2022-03-30 14:39:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 14:39:27 +0100 |
commit | d8d0271977938d89585613e9a77537c33c4dc4a9 (patch) | |
tree | c5ccf846430cef6b45e5dcf1de938a9c92dcf628 /synapse/types.py | |
parent | Flesh out documentation for running SyTest against Synapse, including use of ... (diff) | |
download | synapse-d8d0271977938d89585613e9a77537c33c4dc4a9.tar.xz |
Send device list updates to application services (MSC3202) - part 1 (#11881)
Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
Diffstat (limited to 'synapse/types.py')
-rw-r--r-- | synapse/types.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/synapse/types.py b/synapse/types.py index 5ce2a5b0a5..500597b3a4 100644 --- a/synapse/types.py +++ b/synapse/types.py @@ -25,6 +25,7 @@ from typing import ( Match, MutableMapping, Optional, + Set, Tuple, Type, TypeVar, @@ -748,6 +749,30 @@ class ReadReceipt: data: JsonDict +@attr.s(slots=True, frozen=True, auto_attribs=True) +class DeviceListUpdates: + """ + An object containing a diff of information regarding other users' device lists, intended for + a recipient to carry out device list tracking. + + Attributes: + changed: A set of users whose device lists have changed recently. + left: A set of users who the recipient no longer needs to track the device lists of. + Typically when those users no longer share any end-to-end encryption enabled rooms. + """ + + # We need to use a factory here, otherwise `set` is not evaluated at + # object instantiation, but instead at class definition instantiation. + # The latter happening only once, thus always giving you the same sets + # across multiple DeviceListUpdates instances. + # Also see: don't define mutable default arguments. + changed: Set[str] = attr.ib(factory=set) + left: Set[str] = attr.ib(factory=set) + + def __bool__(self) -> bool: + return bool(self.changed or self.left) + + def get_verify_key_from_cross_signing_key(key_info): """Get the key ID and signedjson verify key from a cross-signing key dict |