feat: auto-subscribe task creator to their own task

Fixes #2692
This commit is contained in:
Jan Grasnick 2026-04-25 13:21:00 +02:00
parent 6ed4e759b0
commit 79be66a7d5
2 changed files with 17 additions and 0 deletions

View File

@ -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 {

View File

@ -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{})