Add events #777

Merged
konrad merged 47 commits from feature/events into master 2021-02-02 22:48:38 +00:00
2 changed files with 28 additions and 0 deletions
Showing only changes of commit 3f4fda1548 - Show all commits

View File

@ -105,3 +105,17 @@ type ListUpdatedEvent struct {
func (l *ListUpdatedEvent) TopicName() string {
return "list.updated"
}
////////////////////
// Sharing Events //
////////////////////
type ListSharedWithUserEvent struct {
List *List
User *user.User
Doer *user.User
}
func (l *ListSharedWithUserEvent) TopicName() string {
return "list.shared.user"
}

View File

@ -17,6 +17,7 @@
package models
import (
"code.vikunja.io/api/pkg/events"
"time"
"code.vikunja.io/api/pkg/user"
@ -112,6 +113,19 @@ func (lu *ListUser) Create(s *xorm.Session, a web.Auth) (err error) {
return err
}
doer, err := user.GetFromAuth(a)
if err != nil {
return err
}
err = events.Publish(&ListSharedWithUserEvent{
List: l,
User: u,
Doer: doer,
})
if err != nil {
return err
}
err = updateListLastUpdated(s, l)
return
}