Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_invitation_file.py @ 3462:12dc234f698c
plugin invitation: pubsub invitations:
- new Pubsub invitation plugin, to have a generic way to manage invitation on Pubsub based
features
- `invitePreflight` and `onInvitationPreflight` method can be implemented to customise
invitation for a namespace
- refactored events invitations to use the new plugin
- a Pubsub invitation can now be for a whole node instead of a specific item
- if invitation is for a node, a namespace can be specified to indicate what this node is
about. It is then added in `extra` data
- an element (domish.Element) can be added in `extra` data, it will then be added in the
invitation
- some code modernisation
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Feb 2021 15:50:22 +0100 |
parents | b57b5e42e894 |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3461:02a8d227d5bb | 3462:12dc234f698c |
---|---|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | 18 |
19 from sat.core.i18n import _ | 19 from sat.core.i18n import _ |
20 from sat.core.constants import Const as C | 20 from sat.core.constants import Const as C |
21 from sat.core.log import getLogger | 21 from sat.core.log import getLogger |
22 from sat.core.xmpp import SatXMPPEntity | |
22 from sat.tools.common import data_format | 23 from sat.tools.common import data_format |
23 from twisted.internet import defer | 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__) |
67 client, invitee_jid, service, repos_type=repos_type or None, | 68 client, invitee_jid, service, repos_type=repos_type or None, |
68 namespace=namespace or None, path=path or None, name=name or None, | 69 namespace=namespace or None, path=path or None, name=name or None, |
69 extra=extra) | 70 extra=extra) |
70 ) | 71 ) |
71 | 72 |
72 def onInvitation(self, client, name, extra, service, repos_type, namespace, path): | 73 def onInvitation( |
74 self, | |
75 client: SatXMPPEntity, | |
76 namespace: str, | |
77 name: str, | |
78 extra: dict, | |
79 service: jid.JID, | |
80 repos_type: str, | |
81 sharing_ns: str, | |
82 path: str | |
83 ): | |
73 if repos_type == "files": | 84 if repos_type == "files": |
74 type_human = _("file sharing") | 85 type_human = _("file sharing") |
75 elif repos_type == "photos": | 86 elif repos_type == "photos": |
76 type_human = _("photo album") | 87 type_human = _("photo album") |
77 else: | 88 else: |
79 repos_type=repos_type)) | 90 repos_type=repos_type)) |
80 repos_type = "file" | 91 repos_type = "file" |
81 type_human = _("file sharing") | 92 type_human = _("file sharing") |
82 log.info(_( | 93 log.info(_( |
83 '{profile} has received an invitation for a files repository ({type_human}) ' | 94 '{profile} has received an invitation for a files repository ({type_human}) ' |
84 'with namespace {namespace!r} at path [{path}]').format( | 95 'with namespace {sharing_ns!r} at path [{path}]').format( |
85 profile=client.profile, type_human=type_human, namespace=namespace, path=path) | 96 profile=client.profile, type_human=type_human, sharing_ns=sharing_ns, |
97 path=path) | |
86 ) | 98 ) |
87 return defer.ensureDeferred( | 99 return defer.ensureDeferred( |
88 self.host.plugins['LIST_INTEREST'].registerFileSharing( | 100 self.host.plugins['LIST_INTEREST'].registerFileSharing( |
89 client, service, repos_type, namespace, path, name, extra | 101 client, service, repos_type, sharing_ns, path, name, extra |
90 ) | 102 ) |
91 ) | 103 ) |