changeset 2916:0b9faea5cb58

jp (file/share): added invite command to invite an entity to a file sharing repository
author Goffi <goffi@goffi.org>
date Sun, 14 Apr 2019 08:21:51 +0200
parents d1fcb8e9aced
children adf6e33a3e50
files sat_frontends/jp/cmd_file.py
diffstat 1 files changed, 72 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_file.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat_frontends/jp/cmd_file.py	Sun Apr 14 08:21:51 2019 +0200
@@ -701,8 +701,79 @@
         )
 
 
+class ShareInvite(base.CommandBase):
+    def __init__(self, host):
+        super(ShareInvite, self).__init__(
+            host, "invite", help=_(u"send invitation for a shared repository")
+        )
+        self.need_loop = True
+
+    def add_parser_options(self):
+        self.parser.add_argument(
+            "-n",
+            "--name",
+            type=base.unicode_decoder,
+            default=u"",
+            help=_(u"name of the repository"),
+        )
+        self.parser.add_argument(
+            "-N",
+            "--namespace",
+            type=base.unicode_decoder,
+            default=u"",
+            help=_(u"namespace of the repository"),
+        )
+        self.parser.add_argument(
+            "-P",
+            "--path",
+            type=base.unicode_decoder,
+            help=_(u"path to the repository"),
+        )
+        self.parser.add_argument(
+            "-t",
+            "--type",
+            choices=[u"files", u"photos"],
+            default=u"files",
+            help=_(u"type of the repository"),
+        )
+        self.parser.add_argument(
+            "service",
+            type=base.unicode_decoder,
+            help=_(u"jid of the file sharing service hosting the repository"),
+        )
+        self.parser.add_argument(
+            "jid",
+            type=base.unicode_decoder,
+            help=_(u"jid of the person to invite"),
+        )
+
+    def _FISInviteCb(self):
+        self.disp(
+            _(u'invitation sent do {entity}').format(entity=self.args.jid)
+        )
+        self.host.quit()
+
+    def start(self):
+        self.path = os.path.abspath(self.args.path) if self.args.path else u""
+        self.host.bridge.FISInvite(
+            self.args.jid,
+            self.args.service,
+            self.args.type,
+            self.args.namespace,
+            self.path,
+            self.args.name,
+            self.profile,
+            callback=self._FISInviteCb,
+            errback=partial(
+                self.errback,
+                msg=_(u"can't send invitation: {}"),
+                exit_code=C.EXIT_BRIDGE_ERRBACK,
+            ),
+        )
+
+
 class Share(base.CommandBase):
-    subcommands = (ShareList, SharePath)
+    subcommands = (ShareList, SharePath, ShareInvite)
 
     def __init__(self, host):
         super(Share, self).__init__(