aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorEric Wang <ericwang@tuta.io>2019-03-18 22:07:16 -0700
committerTrygve Aaberge <trygveaa@gmail.com>2019-03-26 17:05:33 +0100
commite3db8e6f9966d1205e0e194cac0b7421d5006ebd (patch)
treec805c55673d829e16cd3c950b4670ce77d47b319 /wee_slack.py
parent55dfe7442183912339d5e08740a133fd333268b2 (diff)
downloadwee-slack-e3db8e6f9966d1205e0e194cac0b7421d5006ebd.tar.gz
Upload file to thread instead of channel when in thread buffer
Currently files are always uploaded to the main channel, even when `/slack upload` is run in a thread buffer. This happens because the `thread_ts` field isn't included in the upload request. Fixes #672
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 0efc7b0..a22c89e 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3822,8 +3822,18 @@ def command_upload(data, current_buffer, args):
# only http proxy is currenlty supported
proxy = ProxyWrapper()
proxy_string = proxy.curl()
- command = 'curl -F file=@{} -F channels={} -F token={} {} {}'.format(
- file_path, channel.identifier, channel.team.token, proxy_string, url)
+
+ form_fields = {
+ 'file': '@' + file_path,
+ 'channels': channel.identifier,
+ 'token': channel.team.token,
+ }
+ if isinstance(channel, SlackThreadChannel):
+ form_fields['thread_ts'] = channel.parent_message.ts
+
+ curl_options = ' '.join(
+ '-F {}={}'.format(*field) for field in form_fields.iteritems())
+ command = 'curl {} {} {}'.format(curl_options, proxy_string, url)
w.hook_process(command, config.slack_timeout, '', '')
return w.WEECHAT_RC_OK_EAT