comparison sat/plugins/plugin_exp_invitation_file.py @ 3299:83795ff8a633

plugin list of interest: expose `interestsRegisterFileSharing` to bridge + use coroutines
author Goffi <goffi@goffi.org>
date Tue, 09 Jun 2020 06:25:20 +0200
parents 559a625a236b
children 5887fb414758
comparison
equal deleted inserted replaced
3298:d0e8b0a3ef9c 3299:83795ff8a633
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 sat.tools.common import data_format
24 from twisted.internet import defer
24 from twisted.words.protocols.jabber import jid 25 from twisted.words.protocols.jabber import jid
25 26
26 log = getLogger(__name__) 27 log = getLogger(__name__)
27 28
28 29
68 69
69 def onInvitation(self, client, name, extra, service, repos_type, namespace, path): 70 def onInvitation(self, client, name, extra, service, repos_type, namespace, path):
70 if repos_type == "files": 71 if repos_type == "files":
71 type_human = _("file sharing") 72 type_human = _("file sharing")
72 elif repos_type == "photos": 73 elif repos_type == "photos":
73 type_human = _("photos album") 74 type_human = _("photo album")
74 else: 75 else:
75 log.warning("Unknown repository type: {repos_type}".format( 76 log.warning("Unknown repository type: {repos_type}".format(
76 repos_type=repos_type)) 77 repos_type=repos_type))
77 repos_type = "file" 78 repos_type = "file"
78 type_human = _("file sharing") 79 type_human = _("file sharing")
79 log.info(_( 80 log.info(_(
80 '{profile} has received an invitation for a files repository ({type_human}) ' 81 '{profile} has received an invitation for a files repository ({type_human}) '
81 'with namespace "{namespace}" at path [{path}]').format( 82 'with namespace "{namespace}" at path [{path}]').format(
82 profile=client.profile, type_human=type_human, namespace=namespace, path=path) 83 profile=client.profile, type_human=type_human, namespace=namespace, path=path)
83 ) 84 )
84 return self.host.plugins['LIST_INTEREST'].registerFileSharing( 85 return defer.ensureDeferred(
85 client, service, repos_type, namespace, path, name, extra) 86 self.host.plugins['LIST_INTEREST'].registerFileSharing(
87 client, service, repos_type, namespace, path, name, extra
88 )
89 )