diff --git a/slack_sdk/web/async_client.py b/slack_sdk/web/async_client.py index 97ab3855b..79293d8b9 100644 --- a/slack_sdk/web/async_client.py +++ b/slack_sdk/web/async_client.py @@ -4036,6 +4036,7 @@ async def files_upload_v2( content: Optional[Union[str, bytes]] = None, title: Optional[str] = None, alt_txt: Optional[str] = None, + highlight_type: Optional[str] = None, snippet_type: Optional[str] = None, # To upload multiple files at a time file_uploads: Optional[List[Dict[str, Any]]] = None, @@ -4080,6 +4081,7 @@ async def files_upload_v2( "content": content, "title": title, "alt_txt": alt_txt, + "highlight_type": highlight_type, "snippet_type": snippet_type, } ) @@ -4118,7 +4120,7 @@ async def files_upload_v2( # step3: files.completeUploadExternal with all the sets of (file_id + title) completion = await self.files_completeUploadExternal( - files=[{"id": f["file_id"], "title": f["title"]} for f in files], + files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files], channel_id=channel, channels=channels, initial_comment=initial_comment, @@ -4154,7 +4156,7 @@ async def files_getUploadURLExternal( async def files_completeUploadExternal( self, *, - files: List[Dict[str, str]], + files: List[Dict[str, Optional[str]]], channel_id: Optional[str] = None, channels: Optional[List[str]] = None, initial_comment: Optional[str] = None, diff --git a/slack_sdk/web/client.py b/slack_sdk/web/client.py index 5339db491..4c597c2df 100644 --- a/slack_sdk/web/client.py +++ b/slack_sdk/web/client.py @@ -4026,6 +4026,7 @@ def files_upload_v2( content: Optional[Union[str, bytes]] = None, title: Optional[str] = None, alt_txt: Optional[str] = None, + highlight_type: Optional[str] = None, snippet_type: Optional[str] = None, # To upload multiple files at a time file_uploads: Optional[List[Dict[str, Any]]] = None, @@ -4070,6 +4071,7 @@ def files_upload_v2( "content": content, "title": title, "alt_txt": alt_txt, + "highlight_type": highlight_type, "snippet_type": snippet_type, } ) @@ -4108,7 +4110,7 @@ def files_upload_v2( # step3: files.completeUploadExternal with all the sets of (file_id + title) completion = self.files_completeUploadExternal( - files=[{"id": f["file_id"], "title": f["title"]} for f in files], + files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files], channel_id=channel, channels=channels, initial_comment=initial_comment, @@ -4144,7 +4146,7 @@ def files_getUploadURLExternal( def files_completeUploadExternal( self, *, - files: List[Dict[str, str]], + files: List[Dict[str, Optional[str]]], channel_id: Optional[str] = None, channels: Optional[List[str]] = None, initial_comment: Optional[str] = None, diff --git a/slack_sdk/web/internal_utils.py b/slack_sdk/web/internal_utils.py index ad23f87f8..cb48d9fa9 100644 --- a/slack_sdk/web/internal_utils.py +++ b/slack_sdk/web/internal_utils.py @@ -378,6 +378,7 @@ def _to_v2_file_upload_item(upload_file: Dict[str, Any]) -> Dict[str, Optional[A "length": len(data), "title": title, "alt_txt": upload_file.get("alt_txt"), + "highlight_type": upload_file.get("highlight_type"), "snippet_type": upload_file.get("snippet_type"), } diff --git a/slack_sdk/web/legacy_client.py b/slack_sdk/web/legacy_client.py index db785bbbc..afc4e4f64 100644 --- a/slack_sdk/web/legacy_client.py +++ b/slack_sdk/web/legacy_client.py @@ -3961,6 +3961,7 @@ def files_upload_v2( content: Optional[Union[str, bytes]] = None, title: Optional[str] = None, alt_txt: Optional[str] = None, + highlight_type: Optional[str] = None, snippet_type: Optional[str] = None, # To upload multiple files at a time file_uploads: Optional[List[Dict[str, Any]]] = None, @@ -4005,6 +4006,7 @@ def files_upload_v2( "content": content, "title": title, "alt_txt": alt_txt, + "highlight_type": highlight_type, "snippet_type": snippet_type, } ) @@ -4043,7 +4045,7 @@ def files_upload_v2( # step3: files.completeUploadExternal with all the sets of (file_id + title) completion = self.files_completeUploadExternal( - files=[{"id": f["file_id"], "title": f["title"]} for f in files], + files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files], channel_id=channel, channels=channels, initial_comment=initial_comment, @@ -4079,7 +4081,7 @@ def files_getUploadURLExternal( def files_completeUploadExternal( self, *, - files: List[Dict[str, str]], + files: List[Dict[str, Optional[str]]], channel_id: Optional[str] = None, channels: Optional[List[str]] = None, initial_comment: Optional[str] = None, diff --git a/tests/slack_sdk/web/test_internal_utils.py b/tests/slack_sdk/web/test_internal_utils.py index 3e44f0c9c..e8456b471 100644 --- a/tests/slack_sdk/web/test_internal_utils.py +++ b/tests/slack_sdk/web/test_internal_utils.py @@ -133,6 +133,13 @@ def test_files_upload_v2_issue_1356(self): file_io_item = _to_v2_file_upload_item({"file": file_io, "filename": "foo.txt"}) assert file_io_item.get("filename") == "foo.txt" + def test_to_v2_file_upload_item_passes_through_highlight_type(self): + item = _to_v2_file_upload_item({"content": "test", "filename": "image.png", "highlight_type": "png"}) + assert item.get("highlight_type") == "png" + + item_without = _to_v2_file_upload_item({"content": "test", "filename": "image.png"}) + assert item_without.get("highlight_type") is None + def test_to_v2_file_upload_item_can_accept_file_as_path(self): filepath = "tests/slack_sdk/web/test_internal_utils.py" upload_item_str = _to_v2_file_upload_item({"file": filepath})