mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-05 21:02:11 +08:00
fix: fix tools erros code
This commit is contained in:
parent
96121b0ca0
commit
2810cab920
@ -322,8 +322,8 @@ func GinParseToken(rdb redis.UniversalClient, config *config.GlobalConfig) gin.H
|
||||
case http.MethodPost:
|
||||
token := c.Request.Header.Get(constant.Token)
|
||||
if token == "" {
|
||||
log.ZWarn(c, "header get token error", errs.ErrArgs.Wrap("header must have token"))
|
||||
apiresp.GinError(c, errs.ErrArgs.Wrap("header must have token"))
|
||||
log.ZWarn(c, "header get token error", errs.ErrArgs.WrapMsg("header must have token"))
|
||||
apiresp.GinError(c, errs.ErrArgs.WrapMsg("header must have token"))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
|
||||
@ -427,21 +427,21 @@ func (ws *WsServer) ParseWSArgs(r *http.Request) (args *WSArgs, err error) {
|
||||
query := r.URL.Query()
|
||||
v.MsgResp, _ = strconv.ParseBool(query.Get(MsgResp))
|
||||
if ws.onlineUserConnNum.Load() >= ws.wsMaxConnNum {
|
||||
return nil, errs.ErrConnOverMaxNumLimit.Wrap("over max conn num limit")
|
||||
return nil, errs.ErrConnOverMaxNumLimit.WrapMsg("over max conn num limit")
|
||||
}
|
||||
if v.Token = query.Get(Token); v.Token == "" {
|
||||
return nil, errs.ErrConnArgsErr.Wrap("token is empty")
|
||||
return nil, errs.ErrConnArgsErr.WrapMsg("token is empty")
|
||||
}
|
||||
if v.UserID = query.Get(WsUserID); v.UserID == "" {
|
||||
return nil, errs.ErrConnArgsErr.Wrap("sendID is empty")
|
||||
return nil, errs.ErrConnArgsErr.WrapMsg("sendID is empty")
|
||||
}
|
||||
platformIDStr := query.Get(PlatformID)
|
||||
if platformIDStr == "" {
|
||||
return nil, errs.ErrConnArgsErr.Wrap("platformID is empty")
|
||||
return nil, errs.ErrConnArgsErr.WrapMsg("platformID is empty")
|
||||
}
|
||||
platformID, err := strconv.Atoi(platformIDStr)
|
||||
if err != nil {
|
||||
return nil, errs.ErrConnArgsErr.Wrap("platformID is not int")
|
||||
return nil, errs.ErrConnArgsErr.WrapMsg("platformID is not int")
|
||||
}
|
||||
v.PlatformID = platformID
|
||||
if err = authverify.WsVerifyToken(v.Token, v.UserID, ws.globalConfig.Secret, platformID); err != nil {
|
||||
|
||||
@ -80,7 +80,7 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbconvers
|
||||
return nil, err
|
||||
}
|
||||
if len(conversations) < 1 {
|
||||
return nil, errs.ErrRecordNotFound.Wrap("conversation not found")
|
||||
return nil, errs.ErrRecordNotFound.WrapMsg("conversation not found")
|
||||
}
|
||||
resp := &pbconversation.GetConversationResp{Conversation: &pbconversation.Conversation{}}
|
||||
resp.Conversation = convert.ConversationDB2Pb(conversations[0])
|
||||
@ -200,7 +200,7 @@ func (c *conversationServer) SetConversations(ctx context.Context,
|
||||
req *pbconversation.SetConversationsReq,
|
||||
) (*pbconversation.SetConversationsResp, error) {
|
||||
if req.Conversation == nil {
|
||||
return nil, errs.ErrArgs.Wrap("conversation must not be nil")
|
||||
return nil, errs.ErrArgs.WrapMsg("conversation must not be nil")
|
||||
}
|
||||
if req.Conversation.ConversationType == constant.GroupChatType {
|
||||
groupInfo, err := c.groupRpcClient.GetGroupInfo(ctx, req.Conversation.GroupID)
|
||||
@ -208,7 +208,7 @@ func (c *conversationServer) SetConversations(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if groupInfo.Status == constant.GroupStatusDismissed {
|
||||
return nil, errs.ErrDismissedAlready.Wrap("group dismissed")
|
||||
return nil, errs.ErrDismissedAlready.WrapMsg("group dismissed")
|
||||
}
|
||||
}
|
||||
var unequal int
|
||||
@ -219,7 +219,7 @@ func (c *conversationServer) SetConversations(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
if len(cs) == 0 {
|
||||
return nil, errs.ErrRecordNotFound.Wrap("conversation not found")
|
||||
return nil, errs.ErrRecordNotFound.WrapMsg("conversation not found")
|
||||
}
|
||||
conv = *cs[0]
|
||||
}
|
||||
@ -406,7 +406,7 @@ func (c *conversationServer) GetConversationOfflinePushUserIDs(
|
||||
req *pbconversation.GetConversationOfflinePushUserIDsReq,
|
||||
) (*pbconversation.GetConversationOfflinePushUserIDsResp, error) {
|
||||
if req.ConversationID == "" {
|
||||
return nil, errs.ErrArgs.Wrap("conversationID is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("conversationID is empty")
|
||||
}
|
||||
if len(req.UserIDs) == 0 {
|
||||
return &pbconversation.GetConversationOfflinePushUserIDsResp{}, nil
|
||||
|
||||
@ -115,7 +115,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
||||
return nil, err
|
||||
}
|
||||
if req.ToUserID == req.FromUserID {
|
||||
return nil, errs.ErrCanNotAddYourself.Wrap("req.ToUserID", req.ToUserID)
|
||||
return nil, errs.ErrCanNotAddYourself.WrapMsg("req.ToUserID", req.ToUserID)
|
||||
}
|
||||
if err = CallbackBeforeAddFriend(ctx, &s.config.Callback, req); err != nil && err != errs.ErrCallbackContinue {
|
||||
return nil, err
|
||||
@ -128,7 +128,7 @@ func (s *friendServer) ApplyToAddFriend(ctx context.Context, req *pbfriend.Apply
|
||||
return nil, err
|
||||
}
|
||||
if in1 && in2 {
|
||||
return nil, errs.ErrRelationshipAlready.Wrap("has f")
|
||||
return nil, errs.ErrRelationshipAlready.WrapMsg("has f")
|
||||
}
|
||||
if err = s.friendDatabase.AddFriendRequest(ctx, req.FromUserID, req.ToUserID, req.ReqMsg, req.Ex); err != nil {
|
||||
return nil, err
|
||||
@ -149,10 +149,10 @@ func (s *friendServer) ImportFriends(ctx context.Context, req *pbfriend.ImportFr
|
||||
return nil, err
|
||||
}
|
||||
if utils.Contain(req.OwnerUserID, req.FriendUserIDs...) {
|
||||
return nil, errs.ErrCanNotAddYourself.Wrap("can not add yourself")
|
||||
return nil, errs.ErrCanNotAddYourself.WrapMsg("can not add yourself")
|
||||
}
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friend userID repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("friend userID repeated")
|
||||
}
|
||||
if err := CallbackBeforeImportFriends(ctx, &s.config.Callback, req); err != nil {
|
||||
return nil, err
|
||||
@ -206,7 +206,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *pbfriend.Res
|
||||
s.notificationSender.FriendApplicationRefusedNotification(ctx, req)
|
||||
return resp, nil
|
||||
}
|
||||
return nil, errs.ErrArgs.Wrap("req.HandleResult != -1/1")
|
||||
return nil, errs.ErrArgs.WrapMsg("req.HandleResult != -1/1")
|
||||
}
|
||||
|
||||
// ok.
|
||||
@ -257,7 +257,7 @@ func (s *friendServer) SetFriendRemark(ctx context.Context, req *pbfriend.SetFri
|
||||
func (s *friendServer) GetDesignatedFriends(ctx context.Context, req *pbfriend.GetDesignatedFriendsReq) (resp *pbfriend.GetDesignatedFriendsResp, err error) {
|
||||
resp = &pbfriend.GetDesignatedFriendsResp{}
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friend userID repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("friend userID repeated")
|
||||
}
|
||||
friends, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
if err != nil {
|
||||
@ -360,10 +360,10 @@ func (s *friendServer) GetFriendIDs(ctx context.Context, req *pbfriend.GetFriend
|
||||
|
||||
func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfriend.GetSpecifiedFriendsInfoReq) (*pbfriend.GetSpecifiedFriendsInfoResp, error) {
|
||||
if len(req.UserIDList) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("userIDList is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("userIDList is empty")
|
||||
}
|
||||
if utils.Duplicate(req.UserIDList) {
|
||||
return nil, errs.ErrArgs.Wrap("userIDList repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("userIDList repeated")
|
||||
}
|
||||
userMap, err := s.userRpcClient.GetUsersInfoMap(ctx, req.UserIDList)
|
||||
if err != nil {
|
||||
@ -427,10 +427,10 @@ func (s *friendServer) UpdateFriends(
|
||||
req *pbfriend.UpdateFriendsReq,
|
||||
) (*pbfriend.UpdateFriendsResp, error) {
|
||||
if len(req.FriendUserIDs) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("friendIDList is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("friendIDList is empty")
|
||||
}
|
||||
if utils.Duplicate(req.FriendUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("friendIDList repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("friendIDList repeated")
|
||||
}
|
||||
|
||||
_, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.FriendUserIDs)
|
||||
|
||||
@ -166,7 +166,7 @@ func (s *groupServer) GenGroupID(ctx context.Context, groupID *string) error {
|
||||
if *groupID != "" {
|
||||
_, err := s.db.TakeGroup(ctx, *groupID)
|
||||
if err == nil {
|
||||
return errs.ErrGroupIDExisted.Wrap("group id existed " + *groupID)
|
||||
return errs.ErrGroupIDExisted.WrapMsg("group id existed " + *groupID)
|
||||
} else if s.IsNotFound(err) {
|
||||
return nil
|
||||
} else {
|
||||
@ -214,7 +214,7 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbgroup.CreateGroupR
|
||||
return nil, err
|
||||
}
|
||||
if len(userMap) != len(userIDs) {
|
||||
return nil, errs.ErrUserIDNotFound.Wrap("user not found")
|
||||
return nil, errs.ErrUserIDNotFound.WrapMsg("user not found")
|
||||
}
|
||||
|
||||
config := &GroupEventCallbackConfig{
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
|
||||
func (s *groupServer) GroupCreateCount(ctx context.Context, req *group.GroupCreateCountReq) (*group.GroupCreateCountResp, error) {
|
||||
if req.Start > req.End {
|
||||
return nil, errs.ErrArgs.Wrap("start > end: %d > %d", req.Start, req.End)
|
||||
return nil, errs.ErrArgs.WrapMsg("start > end: %d > %d", req.Start, req.End)
|
||||
}
|
||||
total, err := s.db.CountTotal(ctx, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -75,7 +75,7 @@ func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetC
|
||||
return
|
||||
}
|
||||
if req.HasReadSeq > maxSeq {
|
||||
return nil, errs.ErrArgs.Wrap("hasReadSeq must not be bigger than maxSeq")
|
||||
return nil, errs.ErrArgs.WrapMsg("hasReadSeq must not be bigger than maxSeq")
|
||||
}
|
||||
if err := m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq); err != nil {
|
||||
return nil, err
|
||||
@ -89,7 +89,7 @@ func (m *msgServer) SetConversationHasReadSeq(ctx context.Context, req *msg.SetC
|
||||
|
||||
func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadReq) (resp *msg.MarkMsgsAsReadResp, err error) {
|
||||
if len(req.Seqs) < 1 {
|
||||
return nil, errs.ErrArgs.Wrap("seqs must not be empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("seqs must not be empty")
|
||||
}
|
||||
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
|
||||
if err != nil {
|
||||
@ -97,7 +97,7 @@ func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadR
|
||||
}
|
||||
hasReadSeq := req.Seqs[len(req.Seqs)-1]
|
||||
if hasReadSeq > maxSeq {
|
||||
return nil, errs.ErrArgs.Wrap("hasReadSeq must not be bigger than maxSeq")
|
||||
return nil, errs.ErrArgs.WrapMsg("hasReadSeq must not be bigger than maxSeq")
|
||||
}
|
||||
conversation, err := m.ConversationLocalCache.GetConversation(ctx, req.UserID, req.ConversationID)
|
||||
if err != nil {
|
||||
|
||||
@ -34,13 +34,13 @@ import (
|
||||
func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.RevokeMsgResp, error) {
|
||||
defer log.ZDebug(ctx, "RevokeMsg return line")
|
||||
if req.UserID == "" {
|
||||
return nil, errs.ErrArgs.Wrap("user_id is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("user_id is empty")
|
||||
}
|
||||
if req.ConversationID == "" {
|
||||
return nil, errs.ErrArgs.Wrap("conversation_id is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("conversation_id is empty")
|
||||
}
|
||||
if req.Seq < 0 {
|
||||
return nil, errs.ErrArgs.Wrap("seq is invalid")
|
||||
return nil, errs.ErrArgs.WrapMsg("seq is invalid")
|
||||
}
|
||||
if err := authverify.CheckAccessV3(ctx, req.UserID, m.config); err != nil {
|
||||
return nil, err
|
||||
@ -54,10 +54,10 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
||||
return nil, err
|
||||
}
|
||||
if len(msgs) == 0 || msgs[0] == nil {
|
||||
return nil, errs.ErrRecordNotFound.Wrap("msg not found")
|
||||
return nil, errs.ErrRecordNotFound.WrapMsg("msg not found")
|
||||
}
|
||||
if msgs[0].ContentType == constant.MsgRevokeNotification {
|
||||
return nil, errs.ErrMsgAlreadyRevoke.Wrap("msg already revoke")
|
||||
return nil, errs.ErrMsgAlreadyRevoke.WrapMsg("msg already revoke")
|
||||
}
|
||||
|
||||
data, _ := json.Marshal(msgs[0])
|
||||
@ -90,7 +90,7 @@ func (m *msgServer) RevokeMsg(ctx context.Context, req *msg.RevokeMsgReq) (*msg.
|
||||
role = member.RoleLevel
|
||||
}
|
||||
default:
|
||||
return nil, errs.ErrInternalServer.Wrap("msg sessionType not supported")
|
||||
return nil, errs.ErrInternalServer.WrapMsg("msg sessionType not supported")
|
||||
}
|
||||
}
|
||||
now := time.Now().UnixMilli()
|
||||
|
||||
@ -71,7 +71,7 @@ func (t *thirdServer) UploadLogs(ctx context.Context, req *third.UploadLogsReq)
|
||||
}
|
||||
}
|
||||
if log.LogID == "" {
|
||||
return nil, errs.ErrData.Wrap("LogModel id gen error")
|
||||
return nil, errs.ErrData.WrapMsg("LogModel id gen error")
|
||||
}
|
||||
DBlogs = append(DBlogs, &log)
|
||||
}
|
||||
@ -132,7 +132,7 @@ func (t *thirdServer) SearchLogs(ctx context.Context, req *third.SearchLogsReq)
|
||||
userIDs []string
|
||||
)
|
||||
if req.StartTime > req.EndTime {
|
||||
return nil, errs.ErrArgs.Wrap("startTime>endTime")
|
||||
return nil, errs.ErrArgs.WrapMsg("startTime>endTime")
|
||||
}
|
||||
if req.StartTime == 0 && req.EndTime == 0 {
|
||||
t := time.Date(2019, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
@ -170,7 +170,7 @@ func (t *thirdServer) AccessURL(ctx context.Context, req *third.AccessURLReq) (*
|
||||
opt.Image.Height, _ = strconv.Atoi(req.Query["height"])
|
||||
log.ZDebug(ctx, "AccessURL image", "name", req.Name, "option", opt.Image)
|
||||
default:
|
||||
return nil, errs.ErrArgs.Wrap("invalid query type")
|
||||
return nil, errs.ErrArgs.WrapMsg("invalid query type")
|
||||
}
|
||||
}
|
||||
expireTime, rawURL, err := t.s3dataBase.AccessURL(ctx, req.Name, t.defaultExpire, opt)
|
||||
@ -185,10 +185,10 @@ func (t *thirdServer) AccessURL(ctx context.Context, req *third.AccessURLReq) (*
|
||||
|
||||
func (t *thirdServer) InitiateFormData(ctx context.Context, req *third.InitiateFormDataReq) (*third.InitiateFormDataResp, error) {
|
||||
if req.Name == "" {
|
||||
return nil, errs.ErrArgs.Wrap("name is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("name is empty")
|
||||
}
|
||||
if req.Size <= 0 {
|
||||
return nil, errs.ErrArgs.Wrap("size must be greater than 0")
|
||||
return nil, errs.ErrArgs.WrapMsg("size must be greater than 0")
|
||||
}
|
||||
if err := t.checkUploadName(ctx, req.Name); err != nil {
|
||||
return nil, err
|
||||
@ -246,15 +246,15 @@ func (t *thirdServer) InitiateFormData(ctx context.Context, req *third.InitiateF
|
||||
|
||||
func (t *thirdServer) CompleteFormData(ctx context.Context, req *third.CompleteFormDataReq) (*third.CompleteFormDataResp, error) {
|
||||
if req.Id == "" {
|
||||
return nil, errs.ErrArgs.Wrap("id is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("id is empty")
|
||||
}
|
||||
data, err := base64.RawStdEncoding.DecodeString(req.Id)
|
||||
if err != nil {
|
||||
return nil, errs.ErrArgs.Wrap("invalid id " + err.Error())
|
||||
return nil, errs.ErrArgs.WrapMsg("invalid id " + err.Error())
|
||||
}
|
||||
var mate FormDataMate
|
||||
if err := json.Unmarshal(data, &mate); err != nil {
|
||||
return nil, errs.ErrArgs.Wrap("invalid id " + err.Error())
|
||||
return nil, errs.ErrArgs.WrapMsg("invalid id " + err.Error())
|
||||
}
|
||||
if err := t.checkUploadName(ctx, mate.Name); err != nil {
|
||||
return nil, err
|
||||
@ -264,7 +264,7 @@ func (t *thirdServer) CompleteFormData(ctx context.Context, req *third.CompleteF
|
||||
return nil, err
|
||||
}
|
||||
if info.Size > 0 && info.Size != mate.Size {
|
||||
return nil, errs.ErrData.Wrap("file size mismatch")
|
||||
return nil, errs.ErrData.WrapMsg("file size mismatch")
|
||||
}
|
||||
obj := &relation.ObjectModel{
|
||||
Name: mate.Name,
|
||||
|
||||
@ -44,10 +44,10 @@ func toPbMapArray(m map[string][]string) []*third.KeyValues {
|
||||
|
||||
func (t *thirdServer) checkUploadName(ctx context.Context, name string) error {
|
||||
if name == "" {
|
||||
return errs.ErrArgs.Wrap("name is empty")
|
||||
return errs.ErrArgs.WrapMsg("name is empty")
|
||||
}
|
||||
if name[0] == '/' {
|
||||
return errs.ErrArgs.Wrap("name cannot start with `/`")
|
||||
return errs.ErrArgs.WrapMsg("name cannot start with `/`")
|
||||
}
|
||||
if err := checkValidObjectName(name); err != nil {
|
||||
return errs.ErrArgs.Wrap(err.Error())
|
||||
|
||||
@ -27,7 +27,7 @@ func (s *userServer) UserRegisterCount(
|
||||
req *pbuser.UserRegisterCountReq,
|
||||
) (*pbuser.UserRegisterCountResp, error) {
|
||||
if req.Start > req.End {
|
||||
return nil, errs.ErrArgs.Wrap("start > end")
|
||||
return nil, errs.ErrArgs.WrapMsg("start > end")
|
||||
}
|
||||
total, err := s.CountTotal(ctx, nil)
|
||||
if err != nil {
|
||||
|
||||
@ -195,7 +195,7 @@ func (s *userServer) SetGlobalRecvMessageOpt(ctx context.Context, req *pbuser.Se
|
||||
func (s *userServer) AccountCheck(ctx context.Context, req *pbuser.AccountCheckReq) (resp *pbuser.AccountCheckResp, err error) {
|
||||
resp = &pbuser.AccountCheckResp{}
|
||||
if utils.Duplicate(req.CheckUserIDs) {
|
||||
return nil, errs.ErrArgs.Wrap("userID repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID repeated")
|
||||
}
|
||||
err = authverify.CheckAdmin(ctx, s.config)
|
||||
if err != nil {
|
||||
@ -242,22 +242,22 @@ func (s *userServer) GetPaginationUsers(ctx context.Context, req *pbuser.GetPagi
|
||||
func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterReq) (resp *pbuser.UserRegisterResp, err error) {
|
||||
resp = &pbuser.UserRegisterResp{}
|
||||
if len(req.Users) == 0 {
|
||||
return nil, errs.ErrArgs.Wrap("users is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("users is empty")
|
||||
}
|
||||
if req.Secret != s.config.Secret {
|
||||
log.ZDebug(ctx, "UserRegister", s.config.Secret, req.Secret)
|
||||
return nil, errs.ErrNoPermission.WrapMsg("secret invalid")
|
||||
}
|
||||
if utils.DuplicateAny(req.Users, func(e *sdkws.UserInfo) string { return e.UserID }) {
|
||||
return nil, errs.ErrArgs.Wrap("userID repeated")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID repeated")
|
||||
}
|
||||
userIDs := make([]string, 0)
|
||||
for _, user := range req.Users {
|
||||
if user.UserID == "" {
|
||||
return nil, errs.ErrArgs.Wrap("userID is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID is empty")
|
||||
}
|
||||
if strings.Contains(user.UserID, ":") {
|
||||
return nil, errs.ErrArgs.Wrap("userID contains ':' is invalid userID")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID contains ':' is invalid userID")
|
||||
}
|
||||
userIDs = append(userIDs, user.UserID)
|
||||
}
|
||||
@ -266,7 +266,7 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
||||
return nil, err
|
||||
}
|
||||
if exist {
|
||||
return nil, errs.ErrRegisteredAlready.Wrap("userID registered already")
|
||||
return nil, errs.ErrRegisteredAlready.WrapMsg("userID registered already")
|
||||
}
|
||||
if err := CallbackBeforeUserRegister(ctx, s.config, req); err != nil {
|
||||
return nil, err
|
||||
@ -542,12 +542,12 @@ func (s *userServer) AddNotificationAccount(ctx context.Context, req *pbuser.Add
|
||||
break
|
||||
}
|
||||
if req.UserID == "" {
|
||||
return nil, errs.ErrInternalServer.Wrap("gen user id failed")
|
||||
return nil, errs.ErrInternalServer.WrapMsg("gen user id failed")
|
||||
}
|
||||
} else {
|
||||
_, err := s.UserDatabase.FindWithError(ctx, []string{req.UserID})
|
||||
if err == nil {
|
||||
return nil, errs.ErrArgs.Wrap("userID is used")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID is used")
|
||||
}
|
||||
}
|
||||
|
||||
@ -639,7 +639,7 @@ func (s *userServer) SearchNotificationAccount(ctx context.Context, req *pbuser.
|
||||
|
||||
func (s *userServer) GetNotificationAccount(ctx context.Context, req *pbuser.GetNotificationAccountReq) (*pbuser.GetNotificationAccountResp, error) {
|
||||
if req.UserID == "" {
|
||||
return nil, errs.ErrArgs.Wrap("userID is empty")
|
||||
return nil, errs.ErrArgs.WrapMsg("userID is empty")
|
||||
}
|
||||
user, err := s.UserDatabase.GetUserByID(ctx, req.UserID)
|
||||
if err != nil {
|
||||
|
||||
@ -44,7 +44,7 @@ func CheckAccessV3(ctx context.Context, ownerUserID string, manager *config.Mana
|
||||
if opUserID == ownerUserID {
|
||||
return nil
|
||||
}
|
||||
return errs.ErrNoPermission.Wrap("ownerUserID", ownerUserID)
|
||||
return errs.ErrNoPermission.WrapMsg("ownerUserID", ownerUserID)
|
||||
}
|
||||
|
||||
func IsAppManagerUid(ctx context.Context, manager *config.Manager, imAdmin *config.IMAdmin) bool {
|
||||
|
||||
4
pkg/common/db/cache/group.go
vendored
4
pkg/common/db/cache/group.go
vendored
@ -228,7 +228,7 @@ func (g *GroupCacheRedis) DelGroupAllRoleLevel(groupID string) GroupCache {
|
||||
|
||||
func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID string) (hashCode uint64, err error) {
|
||||
if g.groupHash == nil {
|
||||
return 0, errs.ErrInternalServer.Wrap("group hash is nil")
|
||||
return 0, errs.ErrInternalServer.WrapMsg("group hash is nil")
|
||||
}
|
||||
return getCache(ctx, g.rcClient, g.getGroupMembersHashKey(groupID), g.expireTime, func(ctx context.Context) (uint64, error) {
|
||||
return g.groupHash.GetGroupHash(ctx, groupID)
|
||||
@ -237,7 +237,7 @@ func (g *GroupCacheRedis) GetGroupMembersHash(ctx context.Context, groupID strin
|
||||
|
||||
func (g *GroupCacheRedis) GetGroupMemberHashMap(ctx context.Context, groupIDs []string) (map[string]*relationtb.GroupSimpleUserID, error) {
|
||||
if g.groupHash == nil {
|
||||
return nil, errs.ErrInternalServer.Wrap("group hash is nil")
|
||||
return nil, errs.ErrInternalServer.WrapMsg("group hash is nil")
|
||||
}
|
||||
res := make(map[string]*relationtb.GroupSimpleUserID)
|
||||
for _, groupID := range groupIDs {
|
||||
|
||||
2
pkg/common/db/cache/meta_cache.go
vendored
2
pkg/common/db/cache/meta_cache.go
vendored
@ -163,7 +163,7 @@ func getCache[T any](ctx context.Context, rcClient *rockscache.Client, key strin
|
||||
return t, nil
|
||||
}
|
||||
if v == "" {
|
||||
return t, errs.ErrRecordNotFound.Wrap("cache is not found")
|
||||
return t, errs.ErrRecordNotFound.WrapMsg("cache is not found")
|
||||
}
|
||||
err = json.Unmarshal([]byte(v), &t)
|
||||
if err != nil {
|
||||
|
||||
@ -220,7 +220,7 @@ func (f *friendDatabase) AgreeFriendRequest(ctx context.Context, friendRequest *
|
||||
return err
|
||||
}
|
||||
if fr.HandleResult != 0 {
|
||||
return errs.ErrArgs.Wrap("the friend request has been processed")
|
||||
return errs.ErrArgs.WrapMsg("the friend request has been processed")
|
||||
}
|
||||
friendRequest.HandlerUserID = mcontext.GetOpUserID(ctx)
|
||||
friendRequest.HandleResult = constant.FriendResponseAgree
|
||||
|
||||
@ -219,15 +219,15 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
||||
var msg *unrelationtb.MsgDataModel
|
||||
msg, ok = field.(*unrelationtb.MsgDataModel)
|
||||
if msg != nil && msg.Seq != firstSeq+int64(i) {
|
||||
return errs.ErrInternalServer.Wrap("seq is invalid")
|
||||
return errs.ErrInternalServer.WrapMsg("seq is invalid")
|
||||
}
|
||||
case updateKeyRevoke:
|
||||
_, ok = field.(*unrelationtb.RevokeModel)
|
||||
default:
|
||||
return errs.ErrInternalServer.Wrap("key is invalid")
|
||||
return errs.ErrInternalServer.WrapMsg("key is invalid")
|
||||
}
|
||||
if !ok {
|
||||
return errs.ErrInternalServer.Wrap("field type is invalid")
|
||||
return errs.ErrInternalServer.WrapMsg("field type is invalid")
|
||||
}
|
||||
}
|
||||
// Returns true if the document exists in the database, false if the document does not exist in the database
|
||||
@ -309,7 +309,7 @@ func (db *commonMsgDatabase) BatchInsertBlock(ctx context.Context, conversationI
|
||||
|
||||
func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversationID string, msgList []*sdkws.MsgData, currentMaxSeq int64) error {
|
||||
if len(msgList) == 0 {
|
||||
return errs.ErrArgs.Wrap("msgList is empty")
|
||||
return errs.ErrArgs.WrapMsg("msgList is empty")
|
||||
}
|
||||
msgs := make([]any, len(msgList))
|
||||
for i, msg := range msgList {
|
||||
@ -579,7 +579,7 @@ func (db *commonMsgDatabase) GetMsgBySeqsRange(ctx context.Context, userID strin
|
||||
}
|
||||
//"begin" and "end" represent the actual startSeq and endSeq values that the user can retrieve.
|
||||
if end < begin {
|
||||
return 0, 0, nil, errs.ErrArgs.Wrap("seq end < begin")
|
||||
return 0, 0, nil, errs.ErrArgs.WrapMsg("seq end < begin")
|
||||
}
|
||||
var seqs []int64
|
||||
if end-begin+1 <= num {
|
||||
|
||||
@ -128,7 +128,7 @@ func (u *userDatabase) FindWithError(ctx context.Context, userIDs []string) (use
|
||||
return
|
||||
}
|
||||
if len(users) != len(userIDs) {
|
||||
err = errs.ErrRecordNotFound.Wrap("userID not found")
|
||||
err = errs.ErrRecordNotFound.WrapMsg("userID not found")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ func (m *Minio) getImageThumbnailURL(ctx context.Context, name string, expire ti
|
||||
return "", err
|
||||
}
|
||||
if !info.IsImg {
|
||||
return "", errs.ErrData.Wrap("object not image")
|
||||
return "", errs.ErrData.WrapMsg("object not image")
|
||||
}
|
||||
if opt.Width > info.Width || opt.Width <= 0 {
|
||||
opt.Width = info.Width
|
||||
|
||||
@ -147,7 +147,7 @@ func (m *MsgMongoDriver) GetMsgDocModelByIndex(
|
||||
index, sort int64,
|
||||
) (*table.MsgDocModel, error) {
|
||||
if sort != 1 && sort != -1 {
|
||||
return nil, errs.ErrArgs.Wrap("mongo sort must be 1 or -1")
|
||||
return nil, errs.ErrArgs.WrapMsg("mongo sort must be 1 or -1")
|
||||
}
|
||||
findOpts := options.Find().SetLimit(1).SetSkip(index).SetSort(bson.M{"doc_id": sort})
|
||||
cursor, err := m.MsgCollection.Find(
|
||||
|
||||
@ -249,7 +249,7 @@ func (g *GroupNotificationSender) groupMemberDB2PB(member *relation.GroupMemberM
|
||||
|
||||
func (g *GroupNotificationSender) fillOpUser(ctx context.Context, opUser **sdkws.GroupMemberFullInfo, groupID string) (err error) {
|
||||
if opUser == nil {
|
||||
return errs.ErrInternalServer.Wrap("**sdkws.GroupMemberFullInfo is nil")
|
||||
return errs.ErrInternalServer.WrapMsg("**sdkws.GroupMemberFullInfo is nil")
|
||||
}
|
||||
userID := mcontext.GetOpUserID(ctx)
|
||||
if groupID != "" {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user