diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 55ef31acf..ef33b9867 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -18,19 +18,20 @@ const ( ///ContentType //UserRelated - Text = 101 - Picture = 102 - Voice = 103 - Video = 104 - File = 105 - AtText = 106 - Merger = 107 - Card = 108 - Location = 109 - Custom = 110 - Revoke = 111 - Typing = 113 - Quote = 114 + ContentTypeBegin = 100 + Text = 101 + Picture = 102 + Voice = 103 + Video = 104 + File = 105 + AtText = 106 + Merger = 107 + Card = 108 + Location = 109 + Custom = 110 + Revoke = 111 + Typing = 113 + Quote = 114 AdvancedText = 117 diff --git a/pkg/proto/sdkws/sdkws.go b/pkg/proto/sdkws/sdkws.go index 1c0888745..d0b0ae8aa 100644 --- a/pkg/proto/sdkws/sdkws.go +++ b/pkg/proto/sdkws/sdkws.go @@ -26,10 +26,10 @@ func (x *MsgData) Check() error { 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.ContentType <= constant.ContentTypeBegin || x.ContentType >= constant.NotificationEnd { + return errs.ErrArgs.Wrap("content type is invalid") } - if x.SessionType < 1 || x.SessionType > 4 { + if x.SessionType < constant.SingleChatType || x.SessionType > constant.NotificationChatType { return errs.ErrArgs.Wrap("sessionType is invalid") } if x.SessionType == constant.SingleChatType || x.SessionType == constant.NotificationChatType {