mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-05 10:44:13 -04:00
Track device IDs for pushers (#13831)
Second half of the MSC3881 implementation
This commit is contained in:
parent
0fd2f2d460
commit
ccca14140a
7 changed files with 154 additions and 10 deletions
|
@ -117,6 +117,7 @@ class PusherConfig:
|
|||
last_success: Optional[int]
|
||||
failing_since: Optional[int]
|
||||
enabled: bool
|
||||
device_id: Optional[str]
|
||||
|
||||
def as_dict(self) -> Dict[str, Any]:
|
||||
"""Information that can be retrieved about a pusher after creation."""
|
||||
|
@ -130,6 +131,7 @@ class PusherConfig:
|
|||
"profile_tag": self.profile_tag,
|
||||
"pushkey": self.pushkey,
|
||||
"enabled": self.enabled,
|
||||
"device_id": self.device_id,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ class PusherPool:
|
|||
data: JsonDict,
|
||||
profile_tag: str = "",
|
||||
enabled: bool = True,
|
||||
device_id: Optional[str] = None,
|
||||
) -> Optional[Pusher]:
|
||||
"""Creates a new pusher and adds it to the pool
|
||||
|
||||
|
@ -149,18 +150,20 @@ class PusherPool:
|
|||
last_success=None,
|
||||
failing_since=None,
|
||||
enabled=enabled,
|
||||
device_id=device_id,
|
||||
)
|
||||
)
|
||||
|
||||
# Before we actually persist the pusher, we check if the user already has one
|
||||
# for this app ID and pushkey. If so, we want to keep the access token in place,
|
||||
# since this could be one device modifying (e.g. enabling/disabling) another
|
||||
# device's pusher.
|
||||
# this app ID and pushkey. If so, we want to keep the access token and device ID
|
||||
# in place, since this could be one device modifying (e.g. enabling/disabling)
|
||||
# another device's pusher.
|
||||
existing_config = await self._get_pusher_config_for_user_by_app_id_and_pushkey(
|
||||
user_id, app_id, pushkey
|
||||
)
|
||||
if existing_config:
|
||||
access_token = existing_config.access_token
|
||||
device_id = existing_config.device_id
|
||||
|
||||
await self.store.add_pusher(
|
||||
user_id=user_id,
|
||||
|
@ -176,6 +179,7 @@ class PusherPool:
|
|||
last_stream_ordering=last_stream_ordering,
|
||||
profile_tag=profile_tag,
|
||||
enabled=enabled,
|
||||
device_id=device_id,
|
||||
)
|
||||
pusher = await self.process_pusher_change_by_id(app_id, pushkey, user_id)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue