Skip to content
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

Fix a bug where some of the files.remote API parameters do not work since v3.10 #1173

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions integration_tests/web/test_remote_file_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def test_replacing_remote_file_blocks_in_a_message(self):
external_id=external_id,
external_url=url,
title="Slack Logo",
indexable_file_contents="so many keywords!".encode("utf-8"),
preview_image=f"{current_dir}/../../tests/data/slack_logo.png",
)
self.assertIsNotNone(remote_file_creation)
Expand Down Expand Up @@ -61,6 +62,7 @@ def test_replacing_remote_file_blocks_in_a_message(self):
external_id=external_id,
external_url=url,
title="Slack Logo",
indexable_file_contents="more and more keywords!".encode("utf-8"),
preview_image=f"{current_dir}/../../tests/data/slack_logo_new.png",
)
self.assertIsNotNone(new_version)
Expand Down
18 changes: 6 additions & 12 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2794,14 +2794,10 @@ async def files_remote_add(
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs or "indexable_file_contents" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image"),
"indexable_file_contents": indexable_file_contents
if indexable_file_contents is not None
else kwargs.pop("indexable_file_contents"),
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return await self.api_call(
Expand Down Expand Up @@ -2834,16 +2830,14 @@ async def files_remote_update(
"file": file,
"title": title,
"filetype": filetype,
"indexable_file_contents": indexable_file_contents,
}
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image")
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return await self.api_call(
Expand Down
18 changes: 6 additions & 12 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2739,14 +2739,10 @@ def files_remote_add(
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs or "indexable_file_contents" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image"),
"indexable_file_contents": indexable_file_contents
if indexable_file_contents is not None
else kwargs.pop("indexable_file_contents"),
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return self.api_call(
Expand Down Expand Up @@ -2779,16 +2775,14 @@ def files_remote_update(
"file": file,
"title": title,
"filetype": filetype,
"indexable_file_contents": indexable_file_contents,
}
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image")
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return self.api_call(
Expand Down
18 changes: 6 additions & 12 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2750,14 +2750,10 @@ def files_remote_add(
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs or "indexable_file_contents" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image"),
"indexable_file_contents": indexable_file_contents
if indexable_file_contents is not None
else kwargs.pop("indexable_file_contents"),
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return self.api_call(
Expand Down Expand Up @@ -2790,16 +2786,14 @@ def files_remote_update(
"file": file,
"title": title,
"filetype": filetype,
"indexable_file_contents": indexable_file_contents,
}
)
files = None
# preview_image (file): Preview of the document via multipart/form-data.
if "preview_image" in kwargs:
if preview_image is not None or indexable_file_contents is not None:
files = {
"preview_image": preview_image
if preview_image is not None
else kwargs.pop("preview_image")
"preview_image": preview_image,
"indexable_file_contents": indexable_file_contents,
}

return self.api_call(
Expand Down