diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2017-09-20 23:49:00 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2017-09-20 23:53:09 +0200 |
commit | 4556187df35b6bcbbff310ae68ac2ec4bfd9d8ad (patch) | |
tree | f818fdc3a67cba2f536f969a2daae05f7d165bf1 | |
parent | deb9f11ad36cfebbee5b4f0783108433f67f6b56 (diff) | |
download | wee-slack-4556187df35b6bcbbff310ae68ac2ec4bfd9d8ad.tar.gz |
Don't render equal title_link and from_url in attachments twice
This is a follow-up of commit 0345ba1. That prevented rendering the link
if it already was in the text. This prevents rendering both the
title_link and from_url if they are equal, but not in the text. In this
case it only renders the title_link.
-rw-r--r-- | _pytest/test_unwrap_attachments.py | 13 | ||||
-rw-r--r-- | wee_slack.py | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/_pytest/test_unwrap_attachments.py b/_pytest/test_unwrap_attachments.py index e70256e..8b22515 100644 --- a/_pytest/test_unwrap_attachments.py +++ b/_pytest/test_unwrap_attachments.py @@ -45,6 +45,19 @@ import pytest { 'input_message': {'attachments': [{ 'title': 'Title', + 'text': 'Attachment text', + 'title_link': 'http://link', + 'from_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 90b56ac..950117c 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -2629,7 +2629,7 @@ 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: + if from_url not in text_before and from_url != title_link: t.append(from_url) atext = attachment.get("text", None) |