comparison sat/plugins/plugin_exp_invitation_file.py @ 3324:b57b5e42e894

plugins invitation, invitation-file: adapt service JID and affiliation: if the user part of the service is missing while creating and invitation, it's added because using only the domain will lead to a different repository depending on the requester. In addition, the invitee is added to the repostiroy path as a member, to be sure he/she can access it.
author Goffi <goffi@goffi.org>
date Sat, 01 Aug 2020 16:24:03 +0200
parents 5887fb414758
children 12dc234f698c
comparison
equal deleted inserted replaced
3323:44a9438d6608 3324:b57b5e42e894
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 2
3 3 # SàT plugin to send invitations for file sharing
4 # SAT plugin to detect language (experimental)
5 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) 4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
6 5
7 # This program is free software: you can redistribute it and/or modify 6 # 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 7 # 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 8 # the Free Software Foundation, either version 3 of the License, or
38 C.PI_HANDLER: "no", 37 C.PI_HANDLER: "no",
39 C.PI_DESCRIPTION: _("Experimental handling of invitations for file sharing"), 38 C.PI_DESCRIPTION: _("Experimental handling of invitations for file sharing"),
40 } 39 }
41 40
42 41
43 class FileSharingInvitation(object): 42 class FileSharingInvitation:
44 43
45 def __init__(self, host): 44 def __init__(self, host):
46 log.info(_("File Sharing Invitation plugin initialization")) 45 log.info(_("File Sharing Invitation plugin initialization"))
47 self.host = host 46 self.host = host
48 ns_fis = host.getNamespace("fis") 47 ns_fis = host.getNamespace("fis")
51 "FISInvite", 50 "FISInvite",
52 ".plugin", 51 ".plugin",
53 in_sign="ssssssss", 52 in_sign="ssssssss",
54 out_sign="", 53 out_sign="",
55 method=self._sendFileSharingInvitation, 54 method=self._sendFileSharingInvitation,
55 async_=True
56 ) 56 )
57 57
58 def _sendFileSharingInvitation( 58 def _sendFileSharingInvitation(
59 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, 59 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None,
60 name=None, extra_s='', profile_key=C.PROF_KEY_NONE): 60 name=None, extra_s='', profile_key=C.PROF_KEY_NONE):
61 client = self.host.getClient(profile_key) 61 client = self.host.getClient(profile_key)
62 invitee_jid = jid.JID(invitee_jid_s) 62 invitee_jid = jid.JID(invitee_jid_s)
63 service = jid.JID(service_s) 63 service = jid.JID(service_s)
64 extra = data_format.deserialise(extra_s) 64 extra = data_format.deserialise(extra_s)
65 return self.host.plugins["INVITATION"].sendFileSharingInvitation( 65 return defer.ensureDeferred(
66 client, invitee_jid, service, repos_type=repos_type or None, 66 self.host.plugins["INVITATION"].sendFileSharingInvitation(
67 namespace=namespace or None, path=path or None, name=name or None, 67 client, invitee_jid, service, repos_type=repos_type or None,
68 extra=extra) 68 namespace=namespace or None, path=path or None, name=name or None,
69 extra=extra)
70 )
69 71
70 def onInvitation(self, client, name, extra, service, repos_type, namespace, path): 72 def onInvitation(self, client, name, extra, service, repos_type, namespace, path):
71 if repos_type == "files": 73 if repos_type == "files":
72 type_human = _("file sharing") 74 type_human = _("file sharing")
73 elif repos_type == "photos": 75 elif repos_type == "photos":