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 24 additions and 2 deletions
Showing only changes of commit e8f2d577c2 - Show all commits

View File

@ -119,3 +119,13 @@ type ListSharedWithUserEvent struct {
func (l *ListSharedWithUserEvent) TopicName() string {
return "list.shared.user"
}
type ListSharedWithTeamEvent struct {
List *List
Team *Team
Doer *user.User
}
func (l *ListSharedWithTeamEvent) TopicName() string {
return "list.shared.team"
}

View File

@ -17,6 +17,8 @@
package models
import (
"code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/user"
"time"
"code.vikunja.io/web"
@ -77,9 +79,9 @@ func (tl *TeamList) Create(s *xorm.Session, a web.Auth) (err error) {
}
// Check if the team exists
_, err = GetTeamByID(s, tl.TeamID)
team, err := GetTeamByID(s, tl.TeamID)
if err != nil {
return
return err
}
// Check if the list exists
@ -105,6 +107,16 @@ func (tl *TeamList) Create(s *xorm.Session, a web.Auth) (err error) {
return err
}
doer, err := user.GetFromAuth(a)
if err != nil {
return err
}
err = events.Publish(&ListSharedWithTeamEvent{
List: l,
Team: team,
Doer: doer,
})
err = updateListLastUpdated(s, l)
return
}