Mercurial > libervia-pubsub
changeset 400:371e72871e19
privilege: fill hash_map before jid_caps to avoid KeyError in getAutoSubscribers
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 07 May 2019 08:25:31 +0200 |
parents | 2521c53bc359 |
children | 907b10480394 |
files | src/privilege.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/privilege.py Mon May 06 09:37:47 2019 +0200 +++ b/src/privilege.py Tue May 07 08:25:31 2019 +0200 @@ -255,9 +255,6 @@ # FIXME: hash is not checked (cf. XEP-0115) disco_tuple = (hash_, ver) - jid_caps = self.caps_map.setdefault(from_jid_bare, {}) - if from_jid.resource not in jid_caps: - jid_caps[from_jid.resource] = disco_tuple if disco_tuple not in self.hash_map: # first time we se this hash, what is behind it? @@ -267,6 +264,12 @@ 'infos': infos } + # jid_caps must be filled only after hash_map is set, to be sure that + # the hash data is available in getAutoSubscribers + jid_caps = self.caps_map.setdefault(from_jid_bare, {}) + if from_jid.resource not in jid_caps: + jid_caps[from_jid.resource] = disco_tuple + # nodes are the nodes subscribed with +notify nodes = tuple(self.hash_map[disco_tuple]['notify']) if not nodes: @@ -301,8 +304,8 @@ online_resources = self.caps_map[roster_jid] except KeyError: continue - for res, hash_ in online_resources.iteritems(): - notify = self.hash_map[hash_]['notify'] + for res, disco_tuple in online_resources.iteritems(): + notify = self.hash_map[disco_tuple]['notify'] if nodeIdentifier in notify: full_jid = jid.JID(tuple=(roster_jid.user, roster_jid.host, res)) auto_subscribers.append(full_jid)