-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
slack: add file upload functionality #9472
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
hi @Powma thanks for your contribution!
Other than fixing the sanity checks, and adding the version in the docs, it LGTM
thread_ts: | ||
type: str | ||
description: | ||
- Optional timestamp of parent message to thread this message, see U(https://api.slack.com/docs/message-threading). |
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.
If it makes the cut today, else we'll have to update the version number
- Optional timestamp of parent message to thread this message, see U(https://api.slack.com/docs/message-threading). | |
- Optional timestamp of parent message to thread this message, see U(https://api.slack.com/docs/message-threading). | |
version_added: 10.2.0 |
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.
Thanks for your contribution!
- See Slack's file upload API for details at U(https://api.slack.com/methods/files.getUploadURLExternal). | ||
- See Slack's file upload API for details at U(https://api.slack.com/methods/files.completeUploadExternal). |
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.
These are two paragraphs with the same text, but different URLs. Either write something like
- See Slack's file upload API for details at U(https://api.slack.com/methods/files.getUploadURLExternal). | |
- See Slack's file upload API for details at U(https://api.slack.com/methods/files.completeUploadExternal). | |
- See Slack's file upload API for details at U(https://api.slack.com/methods/files.getUploadURLExternal) or | |
U(https://api.slack.com/methods/files.completeUploadExternal). |
or adjust the texts.
upload_url_data = json.load(response) | ||
except ValueError: | ||
module.fail_json( | ||
msg="The Slack API response is not valid JSON: %s" % response.read() |
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.
At this point the response has likely already been read. You should read it first and then use the result both to decode JSON and to report the error here, otherwise this reporting here won't work.
type: str | ||
description: | ||
- Optional title for the uploaded file. | ||
thread_ts: |
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.
How does this option relate to the global thread_id
?
|
||
if upload_file: | ||
try: | ||
upload_response = upload_file_to_slack( |
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.
Hmm, this seems to be very separate from the rest of the module. Maybe this should be a new module that only does file uploading, instead of squeezing this into the current module which is about posting messages?
@@ -0,0 +1,2 @@ | |||
minor_changes: | |||
- Slack upload file - feature added support for uploading files to Slack (https://github.com/ansible-collections/community.general/pull/9472). |
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.
- Slack upload file - feature added support for uploading files to Slack (https://github.com/ansible-collections/community.general/pull/9472). | |
- slack - add support for uploading files to Slack (https://github.com/ansible-collections/community.general/pull/9472). |
SUMMARY
Add file upload functionality to upload the files with the new API SLACK.
Continuation of #9431.
ISSUE TYPE
COMPONENT NAME
ADDITIONAL INFORMATION
This enhancement allows you to upload files with the new version of the Slack API
https://api.slack.com/methods/files.completeUploadExternal
https://api.slack.com/methods/files.getUploadURLExternal
Example usage: