diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-03-26 21:53:35 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-04-05 20:22:46 +0200 |
commit | 2877fa65958921c4b8dcf6caef11c60083495574 (patch) | |
tree | 69995c2fbd2ec5114a7db07d4193a6d6d7973c17 | |
parent | 5dfba738a85d3065de0275ae3a0ed607d1fe3788 (diff) | |
download | wee-slack-2877fa65958921c4b8dcf6caef11c60083495574.tar.gz |
Don't print image_url if it's equal to from_url
-rw-r--r-- | _pytest/test_unwrap_attachments.py | 16 | ||||
-rw-r--r-- | wee_slack.py | 3 |
2 files changed, 18 insertions, 1 deletions
diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py index 89436af..ab2172a 100644 --- a/_pytest/test_unwrap_attachments.py +++ b/_pytest/test_unwrap_attachments.py @@ -51,6 +51,7 @@ import pytest '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([ @@ -65,6 +66,7 @@ import pytest 'text': 'Attachment text', 'title_link': 'http://link', 'from_url': 'http://link', + 'image_url': 'http://link', }]}, 'input_text_before': "", 'output': "\n".join([ @@ -75,6 +77,20 @@ import pytest { 'input_message': {'attachments': [{ 'title': 'Title', + 'text': 'Attachment text', + 'from_url': 'http://link', + 'image_url': 'http://link', + }]}, + 'input_text_before': "", + 'output': "\n".join([ + "Title", + "http://link", + "Attachment text", + ]), + }, + { + 'input_message': {'attachments': [{ + 'title': 'Title', 'text': 'Attachment text\n\n\nWith multiple lines', }]}, 'input_text_before': "", diff --git a/wee_slack.py b/wee_slack.py index 9dd7d3a..6ceb435 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -3466,7 +3466,8 @@ def unwrap_attachments(message_json, text_before): prepend_title_text = '' image_url = attachment.get('image_url', '') - if image_url not in text_before_unescaped and image_url != title_link: + if (image_url not in text_before_unescaped + and image_url != from_url and image_url != title_link): t.append(image_url) fields = attachment.get("fields") |