You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Passing chat_postMessage attachments=null will cause "Copy Link" in Slack not to unfurl. #250
I was so confused on this one I contacted someone at slack support.
At some point in the last several weeks, we noticed that our Copy Link for messages from from this ruby client would no longer unfurl (create a preview of the original message). This was problematic as we value our previews, and click on a *.slack.com/archive/.... link to see the message (and taking you out of context) isn't a good user experience.
After debugging the output in faraday, I noticed that our attachments was nil but still being added to the request body.
self.SlackClient.chat_postMessage(channel: channel,text: msg,as_user: true,link_names: true,thread_ts: thread_ts,attachments: attachments#passed in as nil)
I believe in the past this wasn't an issue, but in the last several weeks the behaviour has changed. To fix this I just stopped sending the attachments argument if it was nil.
# see keyword_args: https://www.justinweiss.com/articles/fun-with-keyword-arguments/keyword_args={channel: channel,text: msg,as_user: true,link_names: true,}keyword_args[thread_ts]=thread_tsunlessthread_ts.nil?keyword_args[attachments]=attachmentsunlessattachments.nil?self.SlackClient.chat_postMessage(**keyword_args)
I was thinking someone might want to filter out any nil arguments from the request body before sending it out (or throw error)
changed the title [-]Passing chat_postMessage attachments=null will cause "Copy Links" not to unfurl.[/-][+]Passing chat_postMessage attachments=null will cause "Copy Link" in Slack not to unfurl.[/+]on Feb 7, 2019
I attempted to address a similar issue I was having in #239, but Slack ultimately fixed it for me. Take a look at my comments about chat.update and the code I wrote to handle that situation, since passing null for attachments is not the same thing as omitting attachments with chat.update.
Activity
[-]Passing chat_postMessage attachments=null will cause "Copy Links" not to unfurl.[/-][+]Passing chat_postMessage attachments=null will cause "Copy Link" in Slack not to unfurl.[/+]sonjz commentedon Feb 7, 2019
From slack support:
dblock commentedon Feb 7, 2019
Should we add something to this effect to README?
jmanian commentedon Feb 11, 2019
I attempted to address a similar issue I was having in #239, but Slack ultimately fixed it for me. Take a look at my comments about
chat.updateand the code I wrote to handle that situation, since passingnullforattachmentsis not the same thing as omittingattachmentswithchat.update.