Feat/parameter check (#465)

Co-authored-by: ‘hanzhixiao’ <‘709674996@qq.com’>
pull/469/head
Alan 1 year ago committed by GitHub
parent 308f84e222
commit a9e2b55f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,30 @@
package auth
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *UserTokenReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.PlatformID > 9 || x.PlatformID < 1 {
return errs.ErrArgs.Wrap("platform is invalidate")
}
return nil
}
func (x *ForceLogoutReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.PlatformID > 9 || x.PlatformID < 1 {
return errs.ErrArgs.Wrap("platformID is invalidate")
}
return nil
}
func (x *ParseTokenReq) Check() error {
if x.Token == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}

@ -0,0 +1,147 @@
package conversation
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *ConversationReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversation is empty")
}
return nil
}
func (x *Conversation) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("ConversationID is empty")
}
if x.ConversationType < 1 || x.ConversationType > 4 {
return errs.ErrArgs.Wrap("ConversationType is invalid")
}
if x.RecvMsgOpt < 0 || x.RecvMsgOpt > 2 {
return errs.ErrArgs.Wrap("RecvMsgOpt is invalid")
}
return nil
}
func (x *ModifyConversationFieldReq) Check() error {
if x.UserIDList == nil {
return errs.ErrArgs.Wrap("userIDList is empty")
}
if x.Conversation == nil {
return errs.ErrArgs.Wrap("conversation is empty")
}
return nil
}
func (x *SetConversationReq) Check() error {
if x.Conversation == nil {
return errs.ErrArgs.Wrap("Conversation is empty")
}
if x.Conversation.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
return nil
}
func (x *SetRecvMsgOptReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.RecvMsgOpt > 2 || x.RecvMsgOpt < 0 {
return errs.ErrArgs.Wrap("MsgReceiveOpt is invalid")
}
return nil
}
func (x *GetConversationReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
return nil
}
func (x *GetConversationsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.ConversationIDs == nil {
return errs.ErrArgs.Wrap("conversationIDs is empty")
}
return nil
}
func (x *GetAllConversationsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
return nil
}
func (x *BatchSetConversationsReq) Check() error {
if x.Conversations == nil {
return errs.ErrArgs.Wrap("conversations is empty")
}
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("conversation is empty")
}
return nil
}
func (x *GetRecvMsgNotNotifyUserIDsReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *CreateGroupChatConversationsReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *SetConversationMaxSeqReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.OwnerUserID == nil {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.MaxSeq <= 0 {
return errs.ErrArgs.Wrap("maxSeq is invalid")
}
return nil
}
func (x *SetConversationsReq) Check() error {
if x.UserIDs == nil {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.Conversation == nil {
return errs.ErrArgs.Wrap("conversation is empty")
}
return nil
}
func (x *GetUserConversationIDsHashReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
return nil
}
func (x *GetConversationsByConversationIDReq) Check() error {
if x.ConversationIDs == nil {
return errs.ErrArgs.Wrap("conversationIDs is empty")
}
return nil
}

@ -0,0 +1,165 @@
package friend
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *GetPaginationFriendsReq) Check() error {
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *ApplyToAddFriendReq) Check() error {
if x.ToUserID == "" {
return errs.ErrArgs.Wrap("toUserID is empty")
}
if x.FromUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
return nil
}
func (x *ImportFriendReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.FriendUserIDs == nil {
return errs.ErrArgs.Wrap("friendUserIDS is empty")
}
return nil
}
func (x *GetPaginationFriendsApplyToReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *GetDesignatedFriendsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.FriendUserIDs == nil {
return errs.ErrArgs.Wrap("friendUserIDS is empty")
}
return nil
}
func (x *AddBlackReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.BlackUserID == "" {
return errs.ErrArgs.Wrap("BlackUserID is empty")
}
return nil
}
func (x *RemoveBlackReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.BlackUserID == "" {
return errs.ErrArgs.Wrap("BlackUserID is empty")
}
return nil
}
func (x *GetPaginationBlacksReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *IsFriendReq) Check() error {
if x.UserID1 == "" {
return errs.ErrArgs.Wrap("userID1 is empty")
}
if x.UserID2 == "" {
return errs.ErrArgs.Wrap("userID2 is empty")
}
return nil
}
func (x *IsBlackReq) Check() error {
if x.UserID1 == "" {
return errs.ErrArgs.Wrap("userID1 is empty")
}
if x.UserID2 == "" {
return errs.ErrArgs.Wrap("userID2 is empty")
}
return nil
}
func (x *DeleteFriendReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("userID1 is empty")
}
if x.FriendUserID == "" {
return errs.ErrArgs.Wrap("userID2 is empty")
}
return nil
}
func (x *RespondFriendApplyReq) Check() error {
if x.ToUserID == "" {
return errs.ErrArgs.Wrap("toUserID is empty")
}
if x.FromUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
return nil
}
func (x *SetFriendRemarkReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID is empty")
}
if x.FriendUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
if x.Remark == "" {
return errs.ErrArgs.Wrap("remark is empty")
}
return nil
}
func (x *GetPaginationFriendsApplyFromReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *GetFriendIDsReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}

@ -1,10 +0,0 @@
package friend
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (m *ApplyToAddFriendReq) Check() error {
if m.GetToUserID() == "" {
return errs.ErrArgs.Wrap("get toUserID is empty")
}
return nil
}

@ -0,0 +1,344 @@
package group
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *CreateGroupReq) Check() error {
if x.MemberUserIDs == nil {
return errs.ErrArgs.Wrap("memberUserIDS is empty")
}
if x.GroupInfo == nil {
return errs.ErrArgs.Wrap("groupInfo is empty")
}
if x.GroupInfo.OwnerUserID == "" {
return errs.ErrArgs.Wrap("GroupInfo.ownerUserID")
}
if x.GroupInfo.GroupType > 2 || x.GroupInfo.GroupType < 0 {
return errs.ErrArgs.Wrap("GroupType is invalid")
}
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("ownerUserID")
}
return nil
}
func (x *GetGroupsInfoReq) Check() error {
if x.GroupIDs == nil {
return errs.ErrArgs.Wrap("GroupIDs")
}
return nil
}
func (x *SetGroupInfoReq) Check() error {
if x.GroupInfoForSet == nil {
return errs.ErrArgs.Wrap("GroupInfoForSets is empty")
}
if x.GroupInfoForSet.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
return nil
}
func (x *GetGroupApplicationListReq) Check() error {
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
if x.FromUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
return nil
}
func (x *GetUserReqApplicationListReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *TransferGroupOwnerReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.OldOwnerUserID == "" {
return errs.ErrArgs.Wrap("oldOwnerUserID is empty")
}
if x.NewOwnerUserID == "" {
return errs.ErrArgs.Wrap("newOwnerUserID is empty")
}
return nil
}
func (x *JoinGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.JoinSource < 2 || x.JoinSource > 4 {
return errs.ErrArgs.Wrap("joinSource is invalid")
}
if x.JoinSource == 2 {
if x.InviterUserID == "" {
return errs.ErrArgs.Wrap("inviterUserID is empty")
}
}
return nil
}
func (x *GroupApplicationResponseReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.FromUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
if x.HandleResult > 1 || x.HandleResult < -1 {
return errs.ErrArgs.Wrap("handleResult is invalid")
}
return nil
}
func (x *QuitGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *GetGroupMemberListReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
if x.Filter < 0 || x.Filter > 5 {
return errs.ErrArgs.Wrap("filter is invalid")
}
return nil
}
func (x *GetGroupMembersInfoReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.UserIDs == nil {
return errs.ErrArgs.Wrap("userIDs is empty")
}
return nil
}
func (x *KickGroupMemberReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.KickedUserIDs == nil {
return errs.ErrArgs.Wrap("kickUserIDs is empty")
}
return nil
}
func (x *GetJoinedGroupListReq) Check() error {
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
if x.FromUserID == "" {
return errs.ErrArgs.Wrap("fromUserID is empty")
}
return nil
}
func (x *InviteUserToGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.InvitedUserIDs == nil {
return errs.ErrArgs.Wrap("invitedUserIDs is empty")
}
return nil
}
func (x *GetGroupAllMemberReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *GetGroupsReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *GetGroupMemberReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *GetGroupMembersCMSReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *DismissGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *MuteGroupMemberReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.MutedSeconds <= 0 {
return errs.ErrArgs.Wrap("mutedSeconds is empty")
}
return nil
}
func (x *CancelMuteGroupMemberReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *MuteGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *CancelMuteGroupReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("groupID is empty")
}
return nil
}
func (x *GetJoinedSuperGroupListReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *GetSuperGroupsInfoReq) Check() error {
if x.GroupIDs == nil {
return errs.ErrArgs.Wrap("GroupIDs is empty")
}
return nil
}
func (x *SetGroupMemberInfo) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *SetGroupMemberInfoReq) Check() error {
if x.Members == nil {
return errs.ErrArgs.Wrap("Members is empty")
}
return nil
}
func (x *GetGroupAbstractInfoReq) Check() error {
if x.GroupIDs == nil {
return errs.ErrArgs.Wrap("GroupID is empty")
}
return nil
}
func (x *GetUserInGroupMembersReq) Check() error {
if x.GroupIDs == nil {
return errs.ErrArgs.Wrap("GroupID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *GetGroupMemberUserIDsReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
return nil
}
func (x *GetGroupMemberRoleLevelReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
if x.RoleLevels == nil {
return errs.ErrArgs.Wrap("rolesLevel is empty")
}
return nil
}
func (x *GetGroupInfoCacheReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
return nil
}
func (x *GetGroupMemberCacheReq) Check() error {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
if x.GroupMemberID == "" {
return errs.ErrArgs.Wrap("GroupMemberID is empty")
}
return nil
}

@ -0,0 +1,205 @@
package msg
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *GetMaxAndMinSeqReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *SendMsgReq) Check() error {
if x.MsgData == nil {
return errs.ErrArgs.Wrap("MsgData is empty")
}
if err := x.MsgData.Check(); err != nil {
return err
}
return nil
}
func (x *SetSendMsgStatusReq) Check() error {
if x.Status < 0 || x.Status > 3 {
return errs.ErrArgs.Wrap("status is invalid")
}
return nil
}
func (x *GetSendMsgStatusReq) Check() error {
return nil
}
func (x *ModifyMessageReactionExtensionsReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.SessionType < 1 || x.SessionType > 4 {
return errs.ErrArgs.Wrap("sessionType is invalid")
}
if x.ReactionExtensions == nil {
return errs.ErrArgs.Wrap("reactionExtensions is empty")
}
return nil
}
func (x *SetMessageReactionExtensionsReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.SessionType < 1 || x.SessionType > 4 {
return errs.ErrArgs.Wrap("sessionType is invalid")
}
if x.ReactionExtensions == nil {
return errs.ErrArgs.Wrap("reactionExtensions is empty")
}
return nil
}
func (x *GetMessagesReactionExtensionsReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.SessionType < 1 || x.SessionType > 4 {
return errs.ErrArgs.Wrap("sessionType is invalid")
}
if x.MessageReactionKeys == nil {
return errs.ErrArgs.Wrap("MessageReactionKeys is empty")
}
if x.TypeKeys == nil {
return errs.ErrArgs.Wrap("TypeKeys is empty")
}
return nil
}
func (x *DeleteMessagesReactionExtensionsReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.SessionType < 1 || x.SessionType > 4 {
return errs.ErrArgs.Wrap("sessionType is invalid")
}
if x.ReactionExtensions == nil {
return errs.ErrArgs.Wrap("ReactionExtensions is empty")
}
return nil
}
func (x *DelMsgsReq) Check() error {
return nil
}
func (x *RevokeMsgReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.Seq < 1 {
return errs.ErrArgs.Wrap("seq is invalid")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *MarkMsgsAsReadReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.Seqs == nil {
return errs.ErrArgs.Wrap("seqs is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}
func (x *MarkConversationAsReadReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.Seqs == nil {
return errs.ErrArgs.Wrap("seqs is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.HasReadSeq < 1 {
return errs.ErrArgs.Wrap("hasReadSeq is invalid")
}
return nil
}
func (x *SetConversationHasReadSeqReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.HasReadSeq < 1 {
return errs.ErrArgs.Wrap("hasReadSeq is invalid")
}
return nil
}
func (x *ClearConversationsMsgReq) Check() error {
if x.ConversationIDs == nil {
return errs.ErrArgs.Wrap("conversationIDs is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.DeleteSyncOpt == nil {
return errs.ErrArgs.Wrap("deleteSyncOpt is empty")
}
return nil
}
func (x *UserClearAllMsgReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.DeleteSyncOpt == nil {
return errs.ErrArgs.Wrap("deleteSyncOpt is empty")
}
return nil
}
func (x *DeleteMsgsReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
if x.Seqs == nil {
return errs.ErrArgs.Wrap("seqs is empty")
}
if x.DeleteSyncOpt == nil {
return errs.ErrArgs.Wrap("deleteSyncOpt is empty")
}
return nil
}
func (x *DeleteMsgPhysicalReq) Check() error {
if x.ConversationIDs == nil {
return errs.ErrArgs.Wrap("conversationIDs is empty")
}
return nil
}
func (x *GetConversationMaxSeqReq) Check() error {
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("conversationID is empty")
}
return nil
}
func (x *GetConversationsHasReadAndMaxSeqReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("userID is empty")
}
return nil
}

@ -0,0 +1,59 @@
package msggateway
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *OnlinePushMsgReq) Check() error {
if x.MsgData == nil {
return errs.ErrArgs.Wrap("MsgData is empty")
}
if err := x.MsgData.Check(); err != nil {
return err
}
if x.PushToUserID == "" {
return errs.ErrArgs.Wrap("PushToUserID is empty")
}
return nil
}
func (x *OnlineBatchPushOneMsgReq) Check() error {
if x.MsgData == nil {
return errs.ErrArgs.Wrap("MsgData is empty")
}
if err := x.MsgData.Check(); err != nil {
return err
}
if x.PushToUserIDs == nil {
return errs.ErrArgs.Wrap("PushToUserIDs is empty")
}
return nil
}
func (x *GetUsersOnlineStatusReq) Check() error {
if x.UserIDs == nil {
return errs.ErrArgs.Wrap("UserIDs is empty")
}
return nil
}
func (x *KickUserOfflineReq) Check() error {
if x.PlatformID < 1 || x.PlatformID > 9 {
return errs.ErrArgs.Wrap("PlatformID is invalid")
}
if x.KickUserIDList == nil {
return errs.ErrArgs.Wrap("KickUserIDList is empty")
}
return nil
}
func (x *MultiTerminalLoginCheckReq) Check() error {
if x.PlatformID < 1 || x.PlatformID > 9 {
return errs.ErrArgs.Wrap("PlatformID is invalid")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
if x.Token == "" {
return errs.ErrArgs.Wrap("Token is empty")
}
return nil
}

@ -0,0 +1,26 @@
package push
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *PushMsgReq) Check() error {
if x.MsgData == nil {
return errs.ErrArgs.Wrap("MsgData is empty")
}
if err := x.MsgData.Check(); err != nil {
return err
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("ConversationID is empty")
}
return nil
}
func (x *DelUserPushTokenReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
if x.PlatformID < 1 || x.PlatformID > 9 {
return errs.ErrArgs.Wrap("PlatformID is invalid")
}
return nil
}

@ -0,0 +1,32 @@
package sdkws
import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
)
func (x *MsgData) Check() error {
if x.SendID == "" {
return errs.ErrArgs.Wrap("sendID is empty")
}
if x.Content == nil {
return errs.ErrArgs.Wrap("content is empty")
}
if x.ContentType < 101 || x.ContentType > 203 {
return errs.ErrArgs.Wrap("content is empty")
}
if x.SessionType < 1 || x.SessionType > 4 {
return errs.ErrArgs.Wrap("sessionType is invalid")
}
if x.SessionType == constant.SingleChatType || x.SessionType == constant.NotificationChatType {
if x.RecvID == "" {
return errs.ErrArgs.Wrap("recvID is empty")
}
}
if x.SessionType == constant.GroupChatType || x.SessionType == constant.SuperGroupChatType {
if x.GroupID == "" {
return errs.ErrArgs.Wrap("GroupID is empty")
}
}
return nil
}

@ -0,0 +1,61 @@
package third
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *ApplyPutReq) Check() error {
if x.PutID == "" {
return errs.ErrArgs.Wrap("PutID is empty")
}
if x.ContentType == "" {
return errs.ErrArgs.Wrap("ContentType is empty")
}
return nil
}
func (x *ConfirmPutReq) Check() error {
if x.PutID == "" {
return errs.ErrArgs.Wrap("PutID is empty")
}
return nil
}
func (x *GetUrlReq) Check() error {
if x.Name == "" {
return errs.ErrArgs.Wrap("Name is empty")
}
return nil
}
func (x *GetPutReq) Check() error {
if x.PutID == "" {
return errs.ErrArgs.Wrap("PutID is empty")
}
return nil
}
func (x *GetHashInfoReq) Check() error {
if x.Hash == "" {
return errs.ErrArgs.Wrap("Hash is empty")
}
return nil
}
func (x *FcmUpdateTokenReq) Check() error {
if x.PlatformID < 1 || x.PlatformID > 9 {
return errs.ErrArgs.Wrap("PlatformID is invalid")
}
if x.FcmToken == "" {
return errs.ErrArgs.Wrap("FcmToken is empty")
}
if x.Account == "" {
return errs.ErrArgs.Wrap("Account is empty")
}
return nil
}
func (x *SetAppBadgeReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
return nil
}

@ -0,0 +1,150 @@
package user
import "github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
func (x *GetAllUserIDReq) Check() error {
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *AccountCheckReq) Check() error {
if x.CheckUserIDs == nil {
return errs.ErrArgs.Wrap("CheckUserIDs is empty")
}
return nil
}
func (x *GetDesignateUsersReq) Check() error {
if x.UserIDs == nil {
return errs.ErrArgs.Wrap("UserIDs is empty")
}
return nil
}
func (x *UpdateUserInfoReq) Check() error {
if x.UserInfo == nil {
return errs.ErrArgs.Wrap("UserInfo is empty")
}
if x.UserInfo.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
return nil
}
func (x *SetGlobalRecvMessageOptReq) Check() error {
if x.GlobalRecvMsgOpt > 2 || x.GlobalRecvMsgOpt < 0 {
return errs.ErrArgs.Wrap("GlobalRecvMsgOpt is invalid")
}
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
return nil
}
func (x *SetConversationReq) Check() error {
if err := x.Conversation.Check(); err != nil {
return err
}
if x.NotificationType < 1 || x.NotificationType > 3 {
return errs.ErrArgs.Wrap("NotificationType is invalid")
}
return nil
}
func (x *SetRecvMsgOptReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("ConversationID is empty")
}
if x.RecvMsgOpt < 0 || x.RecvMsgOpt > 2 {
return errs.ErrArgs.Wrap("RecvMsgOpt is invalid")
}
if x.NotificationType < 1 || x.NotificationType > 3 {
return errs.ErrArgs.Wrap("NotificationType is invalid")
}
return nil
}
func (x *GetConversationReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
if x.ConversationID == "" {
return errs.ErrArgs.Wrap("ConversationID is empty")
}
return nil
}
func (x *GetConversationsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
if x.ConversationIDs == nil {
return errs.ErrArgs.Wrap("ConversationIDs is empty")
}
return nil
}
func (x *GetAllConversationsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
return nil
}
func (x *BatchSetConversationsReq) Check() error {
if x.OwnerUserID == "" {
return errs.ErrArgs.Wrap("OwnerUserID is empty")
}
if x.Conversations == nil {
return errs.ErrArgs.Wrap("ConversationIDs is empty")
}
if x.NotificationType < 1 || x.NotificationType > 3 {
return errs.ErrArgs.Wrap("NotificationType is invalid")
}
return nil
}
func (x *GetPaginationUsersReq) Check() error {
if x.Pagination == nil {
return errs.ErrArgs.Wrap("pagination is empty")
}
if x.Pagination.PageNumber < 1 {
return errs.ErrArgs.Wrap("pageNumber is invalid")
}
return nil
}
func (x *UserRegisterReq) Check() error {
if x.Secret == "" {
return errs.ErrArgs.Wrap("Secret is empty")
}
if x.Users == nil {
return errs.ErrArgs.Wrap("Users is empty")
}
return nil
}
func (x *GetGlobalRecvMessageOptReq) Check() error {
if x.UserID == "" {
return errs.ErrArgs.Wrap("UserID is empty")
}
return nil
}
func (x *UserRegisterCountReq) Check() error {
if x.Start <= 0 {
return errs.ErrArgs.Wrap("start is invalid")
}
if x.End <= 0 {
return errs.ErrArgs.Wrap("end is invalid")
}
return nil
}
Loading…
Cancel
Save