Skip to content

Commit

Permalink
Add UserApi#deleteProfileImage (#162)
Browse files Browse the repository at this point in the history
fix #108
  • Loading branch information
maruTA-bis5 authored Feb 22, 2019
1 parent 6ea9e27 commit d543389
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ public String getUserStatusesRoute() {
return getUsersRoute() + "/status";
}

public String getUserProfileImageRoute(String userId) {
return getUserRoute(userId) + "/image";
}

public String getSamlRoute() {
return "/saml";
}
Expand Down Expand Up @@ -697,7 +701,7 @@ public ApiResponse<UserAutocomplete> autocompleteUsers(String username, String e
@Override
public ApiResponse<byte[]> getProfileImage(String userId, String etag) {
// XXX byte[]で返すの微妙・・・というかreadEntityでこけない?
return doApiGet(getUserRoute(userId) + "/image", etag, byte[].class);
return doApiGet(getUserProfileImageRoute(userId), etag, byte[].class);
}

private GenericType<Map<String, String>> stringMapType() {
Expand Down Expand Up @@ -893,7 +897,7 @@ public ApiResponse<Boolean> setProfileImage(String userId, Path imageFilePath) {
FileDataBodyPart body = new FileDataBodyPart("image", imageFilePath.toFile());
multiPart.bodyPart(body);

return doApiPostMultiPart(getUserRoute(userId) + "/image", multiPart).checkStatusOk();
return doApiPostMultiPart(getUserProfileImageRoute(userId), multiPart).checkStatusOk();
}

@Override
Expand Down Expand Up @@ -946,6 +950,11 @@ public ApiResponse<Boolean> revokeAllActiveSessionForUser(String userId) {
return doApiPost(getUserSessionsRoute(userId) + "/revoke/all", null).checkStatusOk();
}

@Override
public ApiResponse<Boolean> deleteProfileImage(String userId) {
return doApiDelete(getUserProfileImageRoute(userId)).checkStatusOk();
}

// Team Section

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,9 @@ default ApiResponse<UserAccessTokenList> getUserAccessTokensAllUsers() {

ApiResponse<Boolean> revokeAllActiveSessionForUser(String userId);

/**
* delete user profile image.
*/
ApiResponse<Boolean> deleteProfileImage(String userId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,21 @@ public void setUserProfileImage() throws URISyntaxException {
assertThat(result, is(true));
}

@Test
public void deleteUserProfileImage() throws URISyntaxException {
Path image = Paths.get(getClass().getResource(EMOJI_CONSTRUCTION).toURI());
ApiResponse<Boolean> uploadResult =
assertNoError(client.setProfileImage(th.basicUser().getId(), image));
if (isNotSupportVersion("5.6.0", uploadResult)) {
return;
}
assertTrue(uploadResult.readEntity());

ApiResponse<Boolean> deleteResult =
assertNoError(client.deleteProfileImage(th.basicUser().getId()));
assertTrue(deleteResult.readEntity());
}

@Test
public void getUserByName() {
String username = th.basicUser().getUsername();
Expand Down

0 comments on commit d543389

Please sign in to comment.