fix for a bug introduced with media support in #8282 (#8513)

data may be None if twitter data property unconfigured:
  File "/opt/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/notify/twitter.py", line 63, in send_message
    media = data.get(ATTR_MEDIA)
pull/8413/merge
Mike Christianson 2017-07-17 10:45:42 -07:00 committed by Fabian Affolter
parent 1a1571cd52
commit c67c20f752
1 changed files with 7 additions and 4 deletions

View File

@ -60,10 +60,13 @@ class TwitterNotificationService(BaseNotificationService):
def send_message(self, message="", **kwargs):
"""Tweet a message, optionally with media."""
data = kwargs.get(ATTR_DATA)
media = data.get(ATTR_MEDIA)
if not self.hass.config.is_allowed_path(media):
_LOGGER.warning("'%s' is not in a whitelisted area.", media)
return
media = None
if data:
media = data.get(ATTR_MEDIA)
if not self.hass.config.is_allowed_path(media):
_LOGGER.warning("'%s' is not in a whitelisted area.", media)
return
media_id = self.upload_media(media)