diff options
-rw-r--r-- | _pytest/test_unwrap_attachments.py | 15 | ||||
-rw-r--r-- | wee_slack.py | 7 |
2 files changed, 19 insertions, 3 deletions
diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py index ab2172a..1c5fa86 100644 --- a/_pytest/test_unwrap_attachments.py +++ b/_pytest/test_unwrap_attachments.py @@ -64,6 +64,21 @@ import pytest 'input_message': {'attachments': [{ 'title': 'Title', 'text': 'Attachment text', + 'title_link': 'http://link?a=1&b=2', + 'from_url': 'http://link?a=1&b=2', + 'image_url': 'http://link?a=1&b=2', + }]}, + 'input_text_before': "http://link?a=1&b=2", + 'output': "\n".join([ + "", + "Title", + "Attachment text", + ]), + }, + { + 'input_message': {'attachments': [{ + 'title': 'Title', + 'text': 'Attachment text', 'title_link': 'http://link', 'from_url': 'http://link', 'image_url': 'http://link', diff --git a/wee_slack.py b/wee_slack.py index 6ceb435..7424872 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3447,7 +3447,7 @@ def unwrap_attachments(message_json, text_before): t.append(attachment['pretext']) title = attachment.get('title') title_link = attachment.get('title_link', '') - if title_link in text_before_unescaped: + if title_link in text_before or title_link in text_before_unescaped: title_link = '' if title and title_link: t.append('%s%s (%s)' % (prepend_title_text, title, title_link,)) @@ -3456,7 +3456,8 @@ def unwrap_attachments(message_json, text_before): t.append('%s%s' % (prepend_title_text, title,)) prepend_title_text = '' from_url = attachment.get('from_url', '') - if from_url not in text_before_unescaped and from_url != title_link: + if (from_url not in text_before and from_url not in text_before_unescaped + and from_url != title_link): t.append(from_url) atext = attachment.get("text") @@ -3466,7 +3467,7 @@ def unwrap_attachments(message_json, text_before): prepend_title_text = '' image_url = attachment.get('image_url', '') - if (image_url not in text_before_unescaped + if (image_url not in text_before and image_url not in text_before_unescaped and image_url != from_url and image_url != title_link): t.append(image_url) |