Merge branch 'muc-reflections' into 'master'
Add a workaround for MUC reflections See merge request poezio/poezio-omemo!3
This commit is contained in:
commit
f9d6897293
2 changed files with 18 additions and 5 deletions
|
@ -53,6 +53,5 @@ information about autoloading plugins.
|
|||
TODO
|
||||
----
|
||||
|
||||
- MUC support. Needs support for handling MUC reflections in poezio first.
|
||||
- aesgcm
|
||||
- UI, various commands and indicators that messages are encrypted or not.
|
||||
|
|
|
@ -44,6 +44,8 @@ class Plugin(E2EEPlugin):
|
|||
(slixmpp_omemo.OMEMO_BASE_NS, 'encrypted'),
|
||||
]
|
||||
|
||||
self_muc_messages: Dict[str, str] = {}
|
||||
|
||||
# TODO: Look into blind trust stuff.
|
||||
# https://gist.github.com/mar-v-in/b683220a55bc65dcdafc809be9c5d0e4
|
||||
trust_states = {
|
||||
|
@ -57,6 +59,12 @@ class Plugin(E2EEPlugin):
|
|||
}
|
||||
supported_tab_types = (DynamicConversationTab, StaticConversationTab, MucTab)
|
||||
|
||||
default_config = {
|
||||
# Some MUC services may not reflect the message ids properly, in which
|
||||
# case it is better to set this option to false.
|
||||
'enable_muc': True,
|
||||
}
|
||||
|
||||
def init(self) -> None:
|
||||
super().init()
|
||||
|
||||
|
@ -102,7 +110,6 @@ class Plugin(E2EEPlugin):
|
|||
]
|
||||
|
||||
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
|
||||
|
@ -120,8 +127,13 @@ class Plugin(E2EEPlugin):
|
|||
except (MissingOwnKey,):
|
||||
# The message is missing our own key, it was not encrypted for
|
||||
# us, and we can't decrypt it.
|
||||
if (message['type'] == 'groupchat' and
|
||||
message['id'] in self.self_muc_messages):
|
||||
body = self.self_muc_messages.pop(message['id'])
|
||||
else:
|
||||
self.display_error(
|
||||
'I can\'t decrypt this message as it is not encrypted for me.'
|
||||
'I can\'t decrypt this message as it '
|
||||
'is not encrypted for me.'
|
||||
)
|
||||
except (NoAvailableSession,) as exn:
|
||||
# We received a message from that contained a session that we
|
||||
|
@ -152,6 +164,8 @@ class Plugin(E2EEPlugin):
|
|||
return None
|
||||
|
||||
body = message['body']
|
||||
if self.config.get('enable_muc', True) and message['type'] == 'groupchat':
|
||||
self.self_muc_messages[message['id']] = body
|
||||
expect_problems = {} # type: Dict[JID, List[int]]
|
||||
|
||||
while True:
|
||||
|
|
Loading…
Reference in a new issue