aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2023-08-25 18:23:10 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2023-08-25 18:23:10 +0200
commit64e1c6fcc13d8eaade4699a3bef778cc1f3094a7 (patch)
treead581a05b417c16711853b54c31db88fe5ca2497
parent24439521d1147a2b5700a6cea0aea310c5dccb61 (diff)
downloadwee-slack-64e1c6fcc13d8eaade4699a3bef778cc1f3094a7.tar.gz
Fix rendering of huddles
After using blocks to render messages in commit 74da303, huddle messages got the text twice since they already used blocks.
-rw-r--r--wee_slack.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/wee_slack.py b/wee_slack.py
index a4cd742..4a69025 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3421,7 +3421,7 @@ class SlackMessage(object):
text += unfurl_refs(unwrap_attachments(self, text))
text += unfurl_refs(unwrap_files(self, self.message_json, text))
- text += unfurl_refs(unwrap_huddle(self, self.message_json))
+ text += unfurl_refs(unwrap_huddle(self, self.message_json, text))
text = unhtmlescape(text.lstrip().replace("\t", " "))
text += create_reactions_string(
@@ -4974,7 +4974,7 @@ def unwrap_attachments(message, text_before):
return "\n".join(attachment_texts)
-def unwrap_huddle(message, message_json):
+def unwrap_huddle(message, message_json, text_before):
"""
If huddle is linked to message, append huddle information and link
to connect.
@@ -4982,11 +4982,6 @@ def unwrap_huddle(message, message_json):
huddle_texts = []
if "room" in message_json:
- for block in message_json.get("blocks"):
- for element in block.get("elements"):
- for element2 in element.get("elements"):
- huddle_texts.append(element2.get("text"))
-
if "name" in message_json.get("room"):
room_name = message_json.get("room").get("name")
@@ -5000,6 +4995,8 @@ def unwrap_huddle(message, message_json):
)
)
+ if text_before:
+ huddle_texts.insert(0, "")
return "\n".join(huddle_texts)