From 79be66a7d5e7c69016960ed5143e68124a853973 Mon Sep 17 00:00:00 2001 From: Jan Grasnick Date: Sat, 25 Apr 2026 13:21:00 +0200 Subject: [PATCH] feat: auto-subscribe task creator to their own task Fixes #2692 --- pkg/models/tasks.go | 11 +++++++++++ pkg/models/tasks_test.go | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index b7515b40a..13d64dbc2 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -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 { diff --git a/pkg/models/tasks_test.go b/pkg/models/tasks_test.go index caa897740..89676c7fe 100644 --- a/pkg/models/tasks_test.go +++ b/pkg/models/tasks_test.go @@ -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{})