Add list shared with user event
This commit is contained in:
parent
1c5dfb024b
commit
3f4fda1548
|
@ -105,3 +105,17 @@ type ListUpdatedEvent struct {
|
||||||
func (l *ListUpdatedEvent) TopicName() string {
|
func (l *ListUpdatedEvent) TopicName() string {
|
||||||
return "list.updated"
|
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"
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"code.vikunja.io/api/pkg/events"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.vikunja.io/api/pkg/user"
|
"code.vikunja.io/api/pkg/user"
|
||||||
|
@ -112,6 +113,19 @@ func (lu *ListUser) 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(&ListSharedWithUserEvent{
|
||||||
|
List: l,
|
||||||
|
User: u,
|
||||||
|
Doer: doer,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = updateListLastUpdated(s, l)
|
err = updateListLastUpdated(s, l)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue