Skip to content

Commit f3c65a6

Browse files
committed
Remove unnecessary code in files.upload v2 method
1 parent 9404383 commit f3c65a6

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

slack-api-client/src/main/java/com/slack/api/methods/impl/FilesUploadV2Helper.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,8 @@ public FilesUploadV2Response completeUploads(
104104
if (!response.isOk()) {
105105
throw underlyingException;
106106
}
107-
108-
result.setFiles(new ArrayList<>());
109-
for (File file : response.getFiles()) {
110-
if (v2Request.isRequestFileInfo()) {
111-
FilesInfoResponse fileInfo = this.client.filesInfo(r -> r.token(v2Request.getToken()).file(file.getId()));
112-
underlyingException.getFileInfoResponses().add(fileInfo);
113-
if (!fileInfo.isOk()) {
114-
throw underlyingException;
115-
}
116-
result.getFiles().add(fileInfo.getFile());
117-
} else {
118-
File partialFileObject = File.builder().id(file.getId()).title(file.getTitle()).build();
119-
result.getFiles().add(partialFileObject);
120-
}
121-
}
122-
123107
result.setOk(true);
108+
result.setFiles(response.getFiles());
124109
if (response.getFiles().size() == 1) {
125110
result.setFile(result.getFiles().get(0));
126111
}

slack-api-client/src/main/java/com/slack/api/methods/request/files/FilesUploadV2Request.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ public class FilesUploadV2Request implements SlackApiRequest {
7373

7474
/**
7575
* Fetches all the file metadata for better v1 compatibility when this property is true.
76+
* Note that, starting in v1.34, this flag does not do anything.
77+
* The full file metadata is now returned without additional files.info API calls.
7678
*/
79+
@Deprecated
7780
@Builder.Default
7881
private boolean requestFileInfo = true;
7982

slack-api-client/src/test/java/test_with_remote_apis/methods/files_Test.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -414,43 +414,6 @@ public void createLongTextFile_v2_full_args() throws Exception {
414414
}
415415
}
416416

417-
@Test
418-
public void createLongTextFile_v2_no_file_info() throws Exception {
419-
com.slack.api.model.File fileObj;
420-
{
421-
FilesUploadV2Response response = slack.methods(botToken).filesUploadV2(r -> r
422-
.content("test")
423-
.channel(channelId)
424-
.initialComment("initial comment")
425-
.filename("sample.txt")
426-
.title("file title")
427-
.requestFileInfo(false) // Added
428-
);
429-
assertThat(response.getError(), is(nullValue()));
430-
assertThat(response.isOk(), is(true));
431-
assertThat(response.getFile().getTitle(), is("file title"));
432-
assertThat(response.getFile().getName(), is(nullValue())); // this must be absent
433-
434-
// I know this is a bit long but this can be necessary for test stability
435-
Thread.sleep(10000L);
436-
fileObj = slack.methods(botToken).filesInfo(r -> r.file(response.getFile().getId())).getFile();
437-
438-
assertThat(fileObj.getTitle(), is("file title"));
439-
assertThat(fileObj.getName(), is("sample.txt"));
440-
}
441-
{
442-
ChatDeleteResponse response = slack.methods(botToken).chatDelete(r -> r
443-
.channel(channelId)
444-
.ts(fileObj
445-
.getShares()
446-
.getPublicChannels().get(channelId).get(0)
447-
.getTs())
448-
);
449-
assertThat(response.getError(), is(nullValue()));
450-
assertThat(response.isOk(), is(true));
451-
}
452-
}
453-
454417
@Test
455418
public void createImageFileAndComments() throws IOException, SlackApiException {
456419
File file = new File("src/test/resources/seratch.jpg");

0 commit comments

Comments
 (0)