# HG changeset patch # User Goffi # Date 1555222911 -7200 # Node ID 0b9faea5cb584aa244f308f96272c00ba93502d9 # Parent d1fcb8e9aced0d5bbb0e989c2f93809057e57102 jp (file/share): added invite command to invite an entity to a file sharing repository diff -r d1fcb8e9aced -r 0b9faea5cb58 sat_frontends/jp/cmd_file.py --- 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__(