Improve logging for Discord integration (#68160)

This commit is contained in:
d6e 2022-03-16 13:16:38 -07:00 committed by GitHub
parent d8c966fd0a
commit aa57907c18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,8 +49,12 @@ class DiscordNotificationService(BaseNotificationService):
def file_exists(self, filename):
"""Check if a file exists on disk and is in authorized path."""
if not self.hass.config.is_allowed_path(filename):
_LOGGER.warning("Path not allowed: %s", filename)
return False
return os.path.isfile(filename)
if not os.path.isfile(filename):
_LOGGER.warning("Not a file: %s", filename)
return False
return True
async def async_send_message(self, message, **kwargs):
"""Login to Discord, send message to channel(s) and log out."""
@ -98,8 +102,6 @@ class DiscordNotificationService(BaseNotificationService):
if image_exists:
images.append(image)
else:
_LOGGER.warning("Image not found: %s", image)
await discord_bot.login(self.token)