From bf9284cf06b6007c842496dc5f49d41e1b3841e5 Mon Sep 17 00:00:00 2001 From: Goffi Date: Fri, 3 May 2019 13:05:47 +0200 Subject: [PATCH] jp (file/invite): added a --thumbnail argument --- sat_frontends/jp/cmd_file.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sat_frontends/jp/cmd_file.py b/sat_frontends/jp/cmd_file.py index 74caa8d6..295987b8 100644 --- a/sat_frontends/jp/cmd_file.py +++ b/sat_frontends/jp/cmd_file.py @@ -24,6 +24,7 @@ import os import os.path import tarfile from sat.core.i18n import _ +from sat.tools.common import data_format from sat_frontends.jp.constants import Const as C from sat_frontends.jp import common from sat_frontends.tools import jid @@ -736,6 +737,12 @@ class ShareInvite(base.CommandBase): default=u"files", help=_(u"type of the repository"), ) + self.parser.add_argument( + "-T", + "--thumbnail", + type=base.unicode_decoder, + help=_(u"https URL of a image to use as thumbnail"), + ) self.parser.add_argument( "service", type=base.unicode_decoder, @@ -754,7 +761,13 @@ class ShareInvite(base.CommandBase): self.host.quit() def start(self): - self.path = os.path.abspath(self.args.path) if self.args.path else u"" + self.path = os.path.normpath(self.args.path) if self.args.path else u"" + extra = {} + if self.args.thumbnail is not None: + if not self.args.thumbnail.startswith(u'http'): + self.parser.error(_(u"only http(s) links are allowed with --thumbnail")) + else: + extra[u'thumb_url'] = self.args.thumbnail self.host.bridge.FISInvite( self.args.jid, self.args.service, @@ -762,6 +775,7 @@ class ShareInvite(base.CommandBase): self.args.namespace, self.path, self.args.name, + data_format.serialise(extra), self.profile, callback=self._FISInviteCb, errback=partial(