parent
6ed4e759b0
commit
79be66a7d5
|
|
@ -992,6 +992,17 @@ func createTask(s *xorm.Session, t *Task, a web.Auth, updateAssignees bool, setB
|
|||
|
||||
t.CreatedBy = createdBy
|
||||
|
||||
// Auto-subscribe the creator to the task so they receive
|
||||
// notifications on comments and changes.
|
||||
sub := &Subscription{
|
||||
UserID: createdBy.ID,
|
||||
EntityType: SubscriptionEntityTask,
|
||||
EntityID: t.ID,
|
||||
}
|
||||
if err := sub.Create(s, a); err != nil && !IsErrSubscriptionAlreadyExists(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
// Update the assignees
|
||||
if updateAssignees {
|
||||
if err := t.updateTaskAssignees(s, t.Assignees, a); err != nil {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ func TestTask_Create(t *testing.T) {
|
|||
"task_id": task.ID,
|
||||
"bucket_id": 1,
|
||||
}, false)
|
||||
// Assert the creator is auto-subscribed to the task
|
||||
db.AssertExists(t, "subscriptions", map[string]interface{}{
|
||||
"user_id": usr.ID,
|
||||
"entity_type": SubscriptionEntityTask,
|
||||
"entity_id": task.ID,
|
||||
}, false)
|
||||
|
||||
events.DispatchPending(s)
|
||||
events.AssertDispatched(t, &TaskCreatedEvent{})
|
||||
|
|
|
|||
Loading…
Reference in New Issue