use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ImSiteAuthHandler method authResponse.
private CommandResponse authResponse(Channel channel, Command command, boolean result) {
CommandResponse commandResponse = new CommandResponse().setVersion(CommandConst.PROTOCOL_VERSION).setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR2_IMAUTH_FAIL;
if (result) {
String siteServer = ServerAddressUtils.getAddressPort();
ImSiteAuthProto.ImSiteAuthResponse authResponse = ImSiteAuthProto.ImSiteAuthResponse.newBuilder().setSiteServer(siteServer).build();
commandResponse.setParams(authResponse.toByteArray());
errCode = ErrorCode2.SUCCESS;
ChannelWriter.write(channel, commandResponse.setErrCode2(errCode));
} else {
ChannelWriter.writeAndClose(channel, commandResponse.setErrCode2(errCode));
}
logger.debug("{} client={} siteUserId={} action={} auth response result={}", AkxProject.PLN, command.getClientIp(), command.getSiteUserId(), RequestAction.IM_SITE_AUTH, errCode.toString());
return commandResponse;
}
use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiDeviceService method list.
public CommandResponse list(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiDeviceListProto.DeviceListInfoRequest request = ApiDeviceListProto.DeviceListInfoRequest.parseFrom(command.getParams());
String siteFriendId = request.getSiteUserId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteFriendId)) {
ApiDeviceListProto.DeviceListInfoResponse.Builder responseBuilder = ApiDeviceListProto.DeviceListInfoResponse.newBuilder();
List<UserDeviceBean> deviceList = UserDeviceDao.getInstance().getActiveDeviceList(siteFriendId);
for (UserDeviceBean device : deviceList) {
DeviceProto.SimpleDeviceProfile deviceProfile = DeviceProto.SimpleDeviceProfile.newBuilder().setDeviceId(String.valueOf(device.getDeviceId())).setDeviceName(String.valueOf(device.getDeviceName())).setUserDevicePubk(String.valueOf(device.getUserDevicePubk())).setLastLoginTime(device.getActiveTime()).build();
responseBuilder.addList(deviceProfile);
}
commandResponse.setParams(responseBuilder.build().toByteArray());
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiFileService method upload.
public CommandResponse upload(Command command) {
CommandResponse commandResponse = new CommandResponse();
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFileUploadProto.ApiFileUploadRequest request = ApiFileUploadProto.ApiFileUploadRequest.parseFrom(command.getParams());
FileProto.File file = request.getFile();
int type = file.getFileTypeValue();
byte[] content = file.getFileContent().toByteArray();
LogUtils.requestDebugLog(logger, command, "type=" + type + ",size=" + content.length);
String fileId = FileServerUtils.saveFile(content, FilePathUtils.getPicPath(), type);
ApiFileUploadProto.ApiFileUploadResponse response = ApiFileUploadProto.ApiFileUploadResponse.newBuilder().setFileId(fileId).build();
commandResponse.setParams(response.toByteArray());
errCode = ErrorCode2.SUCCESS;
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiFriendService method delete.
/**
* 用户删除好友列表中的其他用户
*
* @param command
* @return
*/
public CommandResponse delete(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendDeleteProto.ApiFriendDeleteRequest request = ApiFriendDeleteProto.ApiFriendDeleteRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(siteFriendId) && !siteUserId.equals(siteFriendId)) {
if (UserFriendDao.getInstance().deleteFriend(siteUserId, siteFriendId)) {
errCode = ErrorCode2.SUCCESS;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
use of com.akaxin.common.constant.ErrorCode2 in project openzaly by akaxincom.
the class ApiFriendService method updateSetting.
/**
* 对用户设置消息免打扰功能
*
* @param command
* @return
*/
public CommandResponse updateSetting(Command command) {
CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
ErrorCode2 errCode = ErrorCode2.ERROR;
try {
ApiFriendUpdateSettingProto.ApiFriendUpdateSettingRequest request = ApiFriendUpdateSettingProto.ApiFriendUpdateSettingRequest.parseFrom(command.getParams());
String siteUserId = command.getSiteUserId();
String siteFriendId = request.getSiteFriendId();
boolean messageMute = request.getMessageMute();
LogUtils.requestDebugLog(logger, command, request.toString());
if (StringUtils.isNoneBlank(siteUserId, siteFriendId)) {
UserFriendBean friendBean = new UserFriendBean();
friendBean.setSiteUserId(siteFriendId);
friendBean.setMute(messageMute);
if (UserFriendDao.getInstance().updateFriendSetting(siteUserId, friendBean)) {
errCode = ErrorCode2.SUCCESS;
} else {
errCode = ErrorCode2.ERROR_DATABASE_EXECUTE;
}
} else {
errCode = ErrorCode2.ERROR_PARAMETER;
}
} catch (Exception e) {
errCode = ErrorCode2.ERROR_SYSTEMERROR;
LogUtils.requestErrorLog(logger, command, e);
}
return commandResponse.setErrCode2(errCode);
}
Aggregations