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
This commit is contained in:
Goffi 2021-02-19 15:50:22 +01:00
commit 795931373a

View file

@ -19,6 +19,7 @@
from sat.core.i18n import _
from sat.core.constants import Const as C
from sat.core.log import getLogger
from sat.core.xmpp import SatXMPPEntity
from sat.tools.common import data_format
from twisted.internet import defer
from twisted.words.protocols.jabber import jid
@ -69,7 +70,17 @@ class FileSharingInvitation:
extra=extra)
)
def onInvitation(self, client, name, extra, service, repos_type, namespace, path):
def onInvitation(
self,
client: SatXMPPEntity,
namespace: str,
name: str,
extra: dict,
service: jid.JID,
repos_type: str,
sharing_ns: str,
path: str
):
if repos_type == "files":
type_human = _("file sharing")
elif repos_type == "photos":
@ -81,11 +92,12 @@ class FileSharingInvitation:
type_human = _("file sharing")
log.info(_(
'{profile} has received an invitation for a files repository ({type_human}) '
'with namespace {namespace!r} at path [{path}]').format(
profile=client.profile, type_human=type_human, namespace=namespace, path=path)
'with namespace {sharing_ns!r} at path [{path}]').format(
profile=client.profile, type_human=type_human, sharing_ns=sharing_ns,
path=path)
)
return defer.ensureDeferred(
self.host.plugins['LIST_INTEREST'].registerFileSharing(
client, service, repos_type, namespace, path, name, extra
client, service, repos_type, sharing_ns, path, name, extra
)
)