aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--_pytest/test_unwrap_attachments.py22
-rw-r--r--wee_slack.py8
2 files changed, 26 insertions, 4 deletions
diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py
index 8b22515..8e41662 100644
--- a/_pytest/test_unwrap_attachments.py
+++ b/_pytest/test_unwrap_attachments.py
@@ -121,6 +121,28 @@ import pytest
"Second field value",
]),
},
+ {
+ 'input_message': {'attachments': [{
+ 'title': 'First attachment title',
+ 'text': 'First attachment text',
+ 'title_link': 'http://title.link.1',
+ 'from_url': 'http://from.url.1',
+ }, {
+ 'title': 'Second attachment title',
+ 'text': 'Second attachment text',
+ 'title_link': 'http://title.link.2',
+ 'from_url': 'http://from.url.2',
+ }]},
+ 'input_text_before': "",
+ 'output': "\n".join([
+ "First attachment title (http://title.link.1)",
+ "http://from.url.1",
+ "First attachment text",
+ "Second attachment title (http://title.link.2)",
+ "http://from.url.2",
+ "Second attachment text",
+ ]),
+ },
))
def test_unwrap_attachments(case):
result = wee_slack.unwrap_attachments(
diff --git a/wee_slack.py b/wee_slack.py
index 950117c..334a8ba 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2600,11 +2600,11 @@ def unhtmlescape(text):
def unwrap_attachments(message_json, text_before):
- attachment_text = ''
+ attachment_texts = []
a = message_json.get("attachments", None)
if a:
if text_before:
- attachment_text = '\n'
+ attachment_texts.append('')
for attachment in a:
# Attachments should be rendered roughly like:
#
@@ -2647,8 +2647,8 @@ def unwrap_attachments(message_json, text_before):
fallback = attachment.get("fallback", None)
if t == [] and fallback:
t.append(fallback)
- attachment_text += "\n".join([x.strip() for x in t if x])
- return attachment_text
+ attachment_texts.append("\n".join([x.strip() for x in t if x]))
+ return "\n".join(attachment_texts)
def resolve_ref(ref):