New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added support for upload of remote or local files to slack #8278
Conversation
@simaosimao, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @Khabi and @balloob to be potential reviewers. |
Hi @simaosimao, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should make a helper function for fileload
|
||
elif local_path is not None: | ||
# load file from local path on server | ||
return open(local_path, "rb") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need check the path with hass.config.is_allowed_path
Hi @pvizeli, thanks for your feedback! Using suggested check now. Had to move the Also had a look at the telegram bot which has a similar method to load a file. We might extract those to a helper function as you mentioned above in a follow up issue 😉 Opened #8291, as |
Awesome 🎉 🌮 🐬 |
Thx 😄 |
…stant#8278) * Added support for upload of remote or local files to slack * Checking local file with hass.config.is_allowed_path prior to posting it
Description:
The notify.slack platform currently supports sending text messages and structured message attachments (see chat.postMessage). This PR's intention is to add support for uploading files either from the local machine/server or from a remote url (See files.upload).
I am using this feature to post security camera still pictures to a slack channel when certain events occur. Might be useful to others...?
Example: Post file or image by url
Use the following service data for notify.slack in order to directly post a remote file:
"auth":"digest"
is optional, too. If omitted basic authentication is used.Example: Post file or image by local path
Use the following service data for notify.slack in order to post local file
Sidenote
This is my first PR (at all) and I am no python developer. I tried to familiarize with applying rules and conventions, running tests etc. Still I might have missed something ... please excuse any mistakes.
Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2949
Checklist:
If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
tox
run successfully. Your PR cannot be merged unless tests pass