# HG changeset patch # User Goffi # Date 1596291439 -7200 # Node ID 56ee491c0df6c003fff02fb8713f909d3da7d600 # Parent 8bbd2ed924e82e112b2143c14422e15f42d859f1 plugin list for interest: build ID using URI or file path metadata: by using those metadata, we get the same ID for 2 interests linking to the same location. This has been done to avoid duplicated interests. diff -r 8bbd2ed924e8 -r 56ee491c0df6 sat/plugins/plugin_exp_list_of_interest.py --- a/sat/plugins/plugin_exp_list_of_interest.py Sat Aug 01 16:14:37 2020 +0200 +++ b/sat/plugins/plugin_exp_list_of_interest.py Sat Aug 01 16:17:19 2020 +0200 @@ -21,6 +21,7 @@ from sat.core.constants import Const as C from sat.core.log import getLogger from sat.tools.common import data_format +from sat.tools.common import uri from wokkel import disco, iwokkel, pubsub from zope.interface import implementer from twisted.internet import defer @@ -134,7 +135,15 @@ pubsub_elt["creator"] = C.BOOL_TRUE if element is not None: pubsub_elt.addChild(element) - item_elt = pubsub.Item(payload=interest_elt) + uri_kwargs = { + "path": service, + "node": node + } + if item_id: + uri_kwargs['id'] = item_id + interest_uri = uri.buildXMPPUri("pubsub", **uri_kwargs) + # we use URI of the interest as item id to avoid duplicates + item_elt = pubsub.Item(interest_uri, payload=interest_elt) yield self._p.publish( client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt] ) @@ -182,7 +191,8 @@ file_sharing_elt["namespace"] = namespace if path is not None: file_sharing_elt["path"] = path - item_elt = pubsub.Item(payload=interest_elt) + item_id = f"{service}_{namespace or ''}_{path or ''}" + item_elt = pubsub.Item(item_id, payload=interest_elt) await self._p.publish( client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt] )