2022-09-28 09:01:17 +02:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import "github.com/photoprism/photoprism/pkg/react"
|
|
|
|
|
|
|
|
type ReactionMap map[string]Reaction
|
|
|
|
|
|
|
|
func (m ReactionMap) Get(name string) Reaction {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
|
|
|
return Reaction{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m ReactionMap) Pointer(name string) *Reaction {
|
|
|
|
if result, ok := m[name]; ok {
|
|
|
|
return &result
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Reaction{}
|
|
|
|
}
|
|
|
|
|
|
|
|
var ReactionFixtures = ReactionMap{
|
|
|
|
"SubjectJohnLike": Reaction{
|
2022-10-08 19:13:39 +02:00
|
|
|
UID: SubjectFixtures.Get("john-doe").SubjUID,
|
|
|
|
UserUID: UserFixtures.Get("alice").UserUID,
|
|
|
|
Reaction: react.Like.String(),
|
|
|
|
Reacted: 1,
|
|
|
|
ReactedAt: TimePointer(),
|
2022-09-28 09:01:17 +02:00
|
|
|
},
|
|
|
|
"PhotoAliceLove": Reaction{
|
2022-10-08 19:13:39 +02:00
|
|
|
UID: PhotoFixtures.Get("Photo01").PhotoUID,
|
|
|
|
UserUID: UserFixtures.Pointer("alice").UserUID,
|
|
|
|
Reaction: react.Love.String(),
|
|
|
|
Reacted: 3,
|
|
|
|
ReactedAt: TimePointer(),
|
2022-09-28 09:01:17 +02:00
|
|
|
},
|
|
|
|
"PhotoBobLove": Reaction{
|
2022-10-08 19:13:39 +02:00
|
|
|
UID: PhotoFixtures.Get("Photo01").PhotoUID,
|
|
|
|
UserUID: UserFixtures.Pointer("bob").UserUID,
|
|
|
|
Reaction: react.Love.String(),
|
|
|
|
Reacted: 1,
|
|
|
|
ReactedAt: TimePointer(),
|
2022-09-28 09:01:17 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateReactionFixtures inserts known entities into the database for testing.
|
|
|
|
func CreateReactionFixtures() {
|
|
|
|
for _, entity := range ReactionFixtures {
|
2022-10-08 19:13:39 +02:00
|
|
|
Db().Create(&entity)
|
2022-09-28 09:01:17 +02:00
|
|
|
}
|
|
|
|
}
|