Mercurial > libervia-backend
diff sat/plugins/plugin_exp_list_of_interest.py @ 2913:672e6be3290f
plugins sharing invitation, invitation, list of interest: handle invitation to a file sharing repository
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 14 Apr 2019 08:21:51 +0200 |
parents | a3faf1c86596 |
children | 47df940738a7 |
line wrap: on
line diff
--- a/sat/plugins/plugin_exp_list_of_interest.py Sun Apr 14 08:21:51 2019 +0200 +++ b/sat/plugins/plugin_exp_list_of_interest.py Sun Apr 14 08:21:51 2019 +0200 @@ -35,7 +35,7 @@ C.PI_IMPORT_NAME: "LIST_INTEREST", C.PI_TYPE: "EXP", C.PI_PROTOCOLS: [], - C.PI_DEPENDENCIES: ["XEP-0060"], + C.PI_DEPENDENCIES: [u"XEP-0060", u"XEP-0329"], C.PI_RECOMMENDATIONS: [], C.PI_MAIN: "ListInterest", C.PI_HANDLER: "yes", @@ -79,7 +79,7 @@ @param namespace(unicode): namespace of the interest this is used as a cache, to avoid the need to retrieve the item only to get its namespace - @param service(jid.JID): pubsub service of the + @param service(jid.JID): target pubsub service @param node(unicode): target pubsub node @param item_id(unicode, None): target pubsub id @param creator(bool): True if client's profile is the creator of the node @@ -108,6 +108,35 @@ ) @defer.inlineCallbacks + def registerFileSharing( + self, client, service, repos_type=None, namespace=None, path=None, name=None): + """Register an interesting file repository in personal list + + @param service(jid.JID): service of the file repository + @param repos_type(unicode): type of the repository + @param namespace(unicode, None): namespace of the repository + @param path(unicode, None): path of the repository + @param name(unicode, None): name of the repository + """ + yield self.createNode(client) + interest_elt = domish.Element((NS_LIST_INTEREST, u"interest")) + interest_elt[u"namespace"] = self.host.getNamespace(u"fis") + if name is not None: + interest_elt[u'name'] = name + file_sharing_elt = interest_elt.addElement(u"file_sharing") + file_sharing_elt[u"service"] = service.full() + if repos_type is not None: + file_sharing_elt[u"type"] = repos_type + if namespace is not None: + file_sharing_elt[u"namespace"] = namespace + if path is not None: + file_sharing_elt[u"path"] = path + item_elt = pubsub.Item(payload=interest_elt) + yield self._p.publish( + client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt] + ) + + @defer.inlineCallbacks def listInterests(self, client, service=None, node=None, namespace=None): """Retrieve list of interests