From 53e162c922b913fe40205f17cb524122a7138e29 Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 3 Aug 2020 11:33:49 -0600 Subject: [PATCH] Remove deprecated Slack attachments framework (#38139) --- homeassistant/components/slack/notify.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/slack/notify.py b/homeassistant/components/slack/notify.py index b7f3d81feb0..d5c784398cf 100644 --- a/homeassistant/components/slack/notify.py +++ b/homeassistant/components/slack/notify.py @@ -24,7 +24,6 @@ import homeassistant.helpers.template as template _LOGGER = logging.getLogger(__name__) -ATTR_ATTACHMENTS = "attachments" ATTR_BLOCKS = "blocks" ATTR_BLOCKS_TEMPLATE = "blocks_template" ATTR_FILE = "file" @@ -52,11 +51,7 @@ DATA_FILE_SCHEMA = vol.Schema( ) DATA_TEXT_ONLY_SCHEMA = vol.Schema( - { - vol.Optional(ATTR_ATTACHMENTS): list, - vol.Optional(ATTR_BLOCKS): list, - vol.Optional(ATTR_BLOCKS_TEMPLATE): list, - } + {vol.Optional(ATTR_BLOCKS): list, vol.Optional(ATTR_BLOCKS_TEMPLATE): list} ) DATA_SCHEMA = vol.All( @@ -196,15 +191,12 @@ class SlackNotificationService(BaseNotificationService): except ClientError as err: _LOGGER.error("Error while uploading file message: %s", err) - async def _async_send_text_only_message( - self, targets, message, title, attachments, blocks - ): + async def _async_send_text_only_message(self, targets, message, title, blocks): """Send a text-only message.""" tasks = { target: self._client.chat_postMessage( channel=target, text=message, - attachments=attachments, blocks=blocks, icon_emoji=self._icon, link_names=True, @@ -242,15 +234,6 @@ class SlackNotificationService(BaseNotificationService): # Message Type 1: A text-only message if ATTR_FILE not in data: - attachments = data.get(ATTR_ATTACHMENTS, {}) - if attachments: - _LOGGER.warning( - "Attachments are deprecated and part of Slack's legacy API; " - "support for them will be dropped in 0.114.0. In most cases, " - "Blocks should be used instead: " - "https://www.home-assistant.io/integrations/slack/" - ) - if ATTR_BLOCKS_TEMPLATE in data: blocks = _async_templatize_blocks(self.hass, data[ATTR_BLOCKS_TEMPLATE]) elif ATTR_BLOCKS in data: @@ -259,7 +242,7 @@ class SlackNotificationService(BaseNotificationService): blocks = {} return await self._async_send_text_only_message( - targets, message, title, attachments, blocks + targets, message, title, blocks ) # Message Type 2: A message that uploads a remote file