diff options
author | Wim <wim@42.be> | 2021-10-17 00:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-17 00:47:22 +0200 |
commit | 4dd8bae5c91fa4aef09d865d8fef1acd84f90925 (patch) | |
tree | ffad9b242daccaf8c86d1c1fbd59032302bd3be9 /vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go | |
parent | 7ae45c42e712bd0e66c101f3f714c05aa1dc2104 (diff) | |
download | matterbridge-msglm-4dd8bae5c91fa4aef09d865d8fef1acd84f90925.tar.gz matterbridge-msglm-4dd8bae5c91fa4aef09d865d8fef1acd84f90925.tar.bz2 matterbridge-msglm-4dd8bae5c91fa4aef09d865d8fef1acd84f90925.zip |
Update dependencies (#1610)
* Update dependencies
* Update module to go 1.17
Diffstat (limited to 'vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go')
-rw-r--r-- | vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go b/vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go index 50879c67..6d0ea68d 100644 --- a/vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go +++ b/vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go @@ -11,10 +11,13 @@ import ( ) type Reaction struct { - UserId string `json:"user_id"` - PostId string `json:"post_id"` - EmojiName string `json:"emoji_name"` - CreateAt int64 `json:"create_at"` + UserId string `json:"user_id"` + PostId string `json:"post_id"` + EmojiName string `json:"emoji_name"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + RemoteId *string `json:"remote_id"` } func (o *Reaction) ToJson() string { @@ -27,9 +30,8 @@ func ReactionFromJson(data io.Reader) *Reaction { if err := json.NewDecoder(data).Decode(&o); err != nil { return nil - } else { - return &o } + return &o } func ReactionsToJson(o []*Reaction) string { @@ -48,9 +50,8 @@ func MapPostIdToReactionsFromJson(data io.Reader) map[string][]*Reaction { var objmap map[string][]*Reaction if err := decoder.Decode(&objmap); err != nil { return make(map[string][]*Reaction) - } else { - return objmap } + return objmap } func ReactionsFromJson(data io.Reader) []*Reaction { @@ -58,9 +59,8 @@ func ReactionsFromJson(data io.Reader) []*Reaction { if err := json.NewDecoder(data).Decode(&o); err != nil { return nil - } else { - return o } + return o } func (o *Reaction) IsValid() *AppError { @@ -74,7 +74,7 @@ func (o *Reaction) IsValid() *AppError { validName := regexp.MustCompile(`^[a-zA-Z0-9\-\+_]+$`) - if len(o.EmojiName) == 0 || len(o.EmojiName) > EMOJI_NAME_MAX_LENGTH || !validName.MatchString(o.EmojiName) { + if o.EmojiName == "" || len(o.EmojiName) > EMOJI_NAME_MAX_LENGTH || !validName.MatchString(o.EmojiName) { return NewAppError("Reaction.IsValid", "model.reaction.is_valid.emoji_name.app_error", nil, "emoji_name="+o.EmojiName, http.StatusBadRequest) } @@ -82,6 +82,10 @@ func (o *Reaction) IsValid() *AppError { return NewAppError("Reaction.IsValid", "model.reaction.is_valid.create_at.app_error", nil, "", http.StatusBadRequest) } + if o.UpdateAt == 0 { + return NewAppError("Reaction.IsValid", "model.reaction.is_valid.update_at.app_error", nil, "", http.StatusBadRequest) + } + return nil } @@ -89,4 +93,18 @@ func (o *Reaction) PreSave() { if o.CreateAt == 0 { o.CreateAt = GetMillis() } + o.UpdateAt = GetMillis() + o.DeleteAt = 0 + + if o.RemoteId == nil { + o.RemoteId = NewString("") + } +} + +func (o *Reaction) PreUpdate() { + o.UpdateAt = GetMillis() + + if o.RemoteId == nil { + o.RemoteId = NewString("") + } } |