Search in sources :

Example 6 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class ApiFriendService method mute.

public CommandResponse mute(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendMuteProto.ApiFriendMuteRequest request = ApiFriendMuteProto.ApiFriendMuteRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNoneEmpty(siteUserId, siteFriendId)) {
            boolean mute = UserFriendDao.getInstance().getFriendMute(siteUserId, siteFriendId);
            ApiFriendSettingProto.ApiFriendSettingResponse response = ApiFriendSettingProto.ApiFriendSettingResponse.newBuilder().setMessageMute(mute).build();
            commandResponse.setParams(response.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);
}
Also used : ApiFriendMuteProto(com.akaxin.proto.site.ApiFriendMuteProto) ApiFriendSettingProto(com.akaxin.proto.site.ApiFriendSettingProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse)

Example 7 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class ApiFriendService method applyResult.

/**
 * 是否同意用户的好友申请结果
 *
 * @param command
 * @return
 */
public CommandResponse applyResult(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendApplyResultProto.ApiFriendApplyResultRequest request = ApiFriendApplyResultProto.ApiFriendApplyResultRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String siteFriendId = request.getSiteFriendId();
        boolean result = request.getApplyResult();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(siteFriendId) && !siteUserId.equals(siteFriendId)) {
            if (UserFriendDao.getInstance().agreeApply(siteUserId, siteFriendId, result)) {
                errCode = ErrorCode2.SUCCESS;
            }
            if (ErrorCode2.SUCCESS.equals(errCode) && result) {
                new User2Notice().addFriendTextMessage(siteUserId, siteFriendId);
                logger.debug("client={} siteUserId={} add friend notice to siteUserId={}", command.getClientIp(), siteFriendId);
            }
        } else {
            errCode = ErrorCode2.ERROR_PARAMETER;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) User2Notice(com.akaxin.site.business.impl.notice.User2Notice) CommandResponse(com.akaxin.common.command.CommandResponse) ApiFriendApplyResultProto(com.akaxin.proto.site.ApiFriendApplyResultProto)

Example 8 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class ApiFriendService method list.

public CommandResponse list(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiFriendListProto.ApiFriendListRequest request = ApiFriendListProto.ApiFriendListRequest.parseFrom(command.getParams());
        String currentUserId = command.getSiteUserId();
        String siteUserId = request.getSiteUserId();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(currentUserId)) {
            List<SimpleUserBean> friendBeanList = UserFriendDao.getInstance().getUserFriends(siteUserId);
            ApiFriendListProto.ApiFriendListResponse.Builder responseBuilder = ApiFriendListProto.ApiFriendListResponse.newBuilder();
            for (SimpleUserBean friendBean : friendBeanList) {
                UserProto.SimpleUserProfile friend = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(String.valueOf(friendBean.getUserId())).setUserName(String.valueOf(friendBean.getUserName())).setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build();
                responseBuilder.addList(friend);
            }
            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);
}
Also used : ApiFriendListProto(com.akaxin.proto.site.ApiFriendListProto) ErrorCode2(com.akaxin.common.constant.ErrorCode2) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean)

Example 9 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class ApiGroupService method updateProfile.

/**
 * 用户更新群资料<br>
 * 群主/管理员权限限制
 *
 * @param command
 * @return
 */
public CommandResponse updateProfile(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest request = ApiGroupUpdateProfileProto.ApiGroupUpdateProfileRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getProfile().getId();
        String photoId = request.getProfile().getIcon();
        String groupName = request.getProfile().getName();
        String groupNotice = request.getProfile().getGroupNotice();
        // 新的群群主
        String newGroupOwner = request.getNewGroupOwner();
        // 是否可以邀请群聊(除了群主以外的其他群成员)
        boolean closeInviteGroupChat = request.getCloseInviteGroupChat();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (StringUtils.isNotBlank(siteUserId) && StringUtils.isNotBlank(groupId)) {
            String groupMasterId = UserGroupDao.getInstance().getGroupMaster(groupId);
            if (StringUtils.isNotBlank(siteUserId) && siteUserId.equals(groupMasterId)) {
                GroupProfileBean gprofileBean = new GroupProfileBean();
                gprofileBean.setGroupId(groupId);
                gprofileBean.setGroupName(groupName);
                gprofileBean.setGroupPhoto(photoId);
                gprofileBean.setGroupNotice(groupNotice);
                gprofileBean.setCreateUserId(newGroupOwner);
                gprofileBean.setCloseInviteGroupChat(closeInviteGroupChat);
                if (StringUtils.isNotEmpty(groupName)) {
                    if (UserGroupDao.getInstance().updateGroupProfile(gprofileBean)) {
                        errCode = ErrorCode2.SUCCESS;
                    }
                } else {
                    if (UserGroupDao.getInstance().updateGroupIGC(gprofileBean)) {
                        errCode = ErrorCode2.SUCCESS;
                    }
                }
            } else {
                errCode = ErrorCode2.ERROR_NOPERMISSION;
            }
        } else {
            errCode = ErrorCode2.ERROR_PARAMETER;
        }
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ErrorCode2(com.akaxin.common.constant.ErrorCode2) CommandResponse(com.akaxin.common.command.CommandResponse) ApiGroupUpdateProfileProto(com.akaxin.proto.site.ApiGroupUpdateProfileProto) GroupProfileBean(com.akaxin.site.storage.bean.GroupProfileBean)

Example 10 with CommandResponse

use of com.akaxin.common.command.CommandResponse in project openzaly by akaxincom.

the class ApiGroupService method nonMembers.

/**
 * 获取用户群组中,不存在的好友用户
 *
 * @param command
 * @return
 */
public CommandResponse nonMembers(Command command) {
    CommandResponse commandResponse = new CommandResponse().setAction(CommandConst.ACTION_RES);
    ErrorCode2 errCode = ErrorCode2.ERROR;
    try {
        ApiGroupNonMembersProto.ApiGroupNonMembersRequest request = ApiGroupNonMembersProto.ApiGroupNonMembersRequest.parseFrom(command.getParams());
        String siteUserId = command.getSiteUserId();
        String groupId = request.getGroupId();
        int pageNum = request.getPageNumber();
        int pageSize = request.getPageSize();
        LogUtils.requestDebugLog(logger, command, request.toString());
        if (pageNum == 0 && pageSize == 0) {
            pageSize = 100;
        }
        List<SimpleUserBean> userFriendList = UserGroupDao.getInstance().getUserFriendNonGroupMemberList(siteUserId, groupId, pageNum, pageSize);
        ApiGroupNonMembersProto.ApiGroupNonMembersResponse.Builder responseBuilder = ApiGroupNonMembersProto.ApiGroupNonMembersResponse.newBuilder();
        for (SimpleUserBean friendBean : userFriendList) {
            UserProto.SimpleUserProfile friendProfile = UserProto.SimpleUserProfile.newBuilder().setSiteUserId(friendBean.getUserId()).setUserName(String.valueOf(friendBean.getUserName())).setUserPhoto(String.valueOf(friendBean.getUserPhoto())).build();
            responseBuilder.addProfile(friendProfile);
        }
        commandResponse.setParams(responseBuilder.build().toByteArray());
        errCode = ErrorCode2.SUCCESS;
    } catch (Exception e) {
        errCode = ErrorCode2.ERROR_SYSTEMERROR;
        LogUtils.requestErrorLog(logger, command, e);
    }
    return commandResponse.setErrCode2(errCode);
}
Also used : ApiGroupNonMembersProto(com.akaxin.proto.site.ApiGroupNonMembersProto) UserProto(com.akaxin.proto.core.UserProto) CommandResponse(com.akaxin.common.command.CommandResponse) SimpleUserBean(com.akaxin.site.storage.bean.SimpleUserBean) ErrorCode2(com.akaxin.common.constant.ErrorCode2)

Aggregations

CommandResponse (com.akaxin.common.command.CommandResponse)82 ErrorCode2 (com.akaxin.common.constant.ErrorCode2)68 UserProto (com.akaxin.proto.core.UserProto)12 PluginBean (com.akaxin.site.storage.bean.PluginBean)7 ByteString (com.google.protobuf.ByteString)7 GroupProto (com.akaxin.proto.core.GroupProto)6 GroupProfileBean (com.akaxin.site.storage.bean.GroupProfileBean)6 SimpleUserBean (com.akaxin.site.storage.bean.SimpleUserBean)6 UserProfileBean (com.akaxin.site.storage.bean.UserProfileBean)6 UserDeviceBean (com.akaxin.site.storage.bean.UserDeviceBean)5 Command (com.akaxin.common.command.Command)4 DeviceProto (com.akaxin.proto.core.DeviceProto)4 ProtocolStringList (com.google.protobuf.ProtocolStringList)4 ConfigProto (com.akaxin.proto.core.ConfigProto)3 GroupMemberBean (com.akaxin.site.storage.bean.GroupMemberBean)3 UserGroupBean (com.akaxin.site.storage.bean.UserGroupBean)3 RedisCommand (com.akaxin.common.command.RedisCommand)2 ImStcPsnProto (com.akaxin.proto.client.ImStcPsnProto)2 CoreProto (com.akaxin.proto.core.CoreProto)2 FileProto (com.akaxin.proto.core.FileProto)2