mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 05:47:10 +00:00
Fix slack notifications requiring an icon (#40027)
This commit is contained in:
parent
fc1fb0ab7c
commit
da19854520
@ -202,22 +202,23 @@ class SlackNotificationService(BaseNotificationService):
|
|||||||
self, targets, message, title, blocks, username, icon
|
self, targets, message, title, blocks, username, icon
|
||||||
):
|
):
|
||||||
"""Send a text-only message."""
|
"""Send a text-only message."""
|
||||||
if self._icon.lower().startswith(("http://", "https://")):
|
message_dict = {
|
||||||
icon_type = "url"
|
"blocks": blocks,
|
||||||
else:
|
"link_names": True,
|
||||||
icon_type = "emoji"
|
"text": message,
|
||||||
|
"username": username,
|
||||||
|
}
|
||||||
|
|
||||||
|
if self._icon:
|
||||||
|
if self._icon.lower().startswith(("http://", "https://")):
|
||||||
|
icon_type = "url"
|
||||||
|
else:
|
||||||
|
icon_type = "emoji"
|
||||||
|
|
||||||
|
message_dict[f"icon_{icon_type}"] = icon
|
||||||
|
|
||||||
tasks = {
|
tasks = {
|
||||||
target: self._client.chat_postMessage(
|
target: self._client.chat_postMessage(**message_dict, channel=target)
|
||||||
**{
|
|
||||||
"blocks": blocks,
|
|
||||||
"channel": target,
|
|
||||||
"link_names": True,
|
|
||||||
"text": message,
|
|
||||||
"username": username,
|
|
||||||
f"icon_{icon_type}": icon,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
for target in targets
|
for target in targets
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user