Add list shared with team event

This commit is contained in:
kolaente 2021-01-31 22:08:43 +01:00
parent 3f4fda1548
commit e8f2d577c2
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 24 additions and 2 deletions

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
}