MUC support
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
05310c104b
commit
6adbf64a7f
1 changed files with 18 additions and 11 deletions
|
@ -17,7 +17,7 @@ from typing import Dict, List, Optional
|
||||||
|
|
||||||
from poezio.plugin_e2ee import E2EEPlugin
|
from poezio.plugin_e2ee import E2EEPlugin
|
||||||
from poezio.xdg import DATA_HOME
|
from poezio.xdg import DATA_HOME
|
||||||
from poezio.tabs import DynamicConversationTab, StaticConversationTab, MucTab
|
from poezio.tabs import ChatTab, DynamicConversationTab, StaticConversationTab, MucTab
|
||||||
|
|
||||||
from omemo.exceptions import MissingBundleException
|
from omemo.exceptions import MissingBundleException
|
||||||
from slixmpp import JID
|
from slixmpp import JID
|
||||||
|
@ -94,15 +94,18 @@ class Plugin(E2EEPlugin):
|
||||||
if trust is not None
|
if trust is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
def decrypt(self, message: Message, tab) -> None:
|
def decrypt(self, message: Message, jid: Optional[JID], tab: ChatTab) -> None:
|
||||||
|
|
||||||
|
if jid is None:
|
||||||
|
self.display_error('Unable to decrypt the message.')
|
||||||
|
return None
|
||||||
|
|
||||||
body = None
|
body = None
|
||||||
try:
|
try:
|
||||||
mfrom = message['from']
|
|
||||||
encrypted = message['omemo_encrypted']
|
encrypted = message['omemo_encrypted']
|
||||||
body = self.core.xmpp['xep_0384'].decrypt_message(
|
body = self.core.xmpp['xep_0384'].decrypt_message(
|
||||||
encrypted,
|
encrypted,
|
||||||
mfrom,
|
jid,
|
||||||
# Always decrypt. Let us handle how we then warn the user.
|
# Always decrypt. Let us handle how we then warn the user.
|
||||||
allow_untrusted=True,
|
allow_untrusted=True,
|
||||||
)
|
)
|
||||||
|
@ -136,8 +139,11 @@ class Plugin(E2EEPlugin):
|
||||||
if body is not None:
|
if body is not None:
|
||||||
message['body'] = body
|
message['body'] = body
|
||||||
|
|
||||||
async def encrypt(self, message: Message, _tab) -> None:
|
async def encrypt(self, message: Message, jids: Optional[List[JID]], _tab) -> None:
|
||||||
mto = message['to']
|
if jids is None:
|
||||||
|
self.display_error('Unable to encrypt the message.')
|
||||||
|
return None
|
||||||
|
|
||||||
body = message['body']
|
body = message['body']
|
||||||
expect_problems = {} # type: Optional[Dict[JID, List[int]]]
|
expect_problems = {} # type: Optional[Dict[JID, List[int]]]
|
||||||
|
|
||||||
|
@ -151,11 +157,12 @@ class Plugin(E2EEPlugin):
|
||||||
# and not a full Message stanza. This combined with the
|
# and not a full Message stanza. This combined with the
|
||||||
# `recipients` parameter that requires for a list of JIDs,
|
# `recipients` parameter that requires for a list of JIDs,
|
||||||
# allows you to encrypt for 1:1 as well as groupchats (MUC).
|
# allows you to encrypt for 1:1 as well as groupchats (MUC).
|
||||||
#
|
recipients = jids
|
||||||
# TODO: Document expect_problems
|
encrypt = await self.core.xmpp['xep_0384'].encrypt_message(
|
||||||
# TODO: Handle multiple recipients (MUCs)
|
body,
|
||||||
recipients = [mto]
|
recipients,
|
||||||
encrypt = await self.core.xmpp['xep_0384'].encrypt_message(body, recipients, expect_problems)
|
expect_problems,
|
||||||
|
)
|
||||||
message.append(encrypt)
|
message.append(encrypt)
|
||||||
return None
|
return None
|
||||||
except UndecidedException as exn:
|
except UndecidedException as exn:
|
||||||
|
|
Loading…
Reference in a new issue