diff --git a/pkg/models/favorites.go b/pkg/models/favorites.go index f04a685ab..5fcd6070e 100644 --- a/pkg/models/favorites.go +++ b/pkg/models/favorites.go @@ -23,6 +23,7 @@ import ( "xorm.io/xorm" ) +// FavoriteKind represents the kind of entities that can be marked as favorite type FavoriteKind int const ( @@ -31,12 +32,14 @@ const ( FavoriteKindList ) +// Favorite represents an entity which is a favorite to someone type Favorite struct { EntityID int64 `xorm:"bigint not null pk"` UserID int64 `xorm:"bigint not null pk"` Kind FavoriteKind `xorm:"int not null pk"` } +// TableName is the table name func (t *Favorite) TableName() string { return "favorites" } diff --git a/pkg/models/list.go b/pkg/models/list.go index 0d4cb56b6..2148e84b4 100644 --- a/pkg/models/list.go +++ b/pkg/models/list.go @@ -552,6 +552,9 @@ func CreateOrUpdateList(s *xorm.Session, list *List, auth web.Auth) (err error) if list.ID == 0 { _, err = s.Insert(list) + if err != nil { + return + } if list.IsFavorite { if err := addToFavorites(s, list.ID, auth, FavoriteKindList); err != nil { return err @@ -590,6 +593,9 @@ func CreateOrUpdateList(s *xorm.Session, list *List, auth web.Auth) (err error) ID(list.ID). Cols(colsToUpdate...). Update(list) + if err != nil { + return err + } } if err != nil { diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index 3c1461650..187df187d 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -998,6 +998,9 @@ func (t *Task) Update(s *xorm.Session, a web.Auth) (err error) { } wasFavorite, err := isFavorite(s, t.ID, a, FavoriteKindTask) + if err != nil { + return + } if t.IsFavorite && !wasFavorite { if err := addToFavorites(s, t.ID, a, FavoriteKindTask); err != nil { return err