Add list updated event

This commit is contained in:
kolaente 2021-01-31 22:03:33 +01:00
parent 90ec98ed23
commit 1c5dfb024b
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 23 additions and 1 deletions

View File

@ -96,3 +96,12 @@ type ListCreatedEvent struct {
func (l *ListCreatedEvent) TopicName() string {
return "list.created"
}
type ListUpdatedEvent struct {
List *List
Doer *user.User
}
func (l *ListUpdatedEvent) TopicName() string {
return "list.updated"
}

View File

@ -543,7 +543,20 @@ func CreateOrUpdateList(s *xorm.Session, list *List, auth web.Auth) (err error)
// @Failure 500 {object} models.Message "Internal error"
// @Router /lists/{id} [post]
func (l *List) Update(s *xorm.Session, a web.Auth) (err error) {
return CreateOrUpdateList(s, l, a)
err = CreateOrUpdateList(s, l, a)
if err != nil {
return err
}
doer, err := user.GetFromAuth(a)
if err != nil {
return err
}
return events.Publish(&ListUpdatedEvent{
List: l,
Doer: doer,
})
}
func updateListLastUpdated(s *xorm.Session, list *List) error {