# HG changeset patch # User Goffi # Date 1551464891 -3600 # Node ID 770ec685ff1f814564b7492874439469b025a1a9 # Parent 649cb3fd7711026e3ac0123314ebcdddc5cefc87 core (disco): added missing disco extensions when generating the cap hash. diff -r 649cb3fd7711 -r 770ec685ff1f sat/memory/disco.py --- a/sat/memory/disco.py Fri Mar 01 17:42:28 2019 +0100 +++ b/sat/memory/disco.py Fri Mar 01 19:28:11 2019 +0100 @@ -356,6 +356,7 @@ """ s = [] + # identities byte_identities = [ ByteIdentity(service) for service in services @@ -367,6 +368,7 @@ for identity in byte_identities: s.append(str(identity)) s.append("<") + # features byte_features = [ service.encode("utf-8") for service in services @@ -376,9 +378,26 @@ for feature in byte_features: s.append(feature) s.append("<") - # TODO: manage XEP-0128 data form here + + # extensions + ext = services.extensions.values() + ext.sort(key=lambda f: f.formNamespace.encode('utf-8')) + for extension in ext: + s.append(extension.formNamespace.encode('utf-8')) + s.append("<") + fields = extension.fieldList + fields.sort(key=lambda f: f.var.encode('utf-8')) + for field in fields: + s.append(field.var.encode('utf-8')) + s.append("<") + values = [v.encode('utf-8') for v in field.values] + values.sort() + for value in values: + s.append(value) + s.append("<") + cap_hash = b64encode(sha1("".join(s)).digest()) - log.debug(_(u"Capability hash generated: [%s]") % cap_hash) + log.debug(_(u"Capability hash generated: [{cap_hash}]").format(cap_hash=cap_hash)) return cap_hash @defer.inlineCallbacks diff -r 649cb3fd7711 -r 770ec685ff1f sat/plugins/plugin_xep_0115.py --- a/sat/plugins/plugin_xep_0115.py Fri Mar 01 17:42:28 2019 +0100 +++ b/sat/plugins/plugin_xep_0115.py Fri Mar 01 19:28:11 2019 +0100 @@ -165,9 +165,10 @@ if c_hash != "sha-1": # unknown hash method log.warning( _( - u"Unknown hash method for entity capabilities: [%(hash_method)s] (entity: %(jid)s, node: %(node)s)" + u"Unknown hash method for entity capabilities: [{hash_method}] " + u"(entity: {entity_jid}, node: {node})" ) - % {"hash_method": c_hash, "jid": from_jid, "node": c_node} + .format(hash_method = c_hash, entity_jid = from_jid, node = c_node) ) def cb(__): @@ -177,14 +178,16 @@ if computed_hash != c_ver: log.warning( _( - u"Computed hash differ from given hash:\ngiven: [%(given_hash)s]\ncomputed: [%(computed_hash)s]\n(entity: %(jid)s, node: %(node)s)" + u"Computed hash differ from given hash:\n" + u"given: [{given}]\n" + u"computed: [{computed}]\n" + u"(entity: {entity_jid}, node: {node})" + ).format( + given = c_ver, + computed = computed_hash, + entity_jid = from_jid, + node = c_node, ) - % { - "given_hash": c_ver, - "computed_hash": computed_hash, - "jid": from_jid, - "node": c_node, - } ) def eb(failure):