Skip to content
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
27 changes: 7 additions & 20 deletions slack_sdk/web/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,7 @@ async def files_upload_v2(
# To upload multiple files at a time
file_uploads: Optional[List[Dict[str, Any]]] = None,
channel: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
request_file_info: bool = True, # since v3.23, this flag is no longer necessary
Expand All @@ -3778,20 +3779,8 @@ async def files_upload_v2(
raise e.SlackRequestError("You cannot specify both the file and the content argument.")

# deprecated arguments:
channels, filetype = kwargs.get("channels"), kwargs.get("filetype")
filetype = kwargs.get("filetype")

if channels is not None:
warnings.warn(
"Although the channels parameter is still supported for smooth migration from legacy files.upload, "
"we recommend using the new channel parameter with a single str value instead for more clarity."
)
if (isinstance(channels, (list, tuple)) and len(channels) > 1) or (
isinstance(channels, str) and len(channels.split(",")) > 1
):
raise e.SlackRequestError(
"Sharing files with multiple channels is no longer supported in v2. "
"Share files in each channel separately instead."
)
if filetype is not None:
warnings.warn("The filetype parameter is no longer supported. Please remove it from the arguments.")

Expand Down Expand Up @@ -3845,15 +3834,10 @@ async def files_upload_v2(
raise e.SlackRequestError(message)

# step3: files.completeUploadExternal with all the sets of (file_id + title)
channel_to_share = channel
if channels is not None:
if isinstance(channels, str):
channel_to_share = channels.split(",")[0]
else:
channel_to_share = channels[0]
completion = await self.files_completeUploadExternal(
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
channel_id=channel_to_share,
channel_id=channel,
channels=channels,
initial_comment=initial_comment,
thread_ts=thread_ts,
**kwargs,
Expand Down Expand Up @@ -3889,6 +3873,7 @@ async def files_completeUploadExternal(
*,
files: List[Dict[str, str]],
channel_id: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
**kwargs,
Expand All @@ -3905,6 +3890,8 @@ async def files_completeUploadExternal(
"thread_ts": thread_ts,
}
)
if channels:
kwargs["channels"] = ",".join(channels)
return await self.api_call("files.completeUploadExternal", params=kwargs)

async def functions_completeSuccess(
Expand Down
27 changes: 7 additions & 20 deletions slack_sdk/web/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3747,6 +3747,7 @@ def files_upload_v2(
# To upload multiple files at a time
file_uploads: Optional[List[Dict[str, Any]]] = None,
channel: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
request_file_info: bool = True, # since v3.23, this flag is no longer necessary
Expand All @@ -3768,20 +3769,8 @@ def files_upload_v2(
raise e.SlackRequestError("You cannot specify both the file and the content argument.")

# deprecated arguments:
channels, filetype = kwargs.get("channels"), kwargs.get("filetype")
filetype = kwargs.get("filetype")

if channels is not None:
warnings.warn(
"Although the channels parameter is still supported for smooth migration from legacy files.upload, "
"we recommend using the new channel parameter with a single str value instead for more clarity."
)
if (isinstance(channels, (list, tuple)) and len(channels) > 1) or (
isinstance(channels, str) and len(channels.split(",")) > 1
):
raise e.SlackRequestError(
"Sharing files with multiple channels is no longer supported in v2. "
"Share files in each channel separately instead."
)
if filetype is not None:
warnings.warn("The filetype parameter is no longer supported. Please remove it from the arguments.")

Expand Down Expand Up @@ -3835,15 +3824,10 @@ def files_upload_v2(
raise e.SlackRequestError(message)

# step3: files.completeUploadExternal with all the sets of (file_id + title)
channel_to_share = channel
if channels is not None:
if isinstance(channels, str):
channel_to_share = channels.split(",")[0]
else:
channel_to_share = channels[0]
completion = self.files_completeUploadExternal(
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
channel_id=channel_to_share,
channel_id=channel,
channels=channels,
initial_comment=initial_comment,
thread_ts=thread_ts,
**kwargs,
Expand Down Expand Up @@ -3879,6 +3863,7 @@ def files_completeUploadExternal(
*,
files: List[Dict[str, str]],
channel_id: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
**kwargs,
Expand All @@ -3895,6 +3880,8 @@ def files_completeUploadExternal(
"thread_ts": thread_ts,
}
)
if channels:
kwargs["channels"] = ",".join(channels)
return self.api_call("files.completeUploadExternal", params=kwargs)

def functions_completeSuccess(
Expand Down
27 changes: 7 additions & 20 deletions slack_sdk/web/legacy_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3759,6 +3759,7 @@ def files_upload_v2(
# To upload multiple files at a time
file_uploads: Optional[List[Dict[str, Any]]] = None,
channel: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
request_file_info: bool = True, # since v3.23, this flag is no longer necessary
Expand All @@ -3780,20 +3781,8 @@ def files_upload_v2(
raise e.SlackRequestError("You cannot specify both the file and the content argument.")

# deprecated arguments:
channels, filetype = kwargs.get("channels"), kwargs.get("filetype")
filetype = kwargs.get("filetype")

if channels is not None:
warnings.warn(
"Although the channels parameter is still supported for smooth migration from legacy files.upload, "
"we recommend using the new channel parameter with a single str value instead for more clarity."
)
if (isinstance(channels, (list, tuple)) and len(channels) > 1) or (
isinstance(channels, str) and len(channels.split(",")) > 1
):
raise e.SlackRequestError(
"Sharing files with multiple channels is no longer supported in v2. "
"Share files in each channel separately instead."
)
if filetype is not None:
warnings.warn("The filetype parameter is no longer supported. Please remove it from the arguments.")

Expand Down Expand Up @@ -3847,15 +3836,10 @@ def files_upload_v2(
raise e.SlackRequestError(message)

# step3: files.completeUploadExternal with all the sets of (file_id + title)
channel_to_share = channel
if channels is not None:
if isinstance(channels, str):
channel_to_share = channels.split(",")[0]
else:
channel_to_share = channels[0]
completion = self.files_completeUploadExternal(
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
channel_id=channel_to_share,
channel_id=channel,
channels=channels,
initial_comment=initial_comment,
thread_ts=thread_ts,
**kwargs,
Expand Down Expand Up @@ -3891,6 +3875,7 @@ def files_completeUploadExternal(
*,
files: List[Dict[str, str]],
channel_id: Optional[str] = None,
channels: Optional[List[str]] = None,
initial_comment: Optional[str] = None,
thread_ts: Optional[str] = None,
**kwargs,
Expand All @@ -3907,6 +3892,8 @@ def files_completeUploadExternal(
"thread_ts": thread_ts,
}
)
if channels:
kwargs["channels"] = ",".join(channels)
return self.api_call("files.completeUploadExternal", params=kwargs)

def functions_completeSuccess(
Expand Down