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 {
|
func (l *ListSharedWithUserEvent) TopicName() string {
|
||||||
return "list.shared.user"
|
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
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.vikunja.io/api/pkg/events"
|
||||||
|
"code.vikunja.io/api/pkg/user"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.vikunja.io/web"
|
"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
|
// Check if the team exists
|
||||||
_, err = GetTeamByID(s, tl.TeamID)
|
team, err := GetTeamByID(s, tl.TeamID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the list exists
|
// Check if the list exists
|
||||||
|
@ -105,6 +107,16 @@ func (tl *TeamList) Create(s *xorm.Session, a web.Auth) (err error) {
|
||||||
return err
|
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)
|
err = updateListLastUpdated(s, l)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue