Skip to content

Commit 1ebd166

Browse files
zimegClaude
andcommitted
feat: add highlight_type to files.completeUploadExternal and files_upload_v2
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
1 parent beecde2 commit 1ebd166

5 files changed

Lines changed: 17 additions & 3 deletions

File tree

slack_sdk/web/async_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4037,6 +4037,7 @@ async def files_upload_v2(
40374037
title: Optional[str] = None,
40384038
alt_txt: Optional[str] = None,
40394039
snippet_type: Optional[str] = None,
4040+
highlight_type: Optional[str] = None,
40404041
# To upload multiple files at a time
40414042
file_uploads: Optional[List[Dict[str, Any]]] = None,
40424043
channel: Optional[str] = None,
@@ -4081,6 +4082,7 @@ async def files_upload_v2(
40814082
"title": title,
40824083
"alt_txt": alt_txt,
40834084
"snippet_type": snippet_type,
4085+
"highlight_type": highlight_type,
40844086
}
40854087
)
40864088
files.append(f)
@@ -4118,7 +4120,7 @@ async def files_upload_v2(
41184120

41194121
# step3: files.completeUploadExternal with all the sets of (file_id + title)
41204122
completion = await self.files_completeUploadExternal(
4121-
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
4123+
files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files],
41224124
channel_id=channel,
41234125
channels=channels,
41244126
initial_comment=initial_comment,

slack_sdk/web/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4027,6 +4027,7 @@ def files_upload_v2(
40274027
title: Optional[str] = None,
40284028
alt_txt: Optional[str] = None,
40294029
snippet_type: Optional[str] = None,
4030+
highlight_type: Optional[str] = None,
40304031
# To upload multiple files at a time
40314032
file_uploads: Optional[List[Dict[str, Any]]] = None,
40324033
channel: Optional[str] = None,
@@ -4071,6 +4072,7 @@ def files_upload_v2(
40714072
"title": title,
40724073
"alt_txt": alt_txt,
40734074
"snippet_type": snippet_type,
4075+
"highlight_type": highlight_type,
40744076
}
40754077
)
40764078
files.append(f)
@@ -4108,7 +4110,7 @@ def files_upload_v2(
41084110

41094111
# step3: files.completeUploadExternal with all the sets of (file_id + title)
41104112
completion = self.files_completeUploadExternal(
4111-
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
4113+
files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files],
41124114
channel_id=channel,
41134115
channels=channels,
41144116
initial_comment=initial_comment,

slack_sdk/web/internal_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ def _to_v2_file_upload_item(upload_file: Dict[str, Any]) -> Dict[str, Optional[A
379379
"title": title,
380380
"alt_txt": upload_file.get("alt_txt"),
381381
"snippet_type": upload_file.get("snippet_type"),
382+
"highlight_type": upload_file.get("highlight_type"),
382383
}
383384

384385

slack_sdk/web/legacy_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3962,6 +3962,7 @@ def files_upload_v2(
39623962
title: Optional[str] = None,
39633963
alt_txt: Optional[str] = None,
39643964
snippet_type: Optional[str] = None,
3965+
highlight_type: Optional[str] = None,
39653966
# To upload multiple files at a time
39663967
file_uploads: Optional[List[Dict[str, Any]]] = None,
39673968
channel: Optional[str] = None,
@@ -4006,6 +4007,7 @@ def files_upload_v2(
40064007
"title": title,
40074008
"alt_txt": alt_txt,
40084009
"snippet_type": snippet_type,
4010+
"highlight_type": highlight_type,
40094011
}
40104012
)
40114013
files.append(f)
@@ -4043,7 +4045,7 @@ def files_upload_v2(
40434045

40444046
# step3: files.completeUploadExternal with all the sets of (file_id + title)
40454047
completion = self.files_completeUploadExternal(
4046-
files=[{"id": f["file_id"], "title": f["title"]} for f in files],
4048+
files=[{"id": f["file_id"], "title": f["title"], "highlight_type": f.get("highlight_type")} for f in files],
40474049
channel_id=channel,
40484050
channels=channels,
40494051
initial_comment=initial_comment,

tests/slack_sdk/web/test_internal_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ def test_files_upload_v2_issue_1356(self):
133133
file_io_item = _to_v2_file_upload_item({"file": file_io, "filename": "foo.txt"})
134134
assert file_io_item.get("filename") == "foo.txt"
135135

136+
def test_to_v2_file_upload_item_passes_through_highlight_type(self):
137+
item = _to_v2_file_upload_item({"content": "test", "filename": "image.png", "highlight_type": "png"})
138+
assert item.get("highlight_type") == "png"
139+
140+
item_without = _to_v2_file_upload_item({"content": "test", "filename": "image.png"})
141+
assert item_without.get("highlight_type") is None
142+
136143
def test_to_v2_file_upload_item_can_accept_file_as_path(self):
137144
filepath = "tests/slack_sdk/web/test_internal_utils.py"
138145
upload_item_str = _to_v2_file_upload_item({"file": filepath})

0 commit comments

Comments
 (0)