Skip to content

Commit

Permalink
Merge pull request #501 from slackapi/fix-attachment-flattening
Browse files Browse the repository at this point in the history
Fix attachment flattening inside buildText
  • Loading branch information
aoberoi authored Jul 3, 2018
2 parents b030cf2 + b21503e commit 5bad3b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class SlackTextMessage extends TextMessage

# flatten any attachments into text
if @rawMessage.attachments
attachment_text = @rawMessage.attachments.map(a -> a.fallback).join("\n")
attachment_text = @rawMessage.attachments.map((a) -> a.fallback).join("\n")
text = text + "\n" + attachment_text

# Replace links in text async to fetch user and channel info (if present)
Expand Down
11 changes: 11 additions & 0 deletions test/message.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ describe 'buildText()', ->
message.buildText @client, () ->
client.robot.logger.logs?.error.length.should.equal 1

it 'Should flatten attachments', ->
message = @slacktextmessage
client = @client
message.rawMessage.text = 'foo bar'
message.rawMessage.attachments = [
{ fallback: 'first' },
{ fallback: 'second' }
]
message.buildText @client, () ->
message.text.should.equal 'foo bar\nfirst\nsecond'


describe 'replaceLinks()', ->

Expand Down

0 comments on commit 5bad3b3

Please sign in to comment.