Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(inbox): only archive your own notifications when you complete an issue, behind a setting (MUL-9336) (#10675)

Jiayuan Zhang12927cd2b30e
diff --git a/packages/core/notification-preferences/patch.ts b/packages/core/notification-preferences/patch.ts
index 437963205e..e8698afc7a 100644
--- a/packages/core/notification-preferences/patch.ts
+++ b/packages/core/notification-preferences/patch.ts
@@ -15,6 +15,7 @@ const NOTIFICATION_GROUP_KEYS: readonly NotificationGroupKey[] = [
"new_issues",
"agent_activity",
"system_notifications",
+ "auto_archive_completed",
];
function preferenceValue(
diff --git a/packages/core/types/notification-preference.ts b/packages/core/types/notification-preference.ts
index 6e12791a06..3e2e4866df 100644
--- a/packages/core/types/notification-preference.ts
+++ b/packages/core/types/notification-preference.ts
@@ -8,7 +8,8 @@ export type NotificationGroupKey =
| "updates"
| "new_issues"
| "agent_activity"
- | "system_notifications";
+ | "system_notifications"
+ | "auto_archive_completed";
export type NotificationGroupValue = "all" | "muted";
diff --git a/packages/views/locales/en/settings.json b/packages/views/locales/en/settings.json
index ddffb3822f..439727f6cd 100644
--- a/packages/views/locales/en/settings.json
+++ b/packages/views/locales/en/settings.json
@@ -845,9 +845,8 @@
"manual_label": "Archive by hand",
"manual_description": "From its row in the sidebar, or the top of the notification",
"manual_value": "Anytime",
- "done_label": "Issue done or cancelled",
- "done_description": "When an issue reaches a Done or Cancelled status, its notifications are archived.",
- "done_value": "Automatic",
+ "done_label": "Archive issues you complete",
+ "done_description": "When you move an issue to Done or Cancelled, its notifications are archived. Issues others complete stay in your Inbox.",
"archived_label": "Archived notifications",
"archived_description": "Find them again and unarchive them",
"archived_action": "View archived"
diff --git a/packages/views/locales/es/settings.json b/packages/views/locales/es/settings.json
index 4835efea6f..907d507ed5 100644
--- a/packages/views/locales/es/settings.json
+++ b/packages/views/locales/es/settings.json
@@ -845,9 +845,8 @@
"manual_label": "Archivar a mano",
"manual_description": "Desde su fila en la barra lateral o desde la parte superior de la notificación",
"manual_value": "En cualquier momento",
- "done_label": "Tarea completada o cancelada",
- "done_description": "Cuando una tarea pasa a un estado Completado o Cancelado, sus notificaciones se archivan.",
- "done_value": "Automático",
+ "done_label": "Archivar las tareas que completas",
+ "done_description": "Cuando pasas una tarea a un estado Completado o Cancelado, sus notificaciones se archivan. Las que completan otros se quedan en la bandeja de entrada.",
"archived_label": "Notificaciones archivadas",
"archived_description": "Encuéntralas de nuevo y desarchívalas",
"archived_action": "Ver archivadas"
diff --git a/packages/views/locales/fr/settings.json b/packages/views/locales/fr/settings.json
index 8c5a78abe6..241d109880 100644
--- a/packages/views/locales/fr/settings.json
+++ b/packages/views/locales/fr/settings.json
@@ -845,9 +845,8 @@
"manual_label": "Archiver à la main",
"manual_description": "Depuis sa ligne dans la barre latérale ou le haut de la notification",
"manual_value": "À tout moment",
- "done_label": "Tâche terminée ou annulée",
- "done_description": "Quand une tâche passe à un statut Terminé ou Annulé, ses notifications sont archivées.",
- "done_value": "Automatique",
+ "done_label": "Archiver les tâches que vous terminez",
+ "done_description": "Quand vous passez une tâche à un statut Terminé ou Annulé, ses notifications sont archivées. Celles terminées par d'autres restent dans la boîte de réception.",
"archived_label": "Notifications archivées",
"archived_description": "Retrouvez-les et désarchivez-les",
"archived_action": "Voir les archivées"
diff --git a/packages/views/locales/ja/settings.json b/packages/views/locales/ja/settings.json
index 2e8d103e2d..b0956cfc78 100644
--- a/packages/views/locales/ja/settings.json
+++ b/packages/views/locales/ja/settings.json
@@ -836,9 +836,8 @@
"manual_label": "手動でアーカイブ",
"manual_description": "サイドバーの行、または通知の上部から",
"manual_value": "いつでも",
- "done_label": "タスクが完了・キャンセル",
- "done_description": "タスクが完了系またはキャンセル系のステータスになると、その通知はアーカイブされます。",
- "done_value": "自動",
+ "done_label": "自分が完了したタスクをアーカイブ",
+ "done_description": "タスクを完了系またはキャンセル系のステータスにすると、その通知はアーカイブされます。他の人が完了したタスクはインボックスに残ります。",
"archived_label": "アーカイブ済みの通知",
"archived_description": "ここから見つけてアーカイブを解除できます",
"archived_action": "アーカイブ済みを表示"
diff --git a/packages/views/locales/ko/settings.json b/packages/views/locales/ko/settings.json
index 681336d623..1c8e1cf225 100644
--- a/packages/views/locales/ko/settings.json
+++ b/packages/views/locales/ko/settings.json
@@ -836,9 +836,8 @@
"manual_label": "직접 보관",
"manual_description": "사이드바의 행이나 알림 상단에서",
"manual_value": "언제든지",
- "done_label": "태스크 완료 또는 취소",
- "done_description": "태스크가 완료 또는 취소 계열 상태가 되면 그 알림은 보관됩니다.",
- "done_value": "자동",
+ "done_label": "내가 완료한 태스크 보관",
+ "done_description": "태스크를 완료 또는 취소 계열 상태로 바꾸면 그 알림은 보관됩니다. 다른 사람이 완료한 태스크는 인박스에 남습니다.",
"archived_label": "보관된 알림",
"archived_description": "여기서 다시 찾고 보관을 해제할 수 있습니다",
"archived_action": "보관된 알림 보기"
diff --git a/packages/views/locales/ru/settings.json b/packages/views/locales/ru/settings.json
index 560ef7066a..7fc1e8e41b 100644
--- a/packages/views/locales/ru/settings.json
+++ b/packages/views/locales/ru/settings.json
@@ -862,9 +862,8 @@
"manual_label": "Архивировать вручную",
"manual_description": "Из строки на боковой панели или в верхней части уведомления",
"manual_value": "В любой момент",
- "done_label": "Задача выполнена или отменена",
- "done_description": "Когда задача переходит в статус «Выполнено» или «Отменено», её уведомления архивируются.",
- "done_value": "Автоматически",
+ "done_label": "Архивировать задачи, которые вы завершили",
+ "done_description": "Когда вы переводите задачу в статус «Выполнено» или «Отменено», её уведомления архивируются. Задачи, завершённые другими, остаются во «Входящих».",
"archived_label": "Архивные уведомления",
"archived_description": "Здесь их можно найти и вернуть из архива",
"archived_action": "Открыть архив"
diff --git a/packages/views/locales/zh-Hans/settings.json b/packages/views/locales/zh-Hans/settings.json
index fbadaa400c..ba089fc582 100644
--- a/packages/views/locales/zh-Hans/settings.json
+++ b/packages/views/locales/zh-Hans/settings.json
@@ -836,9 +836,8 @@
"manual_label": "手动归档",
"manual_description": "在侧栏行上或通知详情顶部点归档",
"manual_value": "随时",
- "done_label": "任务已完成或已取消",
- "done_description": "任务进入「已完成」或「已取消」类状态时,它的通知自动归档。",
- "done_value": "自动",
+ "done_label": "自动归档我完成的任务",
+ "done_description": "你把任务改为「已完成」或「已取消」类状态时,它的通知自动归档。别人完成的任务会留在收件箱。",
"archived_label": "已归档的通知",
"archived_description": "可以在这里找回并取消归档",
"archived_action": "查看已归档"
diff --git a/packages/views/locales/zh-Hant/settings.json b/packages/views/locales/zh-Hant/settings.json
index 2902eaab40..086e93de9e 100644
--- a/packages/views/locales/zh-Hant/settings.json
+++ b/packages/views/locales/zh-Hant/settings.json
@@ -836,9 +836,8 @@
"manual_label": "手動歸檔",
"manual_description": "在側欄列上或通知詳情頂部點歸檔",
"manual_value": "隨時",
- "done_label": "任務已完成或已取消",
- "done_description": "任務進入「已完成」或「已取消」類狀態時,它的通知自動歸檔。",
- "done_value": "自動",
+ "done_label": "自動歸檔我完成的任務",
+ "done_description": "你把任務改為「已完成」或「已取消」類狀態時,它的通知自動歸檔。別人完成的任務會留在收件箱。",
"archived_label": "已歸檔的通知",
"archived_description": "可以在這裡找回並取消歸檔",
"archived_action": "查看已歸檔"
diff --git a/packages/views/settings/components/notifications-tab.test.tsx b/packages/views/settings/components/notifications-tab.test.tsx
index 5d6d6d1c97..01b81fc719 100644
--- a/packages/views/settings/components/notifications-tab.test.tsx
+++ b/packages/views/settings/components/notifications-tab.test.tsx
@@ -69,12 +69,23 @@ describe("Inbox notification settings", () => {
renderTab();
const leaving = screen.getByRole("region", { name: "Leaving the Inbox" });
expect(leaving).toHaveTextContent("Reading a notification doesn't take it out of the Inbox.");
- expect(leaving).toHaveTextContent("reaches a Done or Cancelled status");
+ expect(leaving).toHaveTextContent("Issues others complete stay in your Inbox.");
expect(within(leaving).getByRole("link", { name: "View archived" })).toHaveAttribute(
"href",
"/acme/inbox?view=archived",
);
});
+
+ it.each<{ preferences: Record<string, string>; checked: boolean }>([
+ { preferences: {}, checked: true },
+ { preferences: { auto_archive_completed: "muted" }, checked: false },
+ ])("toggles archiving issues you complete: %j", ({ preferences, checked }) => {
+ renderTab(preferences);
+ const leaving = screen.getByRole("region", { name: "Leaving the Inbox" });
+ const toggle = within(leaving).getByRole("switch", { name: "Archive issues you complete" });
+ if (checked) expect(toggle).toBeChecked();
+ else expect(toggle).not.toBeChecked();
+ });
});
describe("notification setting hierarchy", () => {
diff --git a/packages/views/settings/components/notifications-tab.tsx b/packages/views/settings/components/notifications-tab.tsx
index b4d928c803..5c8eb280b1 100644
--- a/packages/views/settings/components/notifications-tab.tsx
+++ b/packages/views/settings/components/notifications-tab.tsx
@@ -113,12 +113,15 @@ export function NotificationsTab() {
</span>
</SettingsRow>
<SettingsRow
+ anchor="auto_archive_completed"
label={t(($) => $.notifications.leaving.done_label)}
description={t(($) => $.notifications.leaving.done_description)}
>
- <span className="text-caption text-muted-foreground">
- {t(($) => $.notifications.leaving.done_value)}
- </span>
+ <Switch
+ checked={preferences.auto_archive_completed !== "muted"}
+ aria-label={t(($) => $.notifications.leaving.done_label)}
+ onCheckedChange={(checked) => handleToggle("auto_archive_completed", checked)}
+ />
</SettingsRow>
<SettingsRow
anchor="archived"
diff --git a/packages/views/settings/components/use-settings-search-index.ts b/packages/views/settings/components/use-settings-search-index.ts
index 4d7c9eed68..de155aae43 100644
--- a/packages/views/settings/components/use-settings-search-index.ts
+++ b/packages/views/settings/components/use-settings-search-index.ts
@@ -182,6 +182,12 @@ export function useSettingsSearchIndex(
title: t(($) => $.notifications.groups[group].label),
description: t(($) => $.notifications.groups[group].description),
})),
+ {
+ tab: "notifications",
+ anchor: "auto_archive_completed",
+ title: t(($) => $.notifications.leaving.done_label),
+ description: t(($) => $.notifications.leaving.done_description),
+ },
{
tab: "notifications",
anchor: "archived",
diff --git a/server/cmd/server/notification_listeners.go b/server/cmd/server/notification_listeners.go
index 3f2a6b609e..0000fbdff6 100644
--- a/server/cmd/server/notification_listeners.go
+++ b/server/cmd/server/notification_listeners.go
@@ -3,8 +3,10 @@ package main
import (
"context"
"encoding/json"
+ "errors"
"log/slog"
+ "github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgtype"
"github.com/multica-ai/multica/server/internal/events"
"github.com/multica-ai/multica/server/internal/handler"
@@ -244,38 +246,78 @@ func archiveStaleTaskFailedInbox(
"row_count", len(rows), "recipient_count", count)
}
-// archiveTerminalIssueInbox archives every recipient's notifications for an
-// issue that reached a done or closed status: finished or abandoned work
-// leaves the inbox whether or not it was read, the same set "Archive
-// completed" clears by hand.
+// autoArchiveCompletedPref is the preference key for archiving your own
+// notifications when you move an issue to a done or closed status. It is on
+// unless set to "muted".
+const autoArchiveCompletedPref = "auto_archive_completed"
+
+// archiveTerminalIssueInbox archives the actor's own notifications for an
+// issue they moved to a done or closed status, read or not, the same set
+// "Archive completed" clears by hand. Other recipients keep theirs: someone
+// else finishing an issue is news they have not seen yet.
func archiveTerminalIssueInbox(
ctx context.Context,
queries *db.Queries,
bus *events.Bus,
workspaceID string,
issueID string,
+ actorType string,
+ actorID string,
) {
- rows, err := queries.ArchiveInboxByIssueForAllRecipients(ctx, db.ArchiveInboxByIssueForAllRecipientsParams{
+ if actorType != "member" || actorID == "" {
+ return
+ }
+
+ // FAIL CLOSED: archiving on a guess hides notifications the user wanted.
+ pref, err := queries.GetNotificationPreference(ctx, db.GetNotificationPreferenceParams{
WorkspaceID: parseUUID(workspaceID),
- IssueID: parseUUID(issueID),
+ UserID: parseUUID(actorID),
+ })
+ switch {
+ case errors.Is(err, pgx.ErrNoRows):
+ case err != nil:
+ slog.Warn("auto-archive terminal issue inbox: load preference failed; keeping rows",
+ "workspace_id", workspaceID, "issue_id", issueID, "error", err)
+ return
+ default:
+ var prefs map[string]string
+ if err := json.Unmarshal(pref.Preferences, &prefs); err != nil {
+ slog.Warn("auto-archive terminal issue inbox: bad preference JSON; keeping rows",
+ "workspace_id", workspaceID, "issue_id", issueID, "error", err)
+ return
+ }
+ if prefs[autoArchiveCompletedPref] == "muted" {
+ return
+ }
+ }
+
+ count, err := queries.ArchiveInboxByIssue(ctx, db.ArchiveInboxByIssueParams{
+ WorkspaceID: parseUUID(workspaceID),
+ RecipientType: "member",
+ RecipientID: parseUUID(actorID),
+ IssueID: parseUUID(issueID),
})
if err != nil {
slog.Error("auto-archive terminal issue inbox: query failed",
"workspace_id", workspaceID, "issue_id", issueID, "error", err)
return
}
- if len(rows) == 0 {
+ if count == 0 {
return
}
- recipients := make([]inboxArchivedRecipient, len(rows))
- for i, row := range rows {
- recipients[i] = inboxArchivedRecipient{Type: row.RecipientType, ID: row.RecipientID}
- }
- count := publishInboxBatchArchived(bus, workspaceID, issueID, recipients)
+ bus.Publish(events.Event{
+ Type: protocol.EventInboxBatchArchived,
+ WorkspaceID: workspaceID,
+ Payload: map[string]any{
+ "recipient_id": actorID,
+ "count": count,
+ "issue_id": issueID,
+ "reason": "issue_status_terminal",
+ },
+ })
slog.Info("auto-archive terminal issue inbox: archived rows",
- "workspace_id", workspaceID, "issue_id", issueID,
- "row_count", len(rows), "recipient_count", count)
+ "workspace_id", workspaceID, "issue_id", issueID, "row_count", count)
}
type inboxArchivedRecipient struct {
@@ -1034,14 +1076,15 @@ func registerNotificationListeners(bus *events.Bus, queries *db.Queries) {
}
// After the status_changed rows above, so "moved to Done" leaves
- // the inbox together with the rest of the issue's notifications.
+ // the actor's inbox together with the rest of the issue's
+ // notifications.
category, categoryErr := issuestatus.CategoryWithError(ctx, queries, parseUUID(e.WorkspaceID), issue.Status)
switch {
case categoryErr != nil:
slog.Warn("resolve issue status category for terminal-issue inbox archive; keeping rows",
"issue_id", issue.ID, "status", issue.Status, "error", categoryErr)
case category == issuestatus.CategoryDone, category == issuestatus.CategoryClosed:
- archiveTerminalIssueInbox(ctx, queries, bus, e.WorkspaceID, issue.ID)
+ archiveTerminalIssueInbox(ctx, queries, bus, e.WorkspaceID, issue.ID, e.ActorType, e.ActorID)
}
}
diff --git a/server/cmd/server/notification_listeners_test.go b/server/cmd/server/notification_listeners_test.go
index fd471025a1..4df5e0115d 100644
--- a/server/cmd/server/notification_listeners_test.go
+++ b/server/cmd/server/notification_listeners_test.go
@@ -1253,11 +1253,15 @@ func countInboxByTypeForRecipient(t *testing.T, recipientID, notifType string) (
// publishStatusChange is a small helper to publish the issue:updated event
// shape used by the notification listener for status-only transitions.
func publishStatusChange(bus *events.Bus, issueID, newStatus, prevStatus string) {
+ publishStatusChangeBy(bus, issueID, newStatus, prevStatus, "member", testUserID)
+}
+
+func publishStatusChangeBy(bus *events.Bus, issueID, newStatus, prevStatus, actorType, actorID string) {
bus.Publish(events.Event{
Type: protocol.EventIssueUpdated,
WorkspaceID: testWorkspaceID,
- ActorType: "member",
- ActorID: testUserID,
+ ActorType: actorType,
+ ActorID: actorID,
Payload: map[string]any{
"issue": handler.IssueResponse{
ID: issueID,
@@ -1399,8 +1403,9 @@ func countActiveInboxForIssue(t *testing.T, recipientID, issueID string) int {
}
// TestNotification_StatusChange_DoneArchivesIssueInbox verifies that moving an
-// issue to Done archives every notification on it for every recipient, read
-// or unread, including the status_changed row the transition itself writes.
+// issue to Done archives the actor's own notifications on it, read or unread,
+// while every other recipient keeps theirs, including the status_changed row
+// that tells them the issue is done.
func TestNotification_StatusChange_DoneArchivesIssueInbox(t *testing.T) {
queries := db.New(testPool)
bus := newNotificationBus(t, queries)
@@ -1436,10 +1441,12 @@ func TestNotification_StatusChange_DoneArchivesIssueInbox(t *testing.T) {
publishStatusChange(bus, issueID, "done", "in_review")
- for _, recipient := range []string{testUserID, subID} {
- if active := countActiveInboxForIssue(t, recipient, issueID); active != 0 {
- t.Fatalf("recipient %s: expected no active inbox rows on a done issue, got %d", recipient, active)
- }
+ if active := countActiveInboxForIssue(t, testUserID, issueID); active != 0 {
+ t.Fatalf("actor: expected no active inbox rows on an issue they completed, got %d", active)
+ }
+ // The seeded comment plus the "moved to Done" notification.
+ if active := countActiveInboxForIssue(t, subID, issueID); active != 2 {
+ t.Fatalf("other recipient: expected 2 active inbox rows, got %d", active)
}
seen := map[string]bool{}
for _, e := range batchArchived {
@@ -1449,9 +1456,63 @@ func TestNotification_StatusChange_DoneArchivesIssueInbox(t *testing.T) {
}
recipientID, _ := payload["recipient_id"].(string)
seen[recipientID] = true
+ if count, _ := payload["count"].(int64); count != 2 {
+ t.Fatalf("inbox:batch-archived: expected count=2, got %v", payload["count"])
+ }
+ }
+ if len(seen) != 1 || !seen[testUserID] {
+ t.Fatalf("expected inbox:batch-archived for the actor only, got %v", seen)
}
- if !seen[testUserID] || !seen[subID] {
- t.Fatalf("expected inbox:batch-archived for both recipients, got %v", seen)
+}
+
+// TestNotification_StatusChange_DoneKeepsInboxWhenNotArchivedByActor verifies
+// that completing an issue leaves the inbox alone when the actor turned
+// auto_archive_completed off, or when an agent made the change.
+func TestNotification_StatusChange_DoneKeepsInboxWhenNotArchivedByActor(t *testing.T) {
+ queries := db.New(testPool)
+
+ actorEmail := "[email protected]"
+ actorID := createNotificationMember(t, actorEmail)
+ t.Cleanup(func() { cleanupTestUser(t, actorEmail) })
+ if _, err := testPool.Exec(context.Background(), `
+ INSERT INTO notification_preference (workspace_id, user_id, preferences)
+ VALUES ($1, $2, '{"auto_archive_completed":"muted"}'::jsonb)
+ `, testWorkspaceID, actorID); err != nil {
+ t.Fatalf("seed preference: %v", err)
+ }
+ t.Cleanup(func() {
+ testPool.Exec(context.Background(), `DELETE FROM notification_preference WHERE user_id = $1`, actorID)
+ })
+
+ for _, tc := range []struct {
+ name string
+ actorType string
+ actorID string
+ recipient string
+ }{
+ {"setting off", "member", actorID, actorID},
+ {"agent actor", "agent", "00000000-0000-0000-0000-aaaaaaaaaaaa", testUserID},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ bus := newNotificationBus(t, queries)
+ issueID := createTestIssue(t, testWorkspaceID, testUserID)
+ t.Cleanup(func() {
+ cleanupInboxForIssue(t, issueID)
+ cleanupTestIssue(t, issueID)
+ })
+ if _, err := testPool.Exec(context.Background(), `
+ INSERT INTO inbox_item (workspace_id, recipient_type, recipient_id, type, severity, issue_id, title, details)
+ VALUES ($1, 'member', $2, 'new_comment', 'info', $3, 'done keep test', '{}')
+ `, testWorkspaceID, tc.recipient, issueID); err != nil {
+ t.Fatalf("seed notification: %v", err)
+ }
+
+ publishStatusChangeBy(bus, issueID, "done", "in_review", tc.actorType, tc.actorID)
+
+ if active := countActiveInboxForIssue(t, tc.recipient, issueID); active != 1 {
+ t.Fatalf("expected the notification to stay in the inbox, got %d active", active)
+ }
+ })
}
}
diff --git a/server/internal/handler/notification_preference.go b/server/internal/handler/notification_preference.go
index 7750fedc1b..bbcd101fc2 100644
--- a/server/internal/handler/notification_preference.go
+++ b/server/internal/handler/notification_preference.go
@@ -16,18 +16,20 @@ import (
// not an inbox event group — it's a delivery-channel toggle controlling
// whether native OS notification banners fire — but it shares the same
// preferences map so a single endpoint covers all user notification
-// preferences.
+// preferences. `auto_archive_completed` is not an event group either: "muted"
+// stops your notifications from being archived when you complete an issue.
var validNotifGroups = map[string]bool{
- "assignments": true,
- "status_changes": true,
- "comments": true,
- "chat_replies": true,
- "mentions": true,
- "reactions": true,
- "updates": true,
- "agent_activity": true,
- "new_issues": true,
- "system_notifications": true,
+ "assignments": true,
+ "status_changes": true,
+ "comments": true,
+ "chat_replies": true,
+ "mentions": true,
+ "reactions": true,
+ "updates": true,
+ "agent_activity": true,
+ "new_issues": true,
+ "system_notifications": true,
+ "auto_archive_completed": true,
}
// validNotifValues is the set of allowed preference values per group.
diff --git a/server/internal/handler/notification_preference_test.go b/server/internal/handler/notification_preference_test.go
index 9e80ffc014..d5b8b34d6f 100644
--- a/server/internal/handler/notification_preference_test.go
+++ b/server/internal/handler/notification_preference_test.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"net/http"
"net/http/httptest"
+ "strings"
"testing"
"github.com/multica-ai/multica/server/internal/middleware"
@@ -128,16 +129,22 @@ func TestPatchNotificationPreferencesMergesWithoutReplacing(t *testing.T) {
}
// TestPatchNotificationPreferencesAcceptsAddedGroups covers groups added after
-// the original set: mentions (#6468) and reactions (MUL-9328). The whitelist
-// rejects unknown keys, so a client shipped ahead of the server would 400 on
-// these keys — the reason the server must deploy first.
+// the original set: mentions (#6468), reactions (MUL-9328) and
+// auto_archive_completed (MUL-9336). The whitelist rejects unknown keys, so a
+// client shipped ahead of the server would 400 on these keys — the reason the
+// server must deploy first.
func TestPatchNotificationPreferencesAcceptsAddedGroups(t *testing.T) {
if testHandler == nil || testPool == nil {
t.Skip("database not available")
}
- for _, group := range []string{"mentions", "reactions"} {
- t.Run(group, func(t *testing.T) {
+ for _, groups := range [][]string{
+ {"mentions"},
+ {"reactions"},
+ {"auto_archive_completed"},
+ {"reactions", "auto_archive_completed"},
+ } {
+ t.Run(strings.Join(groups, "+"), func(t *testing.T) {
t.Cleanup(func() {
_, _ = testPool.Exec(context.Background(), `
DELETE FROM notification_preference
@@ -145,12 +152,14 @@ func TestPatchNotificationPreferencesAcceptsAddedGroups(t *testing.T) {
`, testWorkspaceID, testUserID)
})
+ patch := map[string]string{}
+ for _, group := range groups {
+ patch[group] = "muted"
+ }
recorder := httptest.NewRecorder()
testHandler.PatchNotificationPreferences(
recorder,
- notificationPreferenceRequest(t, http.MethodPatch, map[string]string{
- group: "muted",
- }),
+ notificationPreferenceRequest(t, http.MethodPatch, patch),
)
if recorder.Code != http.StatusOK {
t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())
@@ -162,8 +171,10 @@ func TestPatchNotificationPreferencesAcceptsAddedGroups(t *testing.T) {
if err := json.NewDecoder(recorder.Body).Decode(&response); err != nil {
t.Fatalf("decode response: %v", err)
}
- if response.Preferences[group] != "muted" {
- t.Fatalf("%s not persisted: %#v", group, response.Preferences)
+ for _, group := range groups {
+ if response.Preferences[group] != "muted" {
+ t.Fatalf("%s not persisted: %#v", group, response.Preferences)
+ }
}
})
}
diff --git a/server/pkg/db/generated/inbox.sql.go b/server/pkg/db/generated/inbox.sql.go
index 593809f171..e8774ad2eb 100644
--- a/server/pkg/db/generated/inbox.sql.go
+++ b/server/pkg/db/generated/inbox.sql.go
@@ -158,43 +158,6 @@ func (q *Queries) ArchiveInboxByIssueAndType(ctx context.Context, arg ArchiveInb
return items, nil
}
-const archiveInboxByIssueForAllRecipients = `-- name: ArchiveInboxByIssueForAllRecipients :many
-UPDATE inbox_item SET archived = true
-WHERE workspace_id = $1 AND issue_id = $2 AND archived = false
-RETURNING recipient_type, recipient_id
-`
-
-type ArchiveInboxByIssueForAllRecipientsParams struct {
- WorkspaceID pgtype.UUID `json:"workspace_id"`
- IssueID pgtype.UUID `json:"issue_id"`
-}
-
-type ArchiveInboxByIssueForAllRecipientsRow struct {
- RecipientType string `json:"recipient_type"`
- RecipientID pgtype.UUID `json:"recipient_id"`
-}
-
-// A done issue leaves every recipient's inbox, read or not.
-func (q *Queries) ArchiveInboxByIssueForAllRecipients(ctx context.Context, arg ArchiveInboxByIssueForAllRecipientsParams) ([]ArchiveInboxByIssueForAllRecipientsRow, error) {
- rows, err := q.db.Query(ctx, archiveInboxByIssueForAllRecipients, arg.WorkspaceID, arg.IssueID)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- items := []ArchiveInboxByIssueForAllRecipientsRow{}
- for rows.Next() {
- var i ArchiveInboxByIssueForAllRecipientsRow
- if err := rows.Scan(&i.RecipientType, &i.RecipientID); err != nil {
- return nil, err
- }
- items = append(items, i)
- }
- if err := rows.Err(); err != nil {
- return nil, err
- }
- return items, nil
-}
-
const archiveInboxItem = `-- name: ArchiveInboxItem :one
UPDATE inbox_item SET archived = true
WHERE id = $1
diff --git a/server/pkg/db/queries/inbox.sql b/server/pkg/db/queries/inbox.sql
index 03cdf47635..1cef30c01e 100644
--- a/server/pkg/db/queries/inbox.sql
+++ b/server/pkg/db/queries/inbox.sql
@@ -216,12 +216,6 @@ RETURNING *;
UPDATE inbox_item SET archived = false
WHERE workspace_id = $1 AND recipient_type = $2 AND recipient_id = $3 AND issue_id = $4 AND archived = true;
--- name: ArchiveInboxByIssueForAllRecipients :many
--- A done issue leaves every recipient's inbox, read or not.
-UPDATE inbox_item SET archived = true
-WHERE workspace_id = $1 AND issue_id = $2 AND archived = false
-RETURNING recipient_type, recipient_id;
-
-- name: ArchiveInboxByIssueAndType :many
UPDATE inbox_item SET archived = true
WHERE workspace_id = $1 AND issue_id = $2 AND type = $3 AND archived = false