summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/mattermost-server/v5/model/reaction.go
diff options
context:
space:
mode:
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.go40
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("")
+ }
}