Add events #777
|
@ -20,6 +20,10 @@ import (
|
|||
"code.vikunja.io/api/pkg/user"
|
||||
)
|
||||
|
||||
/////////////////
|
||||
// Task Events //
|
||||
/////////////////
|
||||
|
||||
type TaskCreatedEvent struct {
|
||||
Task *Task
|
||||
Doer *user.User
|
||||
|
@ -58,6 +62,10 @@ func (t *TaskCommentCreatedEvent) TopicName() string {
|
|||
return "task.comment.created"
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
// Namespace Events //
|
||||
//////////////////////
|
||||
|
||||
type NamespaceCreatedEvent struct {
|
||||
Namespace *Namespace
|
||||
Doer *user.User
|
||||
|
@ -66,3 +74,12 @@ type NamespaceCreatedEvent struct {
|
|||
func (n *NamespaceCreatedEvent) TopicName() string {
|
||||
return "namespace.created"
|
||||
}
|
||||
|
||||
type NamespaceUpdatedEvent struct {
|
||||
Namespace *Namespace
|
||||
Doer *user.User
|
||||
}
|
||||
|
||||
func (n *NamespaceUpdatedEvent) TopicName() string {
|
||||
return "namespace.updated"
|
||||
}
|
||||
|
|
|
@ -618,5 +618,16 @@ func (n *Namespace) Update(s *xorm.Session, a web.Auth) (err error) {
|
|||
ID(currentNamespace.ID).
|
||||
Cols(colsToUpdate...).
|
||||
Update(n)
|
||||
return
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
doer, err := user.GetFromAuth(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return events.Publish(&NamespaceUpdatedEvent{
|
||||
Namespace: n,
|
||||
Doer: doer,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue