Skip to content

Commit

Permalink
Remove manual subscription status fetching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndace committed Oct 7, 2024
1 parent e11dbc5 commit a4762ed
Showing 1 changed file with 4 additions and 37 deletions.
41 changes: 4 additions & 37 deletions slixmpp_omemo/xep_0384.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,37 +824,6 @@ async def _unsubscribe(self, namespace: str, jid: JID) -> None:

await self.storage.store(f"/slixmpp/subscribed/{jid.bare}/{namespace}", False)

async def _fetch_subscription_status(self, namespace: str, jid: JID) -> Optional[bool]:
"""
Fetches the subscription status to the device list pubsub node of the JID, updates the status in
storage and returns it.
Args:
namespace: The OMEMO version namespace (not the node).
jid: The JID whose device list to manually unsubscribe from. Can be a bare (aka "userhost") JID
but doesn't have to.
Returns:
The updated subscription status. Can still be ``None`` if the server doesn't support fetching
subscription status.
"""

jid = JID(jid.bare)

node = {
twomemo.twomemo.NAMESPACE: TWOMEMO_DEVICE_LIST_NODE,
oldmemo.oldmemo.NAMESPACE: OLDMEMO_DEVICE_LIST_NODE
}.get(namespace, None)

if node is None:
raise UnknownNamespace(f"Unknown namespace during device list unsubscription: {namespace}")

# xep_0060: XEP_0060 = self.xmpp["xep_0060"]

# TODO

return None

async def refresh_device_lists(self, jids: Set[JID], force_download: bool = False) -> None:
"""
Ensure that up-to-date device lists for the JIDs are cached. This is done automatically by
Expand Down Expand Up @@ -897,13 +866,11 @@ async def refresh_device_lists(self, jids: Set[JID], force_download: bool = Fals
bool
)).maybe(None)

if subscribed is None:
# Subscription status unknown, ask the server
subscribed = await self._fetch_subscription_status(namespace, jid)

if not subscribed:
# If not subscribed already, manually subscribe to stay up-to-date automatically in
# the future
# If not subscribed already (or the subscription status is unknown), manually
# subscribe to stay up-to-date automatically in the future. This trusts that servers,
# even if they support multi-subscribe, would not generate exact duplicate
# subscriptions with differing subscription ids.
await self._subscribe(namespace, jid)
refresh_namespaces.add(namespace)

Expand Down

0 comments on commit a4762ed

Please sign in to comment.