aboutsummaryrefslogtreecommitdiffstats
path: root/slack/slack_message.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2024-01-08 21:54:11 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2024-02-18 11:32:55 +0100
commit749f38551d5fc8db233aba12c5ca0bf505180ea1 (patch)
tree36ab795f60530d49a50019724938c27f07d71b0e /slack/slack_message.py
parentca8dd313500a037412e023573f6ee77f84ece694 (diff)
downloadwee-slack-749f38551d5fc8db233aba12c5ca0bf505180ea1.tar.gz
Unescape file titles
Also mark a lot of fields as NotRequired as tombstone files doesn't have these fields.
Diffstat (limited to 'slack/slack_message.py')
-rw-r--r--slack/slack_message.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/slack/slack_message.py b/slack/slack_message.py
index ade6522..bb35d4e 100644
--- a/slack/slack_message.py
+++ b/slack/slack_message.py
@@ -1123,11 +1123,16 @@ class SlackMessage:
shared.config.color.deleted_message.value,
"(This file was not found)",
)
- elif file.get("mimetype") == "application/vnd.slack-docs":
+ elif (
+ file.get("mimetype") == "application/vnd.slack-docs"
+ and "permalink" in file
+ ):
url = f"{file['permalink']}?origin_team={self.workspace.id}&origin_channel={self.conversation.id}"
- text = format_url(url, file["title"])
- elif file.get("url_private"):
- text = format_url(file["url_private"], file.get("title"))
+ title = unhtmlescape(file.get("title", ""))
+ text = format_url(url, title)
+ elif "url_private" in file:
+ title = unhtmlescape(file.get("title", ""))
+ text = format_url(file["url_private"], title)
else:
error = SlackError(self.workspace, "Unsupported file", file)
uncaught_error = UncaughtError(error)