diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2024-01-08 21:54:11 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:55 +0100 |
commit | 749f38551d5fc8db233aba12c5ca0bf505180ea1 (patch) | |
tree | 36ab795f60530d49a50019724938c27f07d71b0e /slack/slack_message.py | |
parent | ca8dd313500a037412e023573f6ee77f84ece694 (diff) | |
download | wee-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.py | 13 |
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) |