Skip to content

Commit

Permalink
Add debug logging for subscription and await operations correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Syndace committed Oct 7, 2024
1 parent 62dcc67 commit 8119306
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions slixmpp_omemo/xep_0384.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ async def _on_subscription_changed(self, presence: Presence) -> None:

pep_enabled = jid in roster and roster[jid]["subscription"] == "both"

log.debug(f"Subscription changed for {jid}; PEP enabled: {pep_enabled}")

for namespace in [ twomemo.twomemo.NAMESPACE, oldmemo.oldmemo.NAMESPACE ]:
subscribed = (await self.storage.load_primitive(
f"/slixmpp/subscribed/{jid}/{namespace}",
Expand Down Expand Up @@ -773,6 +775,8 @@ async def _subscribe(self, namespace: str, jid: JID) -> None:

jid = JID(jid.bare)

log.debug(f"Manually subscribing to {namespace} device list for {jid}")

node = {
twomemo.twomemo.NAMESPACE: TWOMEMO_DEVICE_LIST_NODE,
oldmemo.oldmemo.NAMESPACE: OLDMEMO_DEVICE_LIST_NODE
Expand All @@ -784,7 +788,7 @@ async def _subscribe(self, namespace: str, jid: JID) -> None:
xep_0060: XEP_0060 = self.xmpp["xep_0060"]

try:
xep_0060.subscribe(jid, node)
await xep_0060.subscribe(jid, node)
except IqError as e:
# Failure to subscribe is non-critical here, simply debug log the error (and don't update the
# subscription status).
Expand All @@ -804,6 +808,8 @@ async def _unsubscribe(self, namespace: str, jid: JID) -> None:

jid = JID(jid.bare)

log.debug(f"Manually unsubscribing from {namespace} device list for {jid}")

node = {
twomemo.twomemo.NAMESPACE: TWOMEMO_DEVICE_LIST_NODE,
oldmemo.oldmemo.NAMESPACE: OLDMEMO_DEVICE_LIST_NODE
Expand All @@ -815,7 +821,7 @@ async def _unsubscribe(self, namespace: str, jid: JID) -> None:
xep_0060: XEP_0060 = self.xmpp["xep_0060"]

try:
xep_0060.unsubscribe(jid, node)
await xep_0060.unsubscribe(jid, node)
except IqError as e:
# Don't really care about any of the possible Iq error cases:
# https://xmpp.org/extensions/xep-0060.html#subscriber-unsubscribe-error
Expand Down Expand Up @@ -880,7 +886,10 @@ async def refresh_device_lists(self, jids: Set[JID], force_download: bool = Fals

for namespace in refresh_namespaces:
# Force-download the device lists that need a manual refresh
await session_manager.refresh_device_list(namespace, jid.bare)
try:
await session_manager.refresh_device_list(namespace, jid.bare)
except omemo.DeviceListDownloadFailed as e:
log.debug(f"Couldn't manually fetch {namespace} device list, probably doesn't exist: {e}")

async def encrypt_message(
self,
Expand Down

0 comments on commit 8119306

Please sign in to comment.