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
|
TODO
|
||||||
----
|
----
|
||||||
|
|
||||||
- MUC support. Needs support for handling MUC reflections in poezio first.
|
|
||||||
- aesgcm
|
- aesgcm
|
||||||
- UI, various commands and indicators that messages are encrypted or not.
|
- UI, various commands and indicators that messages are encrypted or not.
|
||||||
|
|
|
@ -44,6 +44,8 @@ class Plugin(E2EEPlugin):
|
||||||
(slixmpp_omemo.OMEMO_BASE_NS, 'encrypted'),
|
(slixmpp_omemo.OMEMO_BASE_NS, 'encrypted'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
self_muc_messages: Dict[str, str] = {}
|
||||||
|
|
||||||
# TODO: Look into blind trust stuff.
|
# TODO: Look into blind trust stuff.
|
||||||
# https://gist.github.com/mar-v-in/b683220a55bc65dcdafc809be9c5d0e4
|
# https://gist.github.com/mar-v-in/b683220a55bc65dcdafc809be9c5d0e4
|
||||||
trust_states = {
|
trust_states = {
|
||||||
|
@ -57,6 +59,12 @@ class Plugin(E2EEPlugin):
|
||||||
}
|
}
|
||||||
supported_tab_types = (DynamicConversationTab, StaticConversationTab, MucTab)
|
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:
|
def init(self) -> None:
|
||||||
super().init()
|
super().init()
|
||||||
|
|
||||||
|
@ -102,7 +110,6 @@ class Plugin(E2EEPlugin):
|
||||||
]
|
]
|
||||||
|
|
||||||
def decrypt(self, message: Message, jid: Optional[JID], tab: ChatTab) -> None:
|
def decrypt(self, message: Message, jid: Optional[JID], tab: ChatTab) -> None:
|
||||||
|
|
||||||
if jid is None:
|
if jid is None:
|
||||||
self.display_error('Unable to decrypt the message.')
|
self.display_error('Unable to decrypt the message.')
|
||||||
return None
|
return None
|
||||||
|
@ -120,9 +127,14 @@ class Plugin(E2EEPlugin):
|
||||||
except (MissingOwnKey,):
|
except (MissingOwnKey,):
|
||||||
# The message is missing our own key, it was not encrypted for
|
# The message is missing our own key, it was not encrypted for
|
||||||
# us, and we can't decrypt it.
|
# us, and we can't decrypt it.
|
||||||
self.display_error(
|
if (message['type'] == 'groupchat' and
|
||||||
'I can\'t decrypt this message as it is not encrypted for me.'
|
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.'
|
||||||
|
)
|
||||||
except (NoAvailableSession,) as exn:
|
except (NoAvailableSession,) as exn:
|
||||||
# We received a message from that contained a session that we
|
# We received a message from that contained a session that we
|
||||||
# don't know about (deleted session storage, etc.). We can't
|
# don't know about (deleted session storage, etc.). We can't
|
||||||
|
@ -152,6 +164,8 @@ class Plugin(E2EEPlugin):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
body = message['body']
|
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]]
|
expect_problems = {} # type: Dict[JID, List[int]]
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in a new issue