Skip to content

Commit

Permalink
rewrite get user avatar for pluginapi
Browse files Browse the repository at this point in the history
  • Loading branch information
SAM2O2O committed Jun 8, 2018
1 parent e38cb56 commit 9435cdf
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,21 @@ public CommandResponse avatar(Command command) {
try {
HaiUserAvatarProto.HaiUserAvatarRequest request = HaiUserAvatarProto.HaiUserAvatarRequest
.parseFrom(command.getParams());
String photoId = request.getPhotoId();
String siteUserId = request.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());

if (StringUtils.isEmpty(photoId)) {
if (StringUtils.isEmpty(siteUserId)) {
throw new ZalyException2(ErrorCode2.ERROR_PARAMETER);
}

SimpleUserBean bean = UserProfileDao.getInstance().getSimpleProfileById(siteUserId);

if (bean == null || StringUtils.isEmpty(bean.getUserPhoto())) {
throw new ZalyException2(ErrorCode2.ERROR2_USER_AVATAR);
}

String photoId = bean.getUserPhoto();

byte[] photoContents = FileServerUtils.fileToBinary(FilePathUtils.getPicPath(), photoId);

if (photoContents != null && photoContents.length > 0) {
Expand All @@ -176,8 +184,6 @@ public CommandResponse avatar(Command command) {

commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR2_USER_AVATAR;
}

} catch (Exception e) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9435cdf

Please sign in to comment.