Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_invitation_file.py @ 2931:b256e90612d0
plugins invitation*, events: added an extra parameter and use it to keep a thumnail URL
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 03 May 2019 13:05:01 +0200 |
parents | adf6e33a3e50 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2930:32b6893240e0 | 2931:b256e90612d0 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.core.log import getLogger | 22 from sat.core.log import getLogger |
23 from sat.tools.common import data_format | |
23 from twisted.words.protocols.jabber import jid | 24 from twisted.words.protocols.jabber import jid |
24 | 25 |
25 log = getLogger(__name__) | 26 log = getLogger(__name__) |
26 | 27 |
27 | 28 |
46 ns_fis = host.getNamespace(u"fis") | 47 ns_fis = host.getNamespace(u"fis") |
47 host.plugins[u"INVITATION"].registerNamespace(ns_fis, self.onInvitation) | 48 host.plugins[u"INVITATION"].registerNamespace(ns_fis, self.onInvitation) |
48 host.bridge.addMethod( | 49 host.bridge.addMethod( |
49 "FISInvite", | 50 "FISInvite", |
50 ".plugin", | 51 ".plugin", |
51 in_sign="sssssss", | 52 in_sign="ssssssss", |
52 out_sign="", | 53 out_sign="", |
53 method=self._sendFileSharingInvitation, | 54 method=self._sendFileSharingInvitation, |
54 ) | 55 ) |
55 | 56 |
56 def _sendFileSharingInvitation( | 57 def _sendFileSharingInvitation( |
57 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, | 58 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, |
58 name=None, profile_key=C.PROF_KEY_NONE): | 59 name=None, extra_s=u'', profile_key=C.PROF_KEY_NONE): |
59 client = self.host.getClient(profile_key) | 60 client = self.host.getClient(profile_key) |
60 invitee_jid = jid.JID(invitee_jid_s) | 61 invitee_jid = jid.JID(invitee_jid_s) |
61 service = jid.JID(service_s) | 62 service = jid.JID(service_s) |
63 extra = data_format.deserialise(extra_s) | |
62 return self.host.plugins[u"INVITATION"].sendFileSharingInvitation( | 64 return self.host.plugins[u"INVITATION"].sendFileSharingInvitation( |
63 client, invitee_jid, service, repos_type=None, namespace=None, path=None, | 65 client, invitee_jid, service, repos_type=repos_type or None, |
64 name=None) | 66 namespace=namespace or None, path=path or None, name=name or None, |
67 extra=extra) | |
65 | 68 |
66 def onInvitation(self, client, service, repos_type, namespace, path, name): | 69 def onInvitation(self, client, name, extra, service, repos_type, namespace, path): |
67 if repos_type == u"files": | 70 if repos_type == u"files": |
68 type_human = _(u"file sharing") | 71 type_human = _(u"file sharing") |
69 elif repos_type == u"photos": | 72 elif repos_type == u"photos": |
70 type_human = _(u"photos album") | 73 type_human = _(u"photos album") |
71 else: | 74 else: |
77 u'{profile} has received an invitation for a files repository ({type_human}) ' | 80 u'{profile} has received an invitation for a files repository ({type_human}) ' |
78 u'with namespace "{namespace}" at path [{path}]').format( | 81 u'with namespace "{namespace}" at path [{path}]').format( |
79 profile=client.profile, type_human=type_human, namespace=namespace, path=path) | 82 profile=client.profile, type_human=type_human, namespace=namespace, path=path) |
80 ) | 83 ) |
81 return self.host.plugins[u'LIST_INTEREST'].registerFileSharing( | 84 return self.host.plugins[u'LIST_INTEREST'].registerFileSharing( |
82 client, service, repos_type, namespace, path, name) | 85 client, service, repos_type, namespace, path, name, extra) |