Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ichthyx committed Aug 3, 2023
1 parent 4872369 commit 21f1e4f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions prometheus_xmpp/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
from slixmpp import JID
from slixmpp.exceptions import IqTimeout, IqError
import slixmpp_omemo
from slixmpp_omemo import PluginCouldNotLoad, MissingOwnKey, EncryptionPrepareException
from slixmpp_omemo import UndecidedException, UntrustedException, NoAvailableSession
from slixmpp_omemo import PluginCouldNotLoad, EncryptionPrepareException
from slixmpp_omemo import UndecidedException
from omemo.exceptions import MissingBundleException


Expand Down Expand Up @@ -242,7 +242,8 @@ async def dispatch_message(self, mto, mbody, mhtml):
return_exceptions=True,
)
muc_affiliation = owners + admins + members + outcasts
recipients = [JID(nick) for nick in muc_affiliations]
recipients = [JID(nick) for nick in muc_affiliation]
recipients.remove(self.jid)
logging.debug(f"sending encrypted message to recipients: {recipients}")
await self.send_encrypted(mto=recipients, mtype="groupchat", body=mbody)

Expand All @@ -251,7 +252,7 @@ async def send_encrypted(self, mto: JID, mtype: str, body):
if self.muc:
msg = self.make_message(mto=self.muc_jid, mtype=mtype)
else:
msg = self.make_message(mto=mto, mtype=mtype)
msg = self.make_message(mto=mto[0], mtype=mtype)

msg["eme"]["namespace"] = self.eme_ns
msg["eme"]["name"] = self["xep_0380"].mechanisms[self.eme_ns]
Expand Down Expand Up @@ -298,7 +299,9 @@ async def send_encrypted(self, mto: JID, mtype: str, body):
# device won't be able to decrypt and should display a
# generic message. The receiving end-user at this
# point can bring up the issue if it happens.
self.plain_reply(
if self.muc:
mto=self.muc_jid
self.send_message(
mto,
mtype,
'Could not find keys for device "%d" of recipient "%s". Skipping.'
Expand All @@ -308,15 +311,19 @@ async def send_encrypted(self, mto: JID, mtype: str, body):
device_list = expect_problems.setdefault(jid, [])
device_list.append(error.device)
except (IqError, IqTimeout) as exn:
self.plain_reply(
if self.muc:
mto=self.muc_jid
self.send_message(
mto,
mtype,
"An error occured while fetching information on a recipient.\n%r"
% exn,
)
return None
except Exception as exn:
await self.plain_reply(
if self.muc:
mto=self.muc_jid
await self.send_message(
mto,
mtype,
"An error occured while attempting to encrypt.\n%r" % exn,
Expand Down

0 comments on commit 21f1e4f

Please sign in to comment.