get_trust_for_jid: Add our own did and ik to requests to ownjid

Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 957b555d
Pipeline #3990 passed with stage
......@@ -255,6 +255,10 @@ class XEP_0384(BasePlugin):
def my_device_id(self) -> int:
return self._device_id
def my_identity_key(self) -> bytes:
bundle = self._omemo.public_bundle.serialize(self.omemo_backend)
return bundle['ik']
def _set_node_config(
self,
node: str,
......@@ -490,12 +494,15 @@ class XEP_0384(BasePlugin):
as keys, and a dict with 'key', 'trust' as values that can also be
None.
When the barejid provided is ours, also include our own device id
and key as active.
Example:
{
'active': {
123456: {
'key': bytes,
'trust': bool,
'trust': Optional[bool],
}
}
'inactive': {
......@@ -504,7 +511,20 @@ class XEP_0384(BasePlugin):
}
"""
return self._omemo.getTrustForJID(jid.bare)
bare = jid.bare
trust = self._omemo.getTrustForJID(bare)
if self.xmpp.boundjid.bare == bare:
did = self.my_device_id()
key = self.my_identity_key()
trust['active'].update({
did: {
'key': key,
'trust': None,
}
})
return trust
def is_encrypted(self, msg: Message) -> bool:
return msg.xml.find('{%s}encrypted' % OMEMO_BASE_NS) is not None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment