[pgp] Fix various type errors

This commit is contained in:
Philipp Hörist
2026-01-02 20:28:00 +01:00
parent e6ea3f402f
commit 17e071d9d0
2 changed files with 12 additions and 5 deletions

View File

@@ -324,11 +324,16 @@ class PGPLegacy(BaseModule):
def _cleanup_stanza(message: OutgoingMessage) -> None: def _cleanup_stanza(message: OutgoingMessage) -> None:
"""We make sure only allowed tags are in the stanza""" """We make sure only allowed tags are in the stanza"""
original_stanza = message.get_stanza() original_stanza = message.get_stanza()
stanza = nbxmpp.Message( m_type = original_stanza.getType()
to=original_stanza.getTo(), typ=original_stanza.getType() assert m_type in ("chat", "groupchat", "normal")
) stanza = nbxmpp.Message(to=original_stanza.getTo(), typ=m_type)
stanza.setID(original_stanza.getID())
stanza.setThread(original_stanza.getThread()) if message_id := original_stanza.getID():
stanza.setID(message_id)
if thread := original_stanza.getThread():
stanza.setThread(thread)
for tag, ns in ALLOWED_TAGS: for tag, ns in ALLOWED_TAGS:
node = original_stanza.getTag(tag, namespace=ns) node = original_stanza.getTag(tag, namespace=ns)
if node: if node:

View File

@@ -129,6 +129,7 @@ class PGPPlugin(GajimPlugin):
def _on_encryption_dialog(self, chat_control: ChatControl): def _on_encryption_dialog(self, chat_control: ChatControl):
account = chat_control.account account = chat_control.account
assert chat_control.contact is not None
jid = chat_control.contact.jid jid = chat_control.contact.jid
transient = app.window transient = app.window
KeyDialog(self, account, jid, transient) KeyDialog(self, account, jid, transient)
@@ -162,6 +163,7 @@ class PGPPlugin(GajimPlugin):
def _before_sendmessage(self, chat_control: ChatControl) -> None: def _before_sendmessage(self, chat_control: ChatControl) -> None:
account = chat_control.account account = chat_control.account
assert chat_control.contact is not None
jid = str(chat_control.contact.jid) jid = str(chat_control.contact.jid)
pgp = self.get_pgp_module(account) pgp = self.get_pgp_module(account)