Error code standardization

test-errcode
skiffer-git 2 years ago
parent 635c703535
commit b76751ec79

@ -817,18 +817,18 @@ func SetErrorForResp(err error, errCode *int32, errMsg *string) {
} }
func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) { func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.GetGroupApplicationListReq) (*pbGroup.GetGroupApplicationListResp, error) {
nCtx := trace_log.NewRpcCtx(ctx, utils.GetSelfFuncName(), req.OperationID) ctx = trace_log.NewRpcCtx(ctx, utils.GetSelfFuncName(), req.OperationID)
trace_log.SetRpcReqInfo(nCtx, utils.GetSelfFuncName(), req.String()) trace_log.SetRpcReqInfo(ctx, utils.GetSelfFuncName(), req.String())
defer trace_log.ShowLog(nCtx) defer trace_log.ShowLog(ctx)
resp := pbGroup.GetGroupApplicationListResp{} resp := pbGroup.GetGroupApplicationListResp{}
reply, err := imdb.GetRecvGroupApplicationList(req.FromUserID) reply, err := imdb.GetRecvGroupApplicationList(req.FromUserID)
if err != nil { if err != nil {
SetErr(nCtx, "", err, &resp.ErrCode, &resp.ErrMsg, "userID ", req.FromUserID) SetErr(ctx, "", err, &resp.ErrCode, &resp.ErrMsg, "userID ", req.FromUserID)
return &resp, nil return &resp, nil
} }
var errResult error var errResult error
trace_log.SetContextInfo(nCtx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply) trace_log.SetContextInfo(ctx, "GetRecvGroupApplicationList", nil, " FromUserID: ", req.FromUserID, "GroupApplicationList: ", reply)
for _, v := range reply { for _, v := range reply {
node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}} node := open_im_sdk.GroupRequest{UserInfo: &open_im_sdk.PublicUserInfo{}, GroupInfo: &open_im_sdk.GroupInfo{}}
@ -839,7 +839,7 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
} }
continue continue
} }
trace_log.SetContextInfo(nCtx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo) trace_log.SetContextInfo(ctx, "FillGroupInfoByGroupID ", nil, " groupID: ", v.GroupID, " groupInfo: ", node.GroupInfo)
err = FillPublicUserInfoByUserID(req.OperationID, v.UserID, node.UserInfo) err = FillPublicUserInfoByUserID(req.OperationID, v.UserID, node.UserInfo)
if err != nil { if err != nil {
errResult = err errResult = err
@ -849,24 +849,24 @@ func (s *groupServer) GetGroupApplicationList(ctx context.Context, req *pbGroup.
resp.GroupRequestList = append(resp.GroupRequestList, &node) resp.GroupRequestList = append(resp.GroupRequestList, &node)
} }
if errResult != nil && len(resp.GroupRequestList) == 0 { if errResult != nil && len(resp.GroupRequestList) == 0 {
SetErr(nCtx, "", errResult, &resp.ErrCode, &resp.ErrMsg) SetErr(ctx, "", errResult, &resp.ErrCode, &resp.ErrMsg)
return &resp, nil return &resp, nil
} }
trace_log.SetRpcRespInfo(nCtx, utils.GetSelfFuncName(), resp.String()) trace_log.SetRpcRespInfo(ctx, utils.GetSelfFuncName(), resp.String())
return &resp, nil return &resp, nil
} }
func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsInfoReq) (*pbGroup.GetGroupsInfoResp, error) { func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsInfoReq) (*pbGroup.GetGroupsInfoResp, error) {
nCtx := trace_log.NewRpcCtx(ctx, utils.GetSelfFuncName(), req.OperationID) trace_log.SetRpcReqInfo(trace_log.NewRpcCtx(ctx, utils.GetSelfFuncName(), req.OperationID), utils.GetSelfFuncName(), req.String())
trace_log.SetRpcReqInfo(nCtx, utils.GetSelfFuncName(), req.String()) defer trace_log.ShowLog(ctx)
defer trace_log.ShowLog(nCtx)
resp := pbGroup.GetGroupsInfoResp{} resp := pbGroup.GetGroupsInfoResp{}
groupsInfoList := make([]*open_im_sdk.GroupInfo, 0) groupsInfoList := make([]*open_im_sdk.GroupInfo, 0)
for _, groupID := range req.GroupIDList { for _, groupID := range req.GroupIDList {
groupInfoFromRedis, err := rocksCache.GetGroupInfoFromCache(groupID) groupInfoFromRedis, err := rocksCache.GetGroupInfoFromCache(ctx, groupID)
if err != nil { if err != nil {
SetErr(nCtx, "", err, &resp.ErrCode, &resp.ErrMsg, "groupID ", groupID) SetErrorForResp(err, &resp.CommonResp.ErrCode, &resp.CommonResp.ErrMsg)
SetErr(ctx, "", err, &resp.ErrCode, &resp.ErrMsg, "groupID ", groupID)
continue continue
} }
var groupInfo open_im_sdk.GroupInfo var groupInfo open_im_sdk.GroupInfo
@ -876,7 +876,7 @@ func (s *groupServer) GetGroupsInfo(ctx context.Context, req *pbGroup.GetGroupsI
} }
resp.GroupInfoList = groupsInfoList resp.GroupInfoList = groupsInfoList
trace_log.SetRpcRespInfo(nCtx, utils.GetSelfFuncName(), resp.String()) trace_log.SetRpcRespInfo(ctx, utils.GetSelfFuncName(), resp.String())
return &resp, nil return &resp, nil
} }
@ -885,7 +885,7 @@ func CheckPermission(ctx context.Context, groupID string, userID string) (err er
trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "userID", userID) trace_log.SetContextInfo(ctx, utils.GetSelfFuncName(), err, "groupID", groupID, "userID", userID)
}() }()
if !token_verify.IsManagerUserID(userID) && !imdb.IsGroupOwnerAdmin(groupID, userID) { if !token_verify.IsManagerUserID(userID) && !imdb.IsGroupOwnerAdmin(groupID, userID) {
return constant.ErrNoPermission return utils.Wrap(constant.ErrNoPermission, utils.GetSelfFuncName())
} }
return nil return nil
} }

File diff suppressed because it is too large Load Diff

@ -4,48 +4,42 @@ import "Open-IM-Server/pkg/proto/sdk_ws/wrappers.proto";
option go_package = "Open_IM/pkg/proto/group;group"; option go_package = "Open_IM/pkg/proto/group;group";
package group; package group;
message CommonResp{
int32 ErrCode = 1;
string ErrMsg = 2;
}
message GroupAddMemberInfo{ message GroupAddMemberInfo{
string UserID = 1; string userID = 1;
int32 RoleLevel = 2; int32 roleLevel = 2;
} }
message CreateGroupReq{ message CreateGroupReq{
repeated GroupAddMemberInfo InitMemberList = 1; repeated GroupAddMemberInfo initMemberList = 1;
server_api_params.GroupInfo GroupInfo = 2; server_api_params.GroupInfo groupInfo = 2;
string OperationID = 3; string operationID = 3;
string OpUserID = 4; //app manager or group owner string opUserID = 4; //app manager or group owner
string OwnerUserID = 5; //owner string ownerUserID = 5; //owner
} }
message CreateGroupResp{ message CreateGroupResp{
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; server_api_params.GroupInfo groupInfo = 3;
server_api_params.GroupInfo GroupInfo = 3;
} }
message GetGroupsInfoReq{ message GetGroupsInfoReq{
repeated string GroupIDList = 1; repeated string groupIDList = 1;
string OperationID = 2; string operationID = 2;
string OpUserID = 3; //No verification permission string opUserID = 3; //No verification permission
} }
message GetGroupsInfoResp{ message GetGroupsInfoResp{
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; repeated server_api_params.GroupInfo groupInfoList = 3;
repeated server_api_params.GroupInfo GroupInfoList = 3;
} }
message SetGroupInfoReq{ message SetGroupInfoReq{
server_api_params.GroupInfoForSet groupInfoForSet = 1; server_api_params.GroupInfoForSet groupInfoForSet = 1;
string OpUserID = 2; //app manager or group owner string opUserID = 2; //app manager or group owner
string OperationID = 3; string operationID = 3;
} }
message SetGroupInfoResp{ message SetGroupInfoResp{
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
@ -53,46 +47,45 @@ message SetGroupInfoResp{
message GetGroupApplicationListReq { message GetGroupApplicationListReq {
string OpUserID = 1; //app manager or group owner(manager) string opUserID = 1; //app manager or group owner(manager)
string OperationID = 2; string operationID = 2;
string FromUserID = 3; //owner or manager string fromUserID = 3; //owner or manager
} }
message GetGroupApplicationListResp { message GetGroupApplicationListResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; repeated server_api_params.GroupRequest groupRequestList = 3;
repeated server_api_params.GroupRequest GroupRequestList = 3;
} }
message GetUserReqApplicationListReq{ message GetUserReqApplicationListReq{
string UserID = 1; string userID = 1;
string OpUserID = 2; string opUserID = 2;
string OperationID = 3; string operationID = 3;
} }
message GetUserReqApplicationListResp{ message GetUserReqApplicationListResp{
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
repeated server_api_params.GroupRequest GroupRequestList = 2; repeated server_api_params.GroupRequest groupRequestList = 2;
} }
message TransferGroupOwnerReq { message TransferGroupOwnerReq {
string GroupID = 1; string groupID = 1;
string OldOwnerUserID = 2; string oldOwnerUserID = 2;
string NewOwnerUserID = 3; string newOwnerUserID = 3;
string OperationID = 4; string operationID = 4;
string OpUserID = 5; //app manager or group owner string opUserID = 5; //app manager or group owner
} }
message TransferGroupOwnerResp{ message TransferGroupOwnerResp{
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
} }
message JoinGroupReq{ message JoinGroupReq{
string GroupID = 1; string groupID = 1;
string ReqMessage = 2; string reqMessage = 2;
string OpUserID = 3; string opUserID = 3;
string OperationID = 4; string operationID = 4;
int32 JoinSource = 5; int32 joinSource = 5;
string InviterUserID = 6; string inviterUserID = 6;
} }
message JoinGroupResp{ message JoinGroupResp{
@ -101,12 +94,12 @@ message JoinGroupResp{
message GroupApplicationResponseReq{ message GroupApplicationResponseReq{
string OperationID = 1; string operationID = 1;
string OpUserID = 2; string opUserID = 2;
string GroupID = 3; string groupID = 3;
string FromUserID = 4; // string fromUserID = 4; //
string HandledMsg = 5; string handledMsg = 5;
int32 HandleResult = 6; int32 handleResult = 6;
} }
message GroupApplicationResponseResp{ message GroupApplicationResponseResp{
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
@ -115,9 +108,9 @@ message GroupApplicationResponseResp{
message QuitGroupReq{ message QuitGroupReq{
string GroupID = 1; string groupID = 1;
string OperationID = 2; string operationID = 2;
string OpUserID = 3; string opUserID = 3;
} }
message QuitGroupResp{ message QuitGroupResp{
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
@ -126,130 +119,124 @@ message QuitGroupResp{
message GetGroupMemberListReq { message GetGroupMemberListReq {
string GroupID = 1; string groupID = 1;
string OpUserID = 2; //No verification permission string opUserID = 2; //No verification permission
string OperationID = 3; string operationID = 3;
int32 Filter = 4; int32 filter = 4;
int32 NextSeq = 5; int32 nextSeq = 5;
} }
message GetGroupMemberListResp { message GetGroupMemberListResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2;
repeated server_api_params.GroupMemberFullInfo memberList = 3; repeated server_api_params.GroupMemberFullInfo memberList = 3;
int32 nextSeq = 4; int32 nextSeq = 4;
} }
message GetGroupMembersInfoReq { message GetGroupMembersInfoReq {
string GroupID = 1; string groupID = 1;
repeated string memberList = 2; repeated string memberList = 2;
string OpUserID = 3; //No verification permission string opUserID = 3; //No verification permission
string OperationID = 4; string operationID = 4;
} }
message GetGroupMembersInfoResp { message GetGroupMembersInfoResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2;
repeated server_api_params.GroupMemberFullInfo memberList = 3; repeated server_api_params.GroupMemberFullInfo memberList = 3;
} }
message KickGroupMemberReq { message KickGroupMemberReq {
string GroupID = 1; string groupID = 1;
repeated string KickedUserIDList = 2; repeated string kickedUserIDList = 2;
string Reason = 3; string reason = 3;
string OperationID = 5; string operationID = 5;
string OpUserID = 6; //app manger or group manager string opUserID = 6; //app manger or group manager
} }
message Id2Result { message Id2Result {
string UserID = 1; string userID = 1;
int32 Result = 2; //0 ok; -1 error int32 result = 2; //0 ok; -1 error
} }
message KickGroupMemberResp { message KickGroupMemberResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; repeated Id2Result id2ResultList = 3;
repeated Id2Result Id2ResultList = 3;
} }
message GetJoinedGroupListReq { message GetJoinedGroupListReq {
string FromUserID = 1; string fromUserID = 1;
string operationID = 2; string operationID = 2;
string OpUserID = 3; //app manager or FromUserID string opUserID = 3; //app manager or FromUserID
} }
message GetJoinedGroupListResp{ message GetJoinedGroupListResp{
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; repeated server_api_params.GroupInfo groupList = 3;
repeated server_api_params.GroupInfo GroupList = 3;
} }
message InviteUserToGroupReq { message InviteUserToGroupReq {
string OperationID = 2; string operationID = 2;
string GroupID = 3; string groupID = 3;
string Reason = 4; string reason = 4;
repeated string InvitedUserIDList = 5; repeated string invitedUserIDList = 5;
string OpUserID = 6; //group member or app manager string opUserID = 6; //group member or app manager
} }
message InviteUserToGroupResp { message InviteUserToGroupResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2; repeated Id2Result id2ResultList = 3; // 0 ok, -1 error
repeated Id2Result Id2ResultList = 3; // 0 ok, -1 error
} }
message GetGroupAllMemberReq { message GetGroupAllMemberReq {
string GroupID = 1; string groupID = 1;
string OpUserID = 2; //No verification permission string opUserID = 2; //No verification permission
string OperationID = 3; string operationID = 3;
int32 Offset = 4; int32 offset = 4;
int32 Count = 5; int32 count = 5;
} }
message GetGroupAllMemberResp { message GetGroupAllMemberResp {
int32 ErrCode = 1; server_api_params.CommonResp commonResp = 1;
string ErrMsg = 2;
repeated server_api_params.GroupMemberFullInfo memberList = 3; repeated server_api_params.GroupMemberFullInfo memberList = 3;
} }
message CMSGroup { message CMSGroup {
server_api_params.GroupInfo GroupInfo = 1; server_api_params.GroupInfo groupInfo = 1;
string GroupOwnerUserName = 2; string groupOwnerUserName = 2;
string GroupOwnerUserID = 3; string groupOwnerUserID = 3;
} }
message GetGroupsReq { message GetGroupsReq {
server_api_params.RequestPagination Pagination = 1; server_api_params.RequestPagination pagination = 1;
string GroupName = 2; string groupName = 2;
string GroupID = 3; string groupID = 3;
string OperationID = 4; string operationID = 4;
} }
message GetGroupsResp { message GetGroupsResp {
repeated CMSGroup CMSGroups = 1; repeated CMSGroup groups = 1;
server_api_params.ResponsePagination Pagination = 2; server_api_params.ResponsePagination pagination = 2;
int32 GroupNum = 3; int32 GroupNum = 3;
server_api_params.CommonResp commonResp = 4; server_api_params.CommonResp commonResp = 4;
} }
message GetGroupMemberReq { message GetGroupMemberReq {
string GroupID = 1; string groupID = 1;
string OperationID = 2; string operationID = 2;
} }
message GetGroupMembersCMSReq { message GetGroupMembersCMSReq {
string GroupID = 1; string groupID = 1;
string UserName = 2; string userName = 2;
server_api_params.RequestPagination Pagination = 3; server_api_params.RequestPagination pagination = 3;
string OperationID = 4; string operationID = 4;
} }
message GetGroupMembersCMSResp { message GetGroupMembersCMSResp {
repeated server_api_params.GroupMemberFullInfo members = 1; repeated server_api_params.GroupMemberFullInfo members = 1;
server_api_params.ResponsePagination Pagination = 2; server_api_params.ResponsePagination pagination = 2;
int32 MemberNums = 3; int32 memberNums = 3;
server_api_params.CommonResp commonResp = 4; server_api_params.CommonResp commonResp = 4;
} }
@ -334,18 +321,18 @@ message GetJoinedSuperGroupListReq {
message GetJoinedSuperGroupListResp { message GetJoinedSuperGroupListResp {
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
repeated server_api_params.GroupInfo GroupList = 3; repeated server_api_params.GroupInfo groupList = 3;
} }
message GetSuperGroupsInfoReq { message GetSuperGroupsInfoReq {
repeated string GroupIDList = 1; repeated string groupIDList = 1;
string OperationID = 2; string operationID = 2;
string OpUserID = 3; //No verification permission string opUserID = 3; //No verification permission
} }
message GetSuperGroupsInfoResp { message GetSuperGroupsInfoResp {
server_api_params.CommonResp commonResp = 1; server_api_params.CommonResp commonResp = 1;
repeated server_api_params.GroupInfo GroupInfoList = 3; repeated server_api_params.GroupInfo groupInfoList = 3;
} }
message SetGroupMemberInfoReq{ message SetGroupMemberInfoReq{

Loading…
Cancel
Save