Pass though file_url from extended data attrs (#17801)
* pass though file_url from extended data attrs so synology chat bot can send files * some code cleanuppull/18095/head
parent
a69c3953f1
commit
afc109a585
|
@ -11,10 +11,11 @@ import requests
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.notify import (
|
||||
BaseNotificationService, PLATFORM_SCHEMA)
|
||||
BaseNotificationService, PLATFORM_SCHEMA, ATTR_DATA)
|
||||
from homeassistant.const import CONF_RESOURCE
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
ATTR_FILE_URL = 'file_url'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_RESOURCE): cv.url,
|
||||
|
@ -43,6 +44,12 @@ class SynologyChatNotificationService(BaseNotificationService):
|
|||
'text': message
|
||||
}
|
||||
|
||||
extended_data = kwargs.get(ATTR_DATA)
|
||||
file_url = extended_data.get(ATTR_FILE_URL) if extended_data else None
|
||||
|
||||
if file_url:
|
||||
data['file_url'] = file_url
|
||||
|
||||
to_send = 'payload={}'.format(json.dumps(data))
|
||||
|
||||
response = requests.post(self._resource, data=to_send, timeout=10)
|
||||
|
|
Loading…
Reference in New Issue