fix bug ContentType is wrong range for Check

pull/528/head
skiffer-git 1 year ago
parent 4684a428f5
commit 95ec99daf0

@ -4,19 +4,20 @@ const (
///ContentType ///ContentType
//UserRelated //UserRelated
Text = 101 ContentTypeBegin = 100
Picture = 102 Text = 101
Voice = 103 Picture = 102
Video = 104 Voice = 103
File = 105 Video = 104
AtText = 106 File = 105
Merger = 107 AtText = 106
Card = 108 Merger = 107
Location = 109 Card = 108
Custom = 110 Location = 109
Revoke = 111 Custom = 110
Typing = 113 Revoke = 111
Quote = 114 Typing = 113
Quote = 114
AdvancedText = 117 AdvancedText = 117

@ -12,10 +12,10 @@ func (x *MsgData) Check() error {
if x.Content == nil { if x.Content == nil {
return errs.ErrArgs.Wrap("content is empty") return errs.ErrArgs.Wrap("content is empty")
} }
if x.ContentType < 101 || x.ContentType > 203 { if x.ContentType <= constant.ContentTypeBegin || x.ContentType >= constant.NotificationEnd {
return errs.ErrArgs.Wrap("content is empty") 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") return errs.ErrArgs.Wrap("sessionType is invalid")
} }
if x.SessionType == constant.SingleChatType || x.SessionType == constant.NotificationChatType { if x.SessionType == constant.SingleChatType || x.SessionType == constant.NotificationChatType {

Loading…
Cancel
Save