Add list shared with team event
This commit is contained in:
parent
3f4fda1548
commit
e8f2d577c2
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue