Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_invitation_file.py @ 2917:adf6e33a3e50
plugin invitation file: wrong plugin had been uploaded:
this patch remove the test pluging erroneously uploaded, and add the right one instead
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 26 Apr 2019 11:57:26 +0200 |
parents | |
children | b256e90612d0 |
comparison
equal
deleted
inserted
replaced
2916:0b9faea5cb58 | 2917:adf6e33a3e50 |
---|---|
1 #!/usr/bin/env python2 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # SAT plugin to detect language (experimental) | |
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 from sat.core.i18n import _ | |
21 from sat.core.constants import Const as C | |
22 from sat.core.log import getLogger | |
23 from twisted.words.protocols.jabber import jid | |
24 | |
25 log = getLogger(__name__) | |
26 | |
27 | |
28 PLUGIN_INFO = { | |
29 C.PI_NAME: "File Sharing Invitation", | |
30 C.PI_IMPORT_NAME: "FILE_SHARING_INVITATION", | |
31 C.PI_TYPE: "EXP", | |
32 C.PI_PROTOCOLS: [], | |
33 C.PI_DEPENDENCIES: ["XEP-0329", u"INVITATION"], | |
34 C.PI_RECOMMENDATIONS: [], | |
35 C.PI_MAIN: "FileSharingInvitation", | |
36 C.PI_HANDLER: "no", | |
37 C.PI_DESCRIPTION: _(u"Experimental handling of invitations for file sharing"), | |
38 } | |
39 | |
40 | |
41 class FileSharingInvitation(object): | |
42 | |
43 def __init__(self, host): | |
44 log.info(_(u"File Sharing Invitation plugin initialization")) | |
45 self.host = host | |
46 ns_fis = host.getNamespace(u"fis") | |
47 host.plugins[u"INVITATION"].registerNamespace(ns_fis, self.onInvitation) | |
48 host.bridge.addMethod( | |
49 "FISInvite", | |
50 ".plugin", | |
51 in_sign="sssssss", | |
52 out_sign="", | |
53 method=self._sendFileSharingInvitation, | |
54 ) | |
55 | |
56 def _sendFileSharingInvitation( | |
57 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, | |
58 name=None, profile_key=C.PROF_KEY_NONE): | |
59 client = self.host.getClient(profile_key) | |
60 invitee_jid = jid.JID(invitee_jid_s) | |
61 service = jid.JID(service_s) | |
62 return self.host.plugins[u"INVITATION"].sendFileSharingInvitation( | |
63 client, invitee_jid, service, repos_type=None, namespace=None, path=None, | |
64 name=None) | |
65 | |
66 def onInvitation(self, client, service, repos_type, namespace, path, name): | |
67 if repos_type == u"files": | |
68 type_human = _(u"file sharing") | |
69 elif repos_type == u"photos": | |
70 type_human = _(u"photos album") | |
71 else: | |
72 log.warning(u"Unknown repository type: {repos_type}".format( | |
73 repos_type=repos_type)) | |
74 repos_type = u"file" | |
75 type_human = _(u"file sharing") | |
76 log.info(_( | |
77 u'{profile} has received an invitation for a files repository ({type_human}) ' | |
78 u'with namespace "{namespace}" at path [{path}]').format( | |
79 profile=client.profile, type_human=type_human, namespace=namespace, path=path) | |
80 ) | |
81 return self.host.plugins[u'LIST_INTEREST'].registerFileSharing( | |
82 client, service, repos_type, namespace, path, name) |