Mercurial > libervia-pubsub
diff sat_pubsub/pgsql_storage.py @ 463:f520ac3164b0
privilege: improvment on last message sending on presence with `+notify`:
- local entities subscribed to the presence of an other local entity which is connecting
are now added to presence map. This helps getting their notification even if they didn't
connect recently
- nodes with `presence` access model are now also used for `+notify`
- notifications are not sent anymore in case of status change if the resource was already
present.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 15 Oct 2021 13:40:56 +0200 |
parents | 7c9792f934a2 |
children | 0d38c3529972 |
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py Fri Oct 15 09:32:07 2021 +0200 +++ b/sat_pubsub/pgsql_storage.py Fri Oct 15 13:40:56 2021 +0200 @@ -455,10 +455,12 @@ def getLastItems(self, entities, nodes, node_accesses, item_accesses, pep): """get last item for several nodes and entities in a single request""" + # TODO: manage other access model (whitelist, …) if not entities or not nodes or not node_accesses or not item_accesses: raise BadRequest(text="entities, nodes and accesses must not be empty") - if node_accesses != ('open',) or item_accesses != ('open',): - raise NotImplementedError('only "open" access model is handled for now') + if any(not {"open", "presence"}.issuperset(a) + for a in (node_accesses, item_accesses)): + raise NotImplementedError('only "open" and "presence" access model are handled for now') if not pep: raise NotImplementedError("getLastItems is only implemented for PEP at the moment") d = self.dbpool.runQuery("""SELECT DISTINCT ON (node_id) pep, node, data::text, items.access_model