Mercurial > libervia-backend
diff sat/memory/disco.py @ 2830:770ec685ff1f
core (disco): added missing disco extensions when generating the cap hash.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 01 Mar 2019 19:28:11 +0100 |
parents | 003b8b4b56a7 |
children | 2224fbbd45dd |
line wrap: on
line diff
--- 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