Commit e83b5d4d authored by Philipp Hörist's avatar Philipp Hörist

EME: Use namedtuple

parent b7cb8019
......@@ -19,6 +19,7 @@ import logging
from nbxmpp.protocol import NS_EME
from nbxmpp.structs import StanzaHandler
from nbxmpp.structs import EMEData
log = logging.getLogger('nbxmpp.m.eme')
......@@ -35,16 +36,15 @@ class EME:
@staticmethod
def _process_eme(_con, stanza, properties):
enc_tag = stanza.getTag('encryption', namespace=NS_EME)
if enc_tag is None:
encryption = stanza.getTag('encryption', namespace=NS_EME)
if encryption is None:
return
ns = enc_tag.getAttr('namespace')
if ns is None:
name = encryption.getAttr('name')
namespace = encryption.getAttr('namespace')
if namespace is None:
log.warning('No namespace on message')
return
properties.eme = {}
properties.eme['namespace'] = ns
properties.eme['name'] = enc_tag.getAttr('name')
properties.eme = EMEData(name=name, namespace=namespace)
log.info('Found data: %s', properties.eme)
......@@ -98,6 +98,8 @@ OMEMOMessage = namedtuple('OMEMOMessage', 'sid iv keys payload')
AnnotationNote = namedtuple('AnnotationNote', 'jid data cdate mdate')
AnnotationNote.__new__.__defaults__ = (None, None)
EMEData = namedtuple('EMEData', 'name namespace')
class OMEMOBundle(namedtuple('OMEMOBundle', 'spk spk_signature ik otpks')):
def pick_prekey(self):
......
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