-
Notifications
You must be signed in to change notification settings - Fork 1.7k
slack: add file upload functionality #9472
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
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
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!
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
?
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.
- name: Send initial message to start a thread
community.general.slack:
token: "{{ slack_token }}"
channel: "#channel"
msg: "first"
register: slack_response
- name: Upload a file in the same thread
community.general.slack:
token: "{{ slack_token }}"
channel: "#channel"
upload_file:
path: "/path/to/README.md"
initial_comment: "blablabla"
alt_text: "My README"
thread_ts: "{{ slack_response.ts }}" # specific to file uploads
In this case, using thread_id globally has no effect on the file upload. It must be passed as thread_ts within the upload_file dictionary. That’s why this option is duplicated.
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.
But - why? Can't you use the global parameter thread_id
for the value of thread_ts
?
|
||
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?
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.
Yeah, but should I create a new file in plugins/module_utils
?
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.
Can we upload a file together with sending a message, as in the same request? If yes, then I would suggest to keep the feature in this module, else create a new module.
As of new file in module_utils, if you end up with two modules, it is likely there will be some common code between them and it would make total sense to put that common code in module_utils. If not, then probably no need to.
ping @Powma Are you still working on this? |
needs_info |
Sorry, I’ll take a look at it next week. I know there’s an IRC channel if I need help. |
docs(slack): unify file upload API links Co-authored-by: Felix Fontein <[email protected]>
docs(slack): unify file upload API links Co-authored-by: Alexei Znamensky <[email protected]>
docs(changelog): improve wording for Slack upload feature Co-authored-by: Felix Fontein <[email protected]>
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
U(https://api.slack.com/methods/files.completeUploadExternal). | ||
suboptions: | ||
path: | ||
type: str |
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.
type: str | |
type: path |
type: str | ||
description: | ||
- 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.
version_added: 10.2.0 | |
version_added: 10.6.0 |
Hi @Powma You are probably busy, but the PR is very close to being good to go, and we're having a release of the collection next week. Do you think you will have time to give it some TLC before that? No pressure, just trying to work on the logistics, there will be other releases in the future. :-) |
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: