Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ Each release lists **Upgrade notes** when an install needs action beyond the ste

## [Unreleased]

### Added

- **Watch tasks** (Configuration → Work items → *Task watchers*, off by default): a Watch / Watching button with the watcher count and list in the task header, and a **Watching** filter (bell menu → *Tasks I'm watching*). The creator, developer and tester watch a task automatically, as does anyone who comments on it; anyone can unwatch, and that choice sticks. Watchers get an in-app notification when the status, developer/tester or comments change, including changes from Git merge requests, bulk updates and issue sync, but never for their own changes. Members who can no longer see the task stop receiving them. *E-mail watchers* also sends them by e-mail. ([#15](https://github.com/Taskist/taskist/issues/15))

### Upgrade notes

- New additive migration `AddBacklogWatcher` (table `BacklogWatcher`), applied automatically by Docker; manual installs run `dotnet ef database update` or the regenerated `sql-scripts/01_schema.sql`. Re-run `sql-scripts/03_locale.sql` for the new labels.

## [1.1.0] - 2026-11-16

The first tagged release of Taskist as an open-source project, including single sign-on and two-factor sign-in from the 1.1 roadmap.
Expand Down
47 changes: 47 additions & 0 deletions sql-scripts/01_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2122,3 +2122,50 @@ END;
COMMIT;
GO

BEGIN TRANSACTION;
IF NOT EXISTS (
SELECT * FROM [__EFMigrationsHistory]
WHERE [MigrationId] = N'20261201192407_AddBacklogWatcher'
)
BEGIN
CREATE TABLE [BacklogWatcher] (
[Id] int NOT NULL IDENTITY,
[BacklogId] int NOT NULL,
[UserId] int NOT NULL,
[Watching] bit NOT NULL,
[Source] int NOT NULL,
[CreatedOn] datetime2 NOT NULL,
CONSTRAINT [PK_BacklogWatcher] PRIMARY KEY ([Id]),
CONSTRAINT [FK_BacklogWatcher_Backlog_BacklogId] FOREIGN KEY ([BacklogId]) REFERENCES [Backlog] ([Id]),
CONSTRAINT [FK_BacklogWatcher_User_UserId] FOREIGN KEY ([UserId]) REFERENCES [User] ([Id])
);
END;

IF NOT EXISTS (
SELECT * FROM [__EFMigrationsHistory]
WHERE [MigrationId] = N'20261201192407_AddBacklogWatcher'
)
BEGIN
CREATE UNIQUE INDEX [IX_BacklogWatcher_BacklogId_UserId] ON [BacklogWatcher] ([BacklogId], [UserId]);
END;

IF NOT EXISTS (
SELECT * FROM [__EFMigrationsHistory]
WHERE [MigrationId] = N'20261201192407_AddBacklogWatcher'
)
BEGIN
CREATE INDEX [IX_BacklogWatcher_UserId_Watching] ON [BacklogWatcher] ([UserId], [Watching]);
END;

IF NOT EXISTS (
SELECT * FROM [__EFMigrationsHistory]
WHERE [MigrationId] = N'20261201192407_AddBacklogWatcher'
)
BEGIN
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20261201192407_AddBacklogWatcher', N'10.0.13');
END;

COMMIT;
GO

9 changes: 9 additions & 0 deletions sql-scripts/03_locale.sql
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ FROM (VALUES
(N'Backlog.UnlinkedBranches.Prompt', N'Task number(s) to link this branch to'),
(N'Backlog.UnlinkedBranches.PushedBy', N'pushed by'),
(N'Backlog.UnlinkedBranches.Title', N'Branches not linked to a task'),
(N'Backlog.Watch.Error', N'Couldn''t change watching. Please try again.'),
(N'Backlog.Watch.Hint', N'Watch this task to be notified of status changes, comments and reassignment'),
(N'Backlog.Watch.List', N'Watchers'),
(N'Backlog.Watch.None', N'No one is watching this task'),
(N'Backlog.Watch.UnwatchHint', N'You are watching this task. Click to stop notifications'),
(N'Backlog.Watch.Watch', N'Watch'),
(N'Backlog.Watch.Watching', N'Watching'),
(N'BacklogFilter.Any', N'Any'),
(N'BacklogFilter.CollapseAll', N'Collapse all'),
(N'BacklogFilter.ExpandAll', N'Expand all'),
Expand All @@ -207,6 +214,7 @@ FROM (VALUES
(N'BacklogFilter.Preset.Release', N'Release'),
(N'BacklogFilter.Preset.Reopened', N'Reopened'),
(N'BacklogFilter.Preset.Resolved', N'Resolved'),
(N'BacklogFilter.Preset.Watching', N'Watching'),
(N'BacklogFilter.SaveAs', N'Save as'),
(N'BacklogFilter.Section.Dates', N'Dates & age'),
(N'BacklogFilter.Section.Module', N'Module'),
Expand Down Expand Up @@ -577,6 +585,7 @@ FROM (VALUES
(N'Header.Notifications', N'Notifications'),
(N'Header.OverdueTasks', N'overdue task(s)'),
(N'Header.SearchPlaceholder', N'Search tasks, people...'),
(N'Header.WatchedTasks', N'Tasks I''m watching'),
(N'HeaderMenu.ChangePassword', N'Change Password'),
(N'HeaderMenu.DarkMode', N'Dark mode'),
(N'HeaderMenu.LightMode', N'Light mode'),
Expand Down
56 changes: 56 additions & 0 deletions src/Libraries/Taskist.Core/Common/WatcherRecipients.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Taskist.Core.Domain.WorkItems;

namespace Taskist.Core.Common;

public static class WatcherRecipients
{
#region Methods

public static IReadOnlyList<int> Implicit(int createdById, int? assigneeId, int? testerId)
{
return new[] { createdById, assigneeId ?? 0, testerId ?? 0 }
.Where(x => x > 0)
.Distinct()
.ToList();
}

public static bool IsWatching(int userId, IEnumerable<int> implicitWatchers, IEnumerable<BacklogWatcher> rows)
{
var row = rows.FirstOrDefault(x => x.UserId == userId);
if (row != null)
return row.Watching;

return implicitWatchers.Contains(userId);
}

public static IReadOnlyList<int> Watchers(IEnumerable<int> implicitWatchers, IEnumerable<BacklogWatcher> rows)
{
var list = rows.ToList();
var optedOut = list.Where(x => !x.Watching).Select(x => x.UserId).ToHashSet();

return implicitWatchers
.Concat(list.Where(x => x.Watching).Select(x => x.UserId))
.Where(x => x > 0 && !optedOut.Contains(x))
.Distinct()
.OrderBy(x => x)
.ToList();
}

public static IReadOnlyList<int> Resolve(IEnumerable<int> implicitWatchers, IEnumerable<BacklogWatcher> rows, int? actorId,
IEnumerable<int>? alsoNotify = null, IEnumerable<int>? skip = null)
{
var list = rows.ToList();
var optedOut = list.Where(x => !x.Watching).Select(x => x.UserId).ToHashSet();
var skipped = (skip ?? []).ToHashSet();

return implicitWatchers
.Concat(list.Where(x => x.Watching).Select(x => x.UserId))
.Concat(alsoNotify ?? [])
.Where(x => x > 0 && x != actorId && !optedOut.Contains(x) && !skipped.Contains(x))
.Distinct()
.OrderBy(x => x)
.ToList();
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ public class WorkItemSettings : ISettings
public string ReleaseVersionFormat { get; set; } = "{major}.{minor}.{patch}";

public int ReleaseFullIncrement { get; set; } = 2;

public bool TaskWatchersEnabled { get; set; }

public bool TaskWatcherEmail { get; set; }
}
21 changes: 21 additions & 0 deletions src/Libraries/Taskist.Core/Domain/WorkItems/BacklogWatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Taskist.Core.Domain.Common;
using Taskist.Core.Domain.Users;

namespace Taskist.Core.Domain.WorkItems;

public class BacklogWatcher : BaseEntity
{
public int BacklogId { get; set; }

public int UserId { get; set; }

public bool Watching { get; set; }

public int Source { get; set; }

public DateTime CreatedOn { get; set; }

public virtual Backlog Backlog { get; set; }

public virtual User User { get; set; }
}
18 changes: 18 additions & 0 deletions src/Libraries/Taskist.Core/Dtos/WorkItems/TaskWatchNotice.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Taskist.Core.Enums;

namespace Taskist.Core.Dtos.WorkItems;

public class TaskWatchNotice
{
public NotificationType Type { get; set; }

public string Detail { get; set; } = string.Empty;

public int? ActorId { get; set; }

public string? ActorName { get; set; }

public List<int> AlsoNotify { get; set; } = [];

public List<int> Skip { get; set; } = [];
}
10 changes: 10 additions & 0 deletions src/Libraries/Taskist.Core/Dtos/WorkItems/TaskWatchState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Taskist.Core.Dtos.WorkItems;

public class TaskWatchState
{
public bool Enabled { get; set; }

public bool Watching { get; set; }

public List<string> Watchers { get; set; } = [];
}
5 changes: 4 additions & 1 deletion src/Libraries/Taskist.Core/Enums/NotificationType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ public enum NotificationType
MergeRequestRejected,
MergeRequestComment,
MergeRequestConflict,
MergeRequestClosed
MergeRequestClosed,
TaskStatusChanged,
TaskCommented,
TaskAssignmentChanged
}
8 changes: 8 additions & 0 deletions src/Libraries/Taskist.Core/Enums/WatchSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Taskist.Core.Enums;

public enum WatchSource
{
Manual = 1,
Commented,
Mentioned
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Taskist.Core.Domain.WorkItems;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Taskist.Data.Configuration.WorkItems;

public class BacklogWatcherConfig : EntityTypeConfiguration<BacklogWatcher>
{
public override void Configure(EntityTypeBuilder<BacklogWatcher> builder)
{
builder.ToTable(nameof(BacklogWatcher));

builder.HasKey(x => x.Id);

builder.HasOne(f => f.Backlog)
.WithMany()
.HasForeignKey(p => p.BacklogId)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();

builder.HasOne(f => f.User)
.WithMany()
.HasForeignKey(p => p.UserId)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();

builder.HasIndex(p => new { p.BacklogId, p.UserId })
.IsUnique();

builder.HasIndex(p => new { p.UserId, p.Watching });

base.Configure(builder);
}
}
Loading
Loading