Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(soup): allow dss filtering by notification (done/seen) & task cbm_atm_nc + move inbox filtering to query filters (#1615)

teo285d7517ab73
diff --git a/js/app/packages/app/component/next-soup/filters/inbox-query-filters.test.ts b/js/app/packages/app/component/next-soup/filters/inbox-query-filters.test.ts
new file mode 100644
index 0000000000..94cd707586
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/filters/inbox-query-filters.test.ts
@@ -0,0 +1,106 @@
+import { describe, expect, it, vi } from 'vitest';
+import {
+ applyInboxQueryFilters,
+ applyOtherQueryFilters,
+ removeInboxQueryFilters,
+ removeOtherQueryFilters,
+} from './inbox-query-filters';
+
+vi.mock('./filters', () => ({
+ EXCLUDE: ['00000000-0000-0000-0000-000000000000'],
+}));
+
+describe('inbox-query-filters', () => {
+ describe('applyInboxQueryFilters', () => {
+ it('applies inbox notification filters, task bypass, and email importance', () => {
+ const result = applyInboxQueryFilters({});
+
+ expect(result.channel_filters?.notification_filters?.done).toBe(false);
+ expect(result.chat_filters?.notification_filters?.done).toBe(false);
+ expect(result.project_filters?.notification_filters?.done).toBe(false);
+ expect(result.document_filters?.notification_filters?.done).toBe(false);
+ expect(result.document_filters?.task_filters?.include_cbm_atm_nc).toBe(
+ true
+ );
+ expect(result.email_filters?.importance).toBe(true);
+ });
+ });
+
+ describe('removeInboxQueryFilters', () => {
+ it('strips inbox-applied filters from an inbox-applied payload', () => {
+ const applied = applyInboxQueryFilters({});
+ const result = removeInboxQueryFilters(applied);
+
+ expect(result.channel_filters).toBeUndefined();
+ expect(result.chat_filters).toBeUndefined();
+ expect(result.project_filters).toBeUndefined();
+ expect(result.document_filters).toBeUndefined();
+ expect(result.email_filters).toBeUndefined();
+ });
+
+ it('strips include_cbm_atm_nc while preserving other task filters', () => {
+ const result = removeInboxQueryFilters({
+ document_filters: {
+ task_filters: {
+ include_cbm_atm_nc: true,
+ },
+ },
+ });
+
+ expect(result.document_filters?.task_filters).toEqual({
+ status: ['todo'],
+ });
+ expect(
+ result.document_filters?.task_filters?.include_cbm_atm_nc
+ ).toBeUndefined();
+ });
+
+ it('keeps non-inbox notification values intact', () => {
+ const result = removeInboxQueryFilters({
+ channel_filters: {
+ notification_filters: {
+ done: true,
+ },
+ },
+ });
+
+ expect(result.channel_filters?.notification_filters?.done).toBe(true);
+ });
+ });
+
+ describe('applyOtherQueryFilters', () => {
+ it('applies other filters and email importance=false', () => {
+ const result = applyOtherQueryFilters({
+ email_filters: {
+ recipients: [],
+ },
+ });
+
+ expect(result.channel_filters?.channel_ids).toBeDefined();
+ expect(result.chat_filters?.chat_ids).toBeDefined();
+ expect(result.project_filters?.project_ids).toBeDefined();
+ expect(result.document_filters?.document_ids).toBeDefined();
+ expect(result.email_filters?.importance).toBe(false);
+ expect(result.email_filters?.recipients).toEqual([]);
+ });
+ });
+
+ describe('removeOtherQueryFilters', () => {
+ it('strips other-applied ids and importance=false while preserving unrelated fields', () => {
+ const applied = applyOtherQueryFilters({
+ channel_filters: { channel_types: ['direct_message'] as any },
+ email_filters: { recipients: [] },
+ });
+
+ const result = removeOtherQueryFilters(applied);
+
+ expect(result.channel_filters).toEqual({
+ channel_types: ['direct_message'],
+ });
+ expect(result.chat_filters).toBeUndefined();
+ expect(result.project_filters).toBeUndefined();
+ expect(result.document_filters).toBeUndefined();
+ expect(result.email_filters).toEqual({ recipients: [] });
+ });
+ });
+});
diff --git a/js/app/packages/app/component/next-soup/filters/inbox-query-filters.ts b/js/app/packages/app/component/next-soup/filters/inbox-query-filters.ts
new file mode 100644
index 0000000000..c749460675
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/filters/inbox-query-filters.ts
@@ -0,0 +1,191 @@
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import type { NotificationFilters } from '@service-storage/generated/schemas';
+import { EXCLUDE } from './filters';
+
+const INBOX_DONE = false;
+const INBOX_IMPORTANCE = true;
+const INBOX_TASK_BYPASS = true;
+
+const isNonEmptyObject = (obj: Record<string, unknown>) =>
+ Object.keys(obj).length > 0;
+
+type FilterWithNotification = {
+ notification_filters?: NotificationFilters;
+};
+
+function withInboxNotification<T extends FilterWithNotification>(
+ filters: T | undefined
+): T | undefined {
+ if (!filters) {
+ return {
+ notification_filters: {
+ done: INBOX_DONE,
+ },
+ } as T;
+ }
+ return {
+ ...filters,
+ notification_filters: {
+ ...filters?.notification_filters,
+ done: INBOX_DONE,
+ },
+ };
+}
+
+function withoutInboxNotification<T extends FilterWithNotification>(
+ filters: T | undefined
+): T | undefined {
+ if (!filters) return undefined;
+ const { notification_filters, ...rest } = filters;
+ if (!notification_filters || notification_filters.done !== INBOX_DONE) {
+ return filters;
+ }
+ const { done: _, ...notifRest } = notification_filters;
+ const result = {
+ ...rest,
+ ...(isNonEmptyObject(notifRest) ? { notification_filters: notifRest } : {}),
+ };
+ return isNonEmptyObject(result as Record<string, unknown>)
+ ? (result as T)
+ : undefined;
+}
+
+/** Apply inbox query filters to any existing query filter set. */
+export function applyInboxQueryFilters(
+ filters: SoupItemsQueryFilters
+): SoupItemsQueryFilters {
+ return {
+ ...filters,
+ channel_filters: withInboxNotification(filters.channel_filters),
+ chat_filters: withInboxNotification(filters.chat_filters),
+ project_filters: withInboxNotification(filters.project_filters),
+ document_filters: {
+ ...withInboxNotification(filters.document_filters),
+ task_filters: {
+ ...filters.document_filters?.task_filters,
+ include_cbm_atm_nc: INBOX_TASK_BYPASS,
+ },
+ },
+ email_filters: { ...filters.email_filters, importance: INBOX_IMPORTANCE },
+ };
+}
+
+/** Removes inbox specific query filters keeping the rest in place */
+export function removeInboxQueryFilters(
+ filters: SoupItemsQueryFilters
+): SoupItemsQueryFilters {
+ const channel_filters = withoutInboxNotification(filters.channel_filters);
+ const chat_filters = withoutInboxNotification(filters.chat_filters);
+ const project_filters = withoutInboxNotification(filters.project_filters);
+
+ const docWithoutNotif = withoutInboxNotification(filters.document_filters);
+ const { task_filters: taskFiltersAfterNotif, ...docWithoutTaskFilters } =
+ docWithoutNotif ?? {};
+ const task_filters =
+ taskFiltersAfterNotif ?? filters.document_filters?.task_filters;
+ const taskFiltersClean =
+ task_filters?.include_cbm_atm_nc === INBOX_TASK_BYPASS
+ ? (() => {
+ const { include_cbm_atm_nc: _, ...rest } = task_filters;
+ return isNonEmptyObject(rest) ? rest : undefined;
+ })()
+ : task_filters;
+ const document_filters =
+ isNonEmptyObject(docWithoutTaskFilters) || taskFiltersClean
+ ? {
+ ...docWithoutTaskFilters,
+ ...(taskFiltersClean ? { task_filters: taskFiltersClean } : {}),
+ }
+ : undefined;
+
+ const { importance, ...emailRest } = filters.email_filters ?? {};
+ const email_filters =
+ importance === INBOX_IMPORTANCE
+ ? isNonEmptyObject(emailRest)
+ ? emailRest
+ : undefined
+ : filters.email_filters;
+
+ return {
+ ...filters,
+ channel_filters,
+ chat_filters,
+ project_filters,
+ document_filters,
+ email_filters,
+ };
+}
+
+export function applyOtherQueryFilters(
+ filters: SoupItemsQueryFilters
+): SoupItemsQueryFilters {
+ return {
+ ...filters,
+ channel_filters: {
+ ...filters.channel_filters,
+ channel_ids: EXCLUDE,
+ },
+ chat_filters: {
+ ...filters.chat_filters,
+ chat_ids: EXCLUDE,
+ },
+ project_filters: {
+ ...filters.project_filters,
+ project_ids: EXCLUDE,
+ },
+ document_filters: {
+ ...filters.document_filters,
+ document_ids: EXCLUDE,
+ },
+ email_filters: {
+ ...filters.email_filters,
+ importance: false,
+ },
+ };
+}
+
+function stripExcludeId<
+ T extends Partial<Record<K, unknown>>,
+ K extends string,
+>(f: T | undefined, key: K): T | undefined {
+ if (!f || f[key] !== EXCLUDE) return f;
+ const { [key]: _, ...rest } = f;
+ return isNonEmptyObject(rest as Record<string, unknown>)
+ ? (rest as unknown as T)
+ : undefined;
+}
+
+export function removeOtherQueryFilters(
+ filters: SoupItemsQueryFilters
+): SoupItemsQueryFilters {
+ const channel_filters = stripExcludeId(
+ filters.channel_filters,
+ 'channel_ids'
+ );
+ const chat_filters = stripExcludeId(filters.chat_filters, 'chat_ids');
+ const project_filters = stripExcludeId(
+ filters.project_filters,
+ 'project_ids'
+ );
+ const document_filters = stripExcludeId(
+ filters.document_filters,
+ 'document_ids'
+ );
+
+ const { importance, ...emailRest } = filters.email_filters ?? {};
+ const email_filters =
+ importance === false
+ ? isNonEmptyObject(emailRest)
+ ? emailRest
+ : undefined
+ : filters.email_filters;
+
+ return {
+ ...filters,
+ channel_filters,
+ chat_filters,
+ project_filters,
+ document_filters,
+ email_filters,
+ };
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx
index dcf7e541fa..f54d56937c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx
@@ -29,6 +29,12 @@ import {
getEntityTypeFilterIcon,
QUERY_FILTERS,
} from '@app/component/next-soup/filters/filters';
+import {
+ applyInboxQueryFilters,
+ applyOtherQueryFilters,
+ removeInboxQueryFilters,
+ removeOtherQueryFilters,
+} from '@app/component/next-soup/filters/inbox-query-filters';
import { ENABLE_ANIMATED_ICONS } from '@core/constant/featureFlags';
import { registerHotkey } from '@core/hotkey/hotkeys';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
@@ -45,6 +51,8 @@ import {
TaskStatusDropdown,
TaskAssigneeDropdown,
} from '@app/component/next-soup/soup-view/task-sub-filters';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import { match } from 'ts-pattern';
/**
* Keyboard shortcuts for entity type filters.
@@ -131,14 +139,55 @@ const SoupFilters = () => {
const [statusDropdownOpen, setStatusDropdownOpen] = createSignal(false);
const [assigneeDropdownOpen, setAssigneeDropdownOpen] = createSignal(false);
- const toggleFocus = (id: 'signal' | 'noise') => {
- if (soup.filters.isActive(id)) {
- soup.filters.toggle('explicit-noise');
- soup.filters.deactivate('not-done');
- } else {
- soup.filters.toggle(id);
- soup.filters.activate('not-done');
+ const setQueryFiltersInboxAware = (filters: SoupItemsQueryFilters) => {
+ if (soup.filters.isActive('signal')) {
+ setQueryFilters(applyInboxQueryFilters(filters));
+ return;
}
+ if (soup.filters.isActive('noise')) {
+ setQueryFilters(applyOtherQueryFilters(removeInboxQueryFilters(filters)));
+ return;
+ }
+ setQueryFilters(removeInboxQueryFilters(filters));
+ };
+
+ const toggleFocus = (id: 'signal' | 'noise') => {
+ const comb = { id, isActive: soup.filters.isActive(id) };
+
+ const activateFocus = () =>
+ batch(() => {
+ soup.filters.toggle(id);
+ soup.filters.activate('not-done');
+ });
+
+ const deactivateFocus = () =>
+ batch(() => {
+ soup.filters.toggle('explicit-noise');
+ soup.filters.deactivate('not-done');
+ });
+
+ match(comb)
+ .with({ id: 'signal', isActive: false }, () => {
+ setQueryFilters((prev) =>
+ applyInboxQueryFilters(removeOtherQueryFilters(prev))
+ );
+ activateFocus();
+ })
+ .with({ id: 'noise', isActive: false }, () => {
+ setQueryFilters((prev) =>
+ applyOtherQueryFilters(removeInboxQueryFilters(prev))
+ );
+ activateFocus();
+ })
+ .with({ id: 'signal', isActive: true }, () => {
+ setQueryFilters(removeInboxQueryFilters);
+ deactivateFocus();
+ })
+ .with({ id: 'noise', isActive: true }, () => {
+ setQueryFilters(removeOtherQueryFilters);
+ deactivateFocus();
+ })
+ .exhaustive();
};
const toggleUnread = () => {
@@ -149,7 +198,9 @@ const SoupFilters = () => {
const willBeActive = !soup.filters.isActive(id);
batch(() => {
soup.filters.toggle(id);
- setQueryFilters(willBeActive ? QUERY_FILTERS[id] : QUERY_FILTERS.default);
+ setQueryFiltersInboxAware(
+ willBeActive ? QUERY_FILTERS[id] : QUERY_FILTERS.default
+ );
});
};
@@ -160,14 +211,14 @@ const SoupFilters = () => {
soup.filters.toggle('email');
if (willBeActive) {
const shouldIncludeEmails = emailActive();
- setQueryFilters({
+ setQueryFiltersInboxAware({
...QUERY_FILTERS.email,
email_filters: {
recipients: shouldIncludeEmails ? [] : EXCLUDE,
},
});
} else {
- setQueryFilters(QUERY_FILTERS.default);
+ setQueryFiltersInboxAware(QUERY_FILTERS.default);
}
});
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index a5986bb4d5..b94f206c52 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
@@ -102,7 +102,6 @@ export const SoupViewContextProvider: FlowComponent<
SoupViewContextProviderProps
> = (props) => {
const soup = props.soup ?? createSoupState();
-
const soupParams = createMemo(
(): SoupParams => ({
limit: 100,
@@ -158,7 +157,7 @@ export const SoupViewContextProvider: FlowComponent<
const soupBody = createMemo(
(): SoupBody => ({
...queryFilters(),
- emailView: 'all',
+ emailView: soup.filters.isActive('signal') ? 'inbox' : 'all',
})
);
diff --git a/js/app/packages/service-clients/service-search/generated/models/channelFilters.ts b/js/app/packages/service-clients/service-search/generated/models/channelFilters.ts
index 568807a18f..274829c732 100644
--- a/js/app/packages/service-clients/service-search/generated/models/channelFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/channelFilters.ts
@@ -6,6 +6,7 @@
*/
import type { ChannelFiltersImportance } from './channelFiltersImportance';
import type { ChannelFiltersOrgId } from './channelFiltersOrgId';
+import type { NotificationFilters } from './notificationFilters';
/**
* The channel message filters used to filter down what channel messages you search over.
@@ -19,6 +20,8 @@ export interface ChannelFilters {
importance?: ChannelFiltersImportance;
/** Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions. */
mentions?: string[];
+ /** Filter by channel notification state. */
+ notification_filters?: NotificationFilters;
/** Channel organization ID to search within. Empty to ignore organization filtering. */
org_id?: ChannelFiltersOrgId;
/** Sender IDs to search within. Examples: ['user1']. Empty to search all accessible senders. */
diff --git a/js/app/packages/service-clients/service-search/generated/models/chatFilters.ts b/js/app/packages/service-clients/service-search/generated/models/chatFilters.ts
index 38f463936d..3dc8412eb8 100644
--- a/js/app/packages/service-clients/service-search/generated/models/chatFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/chatFilters.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { ChatFiltersImportance } from './chatFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
/**
* The chat filters used to filter down what chats you search over.
@@ -14,6 +15,8 @@ export interface ChatFilters {
chat_ids?: string[];
/** Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: ChatFiltersImportance;
+ /** Filter by chat notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by chat owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** A list of project ids to search within. Examples: ['project1']. Empty to ignore project filtering. */
diff --git a/js/app/packages/service-clients/service-search/generated/models/documentFilters.ts b/js/app/packages/service-clients/service-search/generated/models/documentFilters.ts
index 0312a5bed8..25445d3d61 100644
--- a/js/app/packages/service-clients/service-search/generated/models/documentFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/documentFilters.ts
@@ -5,6 +5,8 @@
* OpenAPI spec version: 0.1.0
*/
import type { DocumentFiltersImportance } from './documentFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
+import type { TaskFilters } from './taskFilters';
/**
* The document filters used to filter down what documents you search over.
@@ -16,9 +18,13 @@ export interface DocumentFilters {
file_types?: string[];
/** Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: DocumentFiltersImportance;
+ /** Filter by document notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by document owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** A list of project ids to search within. Examples: ['project1'].
filtering. Empty to ignore project filtering. */
project_ids?: string[];
+ /** Task-specific filters that only apply to task subtype documents. */
+ task_filters?: TaskFilters;
}
diff --git a/js/app/packages/service-clients/service-search/generated/models/emailFilters.ts b/js/app/packages/service-clients/service-search/generated/models/emailFilters.ts
index 6a7882ef20..21460d3f34 100644
--- a/js/app/packages/service-clients/service-search/generated/models/emailFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/emailFilters.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { EmailFiltersImportance } from './emailFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
/**
* The email filters used to filter down what emails you search over.
@@ -18,6 +19,8 @@ export interface EmailFilters {
email_thread_ids?: string[];
/** Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: EmailFiltersImportance;
+ /** Filter by email notification state. */
+ notification_filters?: NotificationFilters;
/** Email Recipient addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by Recipient. */
recipients?: string[];
/** Email sender addresses to filter by. Examples: ['[email protected]']. Empty to search all senders. */
diff --git a/js/app/packages/service-clients/service-search/generated/models/index.ts b/js/app/packages/service-clients/service-search/generated/models/index.ts
index e2f9a15756..bc7287f8e0 100644
--- a/js/app/packages/service-clients/service-search/generated/models/index.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/index.ts
@@ -101,6 +101,9 @@ export * from './emptyResponse';
export * from './errorResponse';
export * from './fileType';
export * from './matchType';
+export * from './notificationFilters';
+export * from './notificationFiltersDone';
+export * from './notificationFiltersSeen';
export * from './projectFilters';
export * from './projectFiltersImportance';
export * from './projectMetadata';
@@ -185,6 +188,8 @@ export * from './simpleUnifiedSearchResponseBaseItemOneOfOnezeroAllOfType';
export * from './simpleUnifiedSearchResponseBaseItemOneOfSeven';
export * from './simpleUnifiedSearchResponseBaseItemOneOfSevenAllOf';
export * from './simpleUnifiedSearchResponseBaseItemOneOfSevenAllOfType';
+export * from './taskFilters';
+export * from './taskFiltersIncludeCbmAtmNc';
export * from './unifiedSearchFilters';
export * from './unifiedSearchFiltersChannel';
export * from './unifiedSearchFiltersChat';
diff --git a/js/app/packages/service-clients/service-search/generated/models/notificationFilters.ts b/js/app/packages/service-clients/service-search/generated/models/notificationFilters.ts
new file mode 100644
index 0000000000..6c35389378
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/notificationFilters.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { NotificationFiltersDone } from './notificationFiltersDone';
+import type { NotificationFiltersSeen } from './notificationFiltersSeen';
+
+/**
+ * Notification-level filters that apply to an entity type.
+ */
+export interface NotificationFilters {
+ /** Filter by notification done state.
+None to ignore, true to include only done notifications, false to include only not-done notifications. */
+ done?: NotificationFiltersDone;
+ /** Filter by notification seen state.
+None to ignore, true to include only seen notifications, false to include only unseen notifications. */
+ seen?: NotificationFiltersSeen;
+}
diff --git a/js/app/packages/service-clients/service-search/generated/models/notificationFiltersDone.ts b/js/app/packages/service-clients/service-search/generated/models/notificationFiltersDone.ts
new file mode 100644
index 0000000000..5c1680a43f
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/notificationFiltersDone.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filter by notification done state.
+None to ignore, true to include only done notifications, false to include only not-done notifications.
+ */
+export type NotificationFiltersDone = boolean | null;
diff --git a/js/app/packages/service-clients/service-search/generated/models/notificationFiltersSeen.ts b/js/app/packages/service-clients/service-search/generated/models/notificationFiltersSeen.ts
new file mode 100644
index 0000000000..719f4b3e94
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/notificationFiltersSeen.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filter by notification seen state.
+None to ignore, true to include only seen notifications, false to include only unseen notifications.
+ */
+export type NotificationFiltersSeen = boolean | null;
diff --git a/js/app/packages/service-clients/service-search/generated/models/projectFilters.ts b/js/app/packages/service-clients/service-search/generated/models/projectFilters.ts
index 4dbb57fe07..938f843ba5 100644
--- a/js/app/packages/service-clients/service-search/generated/models/projectFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/projectFilters.ts
@@ -4,6 +4,8 @@
* search_service
* OpenAPI spec version: 0.1.0
*/
+
+import type { NotificationFilters } from './notificationFilters';
import type { ProjectFiltersImportance } from './projectFiltersImportance';
/**
@@ -12,6 +14,8 @@ import type { ProjectFiltersImportance } from './projectFiltersImportance';
export interface ProjectFilters {
/** Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: ProjectFiltersImportance;
+ /** Filter by project notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by project owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** Project IDs to search within. Examples: ['project1']. Empty to search all accessible projects. */
diff --git a/js/app/packages/service-clients/service-search/generated/models/taskFilters.ts b/js/app/packages/service-clients/service-search/generated/models/taskFilters.ts
new file mode 100644
index 0000000000..303494ba4e
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/taskFilters.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TaskFiltersIncludeCbmAtmNc } from './taskFiltersIncludeCbmAtmNc';
+
+/**
+ * Task-only filters nested under document filters.
+ */
+export interface TaskFilters {
+ /** Include tasks that are created by me, assigned to me, and not completed,
+even when they do not match other document filters. */
+ include_cbm_atm_nc?: TaskFiltersIncludeCbmAtmNc;
+}
diff --git a/js/app/packages/service-clients/service-search/generated/models/taskFiltersIncludeCbmAtmNc.ts b/js/app/packages/service-clients/service-search/generated/models/taskFiltersIncludeCbmAtmNc.ts
new file mode 100644
index 0000000000..3d482fa31c
--- /dev/null
+++ b/js/app/packages/service-clients/service-search/generated/models/taskFiltersIncludeCbmAtmNc.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * search_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Include tasks that are created by me, assigned to me, and not completed,
+even when they do not match other document filters.
+ */
+export type TaskFiltersIncludeCbmAtmNc = boolean | null;
diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.json
index 66526d3a73..c0fdbe2b41 100644
--- a/js/app/packages/service-clients/service-search/openapi.json
+++ b/js/app/packages/service-clients/service-search/openapi.json
@@ -202,6 +202,10 @@
},
"description": "Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by channel notification state."
+ },
"org_id": {
"type": ["integer", "null"],
"format": "int64",
@@ -424,6 +428,10 @@
"type": ["boolean", "null"],
"description": "Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by chat notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -647,6 +655,10 @@
"type": ["boolean", "null"],
"description": "Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by document notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -660,6 +672,10 @@
"type": "string"
},
"description": "A list of project ids to search within. Examples: ['project1'].\nfiltering. Empty to ignore project filtering."
+ },
+ "task_filters": {
+ "$ref": "#/components/schemas/TaskFilters",
+ "description": "Task-specific filters that only apply to task subtype documents."
}
}
},
@@ -889,6 +905,10 @@
"type": ["boolean", "null"],
"description": "Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by email notification state."
+ },
"recipients": {
"type": "array",
"items": {
@@ -1226,6 +1246,20 @@
"type": "string",
"enum": ["exact", "partial", "regexp", "query"]
},
+ "NotificationFilters": {
+ "type": "object",
+ "description": "Notification-level filters that apply to an entity type.",
+ "properties": {
+ "done": {
+ "type": ["boolean", "null"],
+ "description": "Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications."
+ },
+ "seen": {
+ "type": ["boolean", "null"],
+ "description": "Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications."
+ }
+ }
+ },
"ProjectFilters": {
"type": "object",
"description": "The project filters used to filter down what projects you search over.",
@@ -1234,6 +1268,10 @@
"type": ["boolean", "null"],
"description": "Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by project notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -2383,6 +2421,16 @@
}
]
},
+ "TaskFilters": {
+ "type": "object",
+ "description": "Task-only filters nested under document filters.",
+ "properties": {
+ "include_cbm_atm_nc": {
+ "type": ["boolean", "null"],
+ "description": "Include tasks that are created by me, assigned to me, and not completed,\neven when they do not match other document filters."
+ }
+ }
+ },
"UnifiedSearchFilters": {
"type": "object",
"properties": {
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelFilters.ts
index 4abc4bce21..7bbb6112f5 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelFilters.ts
@@ -6,6 +6,7 @@
*/
import type { ChannelFiltersImportance } from './channelFiltersImportance';
import type { ChannelFiltersOrgId } from './channelFiltersOrgId';
+import type { NotificationFilters } from './notificationFilters';
/**
* The channel message filters used to filter down what channel messages you search over.
@@ -19,6 +20,8 @@ export interface ChannelFilters {
importance?: ChannelFiltersImportance;
/** Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions. */
mentions?: string[];
+ /** Filter by channel notification state. */
+ notification_filters?: NotificationFilters;
/** Channel organization ID to search within. Empty to ignore organization filtering. */
org_id?: ChannelFiltersOrgId;
/** Sender IDs to search within. Examples: ['user1']. Empty to search all accessible senders. */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/chatFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/chatFilters.ts
index 14dae282b6..3f76a53c41 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/chatFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/chatFilters.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { ChatFiltersImportance } from './chatFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
/**
* The chat filters used to filter down what chats you search over.
@@ -14,6 +15,8 @@ export interface ChatFilters {
chat_ids?: string[];
/** Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: ChatFiltersImportance;
+ /** Filter by chat notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by chat owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** A list of project ids to search within. Examples: ['project1']. Empty to ignore project filtering. */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/documentFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/documentFilters.ts
index 0055f74a47..6cd848c835 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/documentFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/documentFilters.ts
@@ -5,6 +5,8 @@
* OpenAPI spec version: 0.1.0
*/
import type { DocumentFiltersImportance } from './documentFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
+import type { TaskFilters } from './taskFilters';
/**
* The document filters used to filter down what documents you search over.
@@ -16,9 +18,13 @@ export interface DocumentFilters {
file_types?: string[];
/** Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: DocumentFiltersImportance;
+ /** Filter by document notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by document owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** A list of project ids to search within. Examples: ['project1'].
filtering. Empty to ignore project filtering. */
project_ids?: string[];
+ /** Task-specific filters that only apply to task subtype documents. */
+ task_filters?: TaskFilters;
}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/emailFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/emailFilters.ts
index dc337b0cde..e5c85ad382 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/emailFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/emailFilters.ts
@@ -5,6 +5,7 @@
* OpenAPI spec version: 0.1.0
*/
import type { EmailFiltersImportance } from './emailFiltersImportance';
+import type { NotificationFilters } from './notificationFilters';
/**
* The email filters used to filter down what emails you search over.
@@ -18,6 +19,8 @@ export interface EmailFilters {
email_thread_ids?: string[];
/** Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: EmailFiltersImportance;
+ /** Filter by email notification state. */
+ notification_filters?: NotificationFilters;
/** Email Recipient addresses to filter by. Examples: ['[email protected]']. Empty if not filtering by Recipient. */
recipients?: string[];
/** Email sender addresses to filter by. Examples: ['[email protected]']. Empty to search all senders. */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
index 7c96e33590..0155fff73f 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/index.ts
@@ -359,6 +359,9 @@ export * from './locationResponseData';
export * from './locationResponseDataOneOf';
export * from './locationResponseDataOneOfTwo';
export * from './mentions';
+export * from './notificationFilters';
+export * from './notificationFiltersDone';
+export * from './notificationFiltersSeen';
export * from './params';
export * from './paramsExpand';
export * from './paramsLimit';
@@ -566,6 +569,8 @@ export * from './soupProperty';
export * from './soupPropertyValue';
export * from './successResponse';
export * from './syncServiceVersionID';
+export * from './taskFilters';
+export * from './taskFiltersIncludeCbmAtmNc';
export * from './thread';
export * from './threadCreatedAt';
export * from './threadDeletedAt';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/notificationFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFilters.ts
new file mode 100644
index 0000000000..ad72a7f79a
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFilters.ts
@@ -0,0 +1,20 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { NotificationFiltersDone } from './notificationFiltersDone';
+import type { NotificationFiltersSeen } from './notificationFiltersSeen';
+
+/**
+ * Notification-level filters that apply to an entity type.
+ */
+export interface NotificationFilters {
+ /** Filter by notification done state.
+None to ignore, true to include only done notifications, false to include only not-done notifications. */
+ done?: NotificationFiltersDone;
+ /** Filter by notification seen state.
+None to ignore, true to include only seen notifications, false to include only unseen notifications. */
+ seen?: NotificationFiltersSeen;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersDone.ts b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersDone.ts
new file mode 100644
index 0000000000..7dd149827a
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersDone.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filter by notification done state.
+None to ignore, true to include only done notifications, false to include only not-done notifications.
+ */
+export type NotificationFiltersDone = boolean | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersSeen.ts b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersSeen.ts
new file mode 100644
index 0000000000..b36c407d36
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/notificationFiltersSeen.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Filter by notification seen state.
+None to ignore, true to include only seen notifications, false to include only unseen notifications.
+ */
+export type NotificationFiltersSeen = boolean | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/projectFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/projectFilters.ts
index 373c05d08f..5d0cb703ad 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/projectFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/projectFilters.ts
@@ -4,6 +4,8 @@
* document_storage_service
* OpenAPI spec version: 0.1.0
*/
+
+import type { NotificationFilters } from './notificationFilters';
import type { ProjectFiltersImportance } from './projectFiltersImportance';
/**
@@ -12,6 +14,8 @@ import type { ProjectFiltersImportance } from './projectFiltersImportance';
export interface ProjectFilters {
/** Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing. */
importance?: ProjectFiltersImportance;
+ /** Filter by project notification state. */
+ notification_filters?: NotificationFilters;
/** Filter by project owner. Examples: ['macro|[email protected]'], ['macro|[email protected]', 'macro|[email protected]']. Empty to search all owners. */
owners?: string[];
/** Project IDs to search within. Examples: ['project1']. Empty to search all accessible projects. */
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/taskFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/taskFilters.ts
new file mode 100644
index 0000000000..5976b3ff61
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/taskFilters.ts
@@ -0,0 +1,16 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+import type { TaskFiltersIncludeCbmAtmNc } from './taskFiltersIncludeCbmAtmNc';
+
+/**
+ * Task-only filters nested under document filters.
+ */
+export interface TaskFilters {
+ /** Include tasks that are created by me, assigned to me, and not completed,
+even when they do not match other document filters. */
+ include_cbm_atm_nc?: TaskFiltersIncludeCbmAtmNc;
+}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/taskFiltersIncludeCbmAtmNc.ts b/js/app/packages/service-clients/service-storage/generated/schemas/taskFiltersIncludeCbmAtmNc.ts
new file mode 100644
index 0000000000..07ed1217d7
--- /dev/null
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/taskFiltersIncludeCbmAtmNc.ts
@@ -0,0 +1,12 @@
+/**
+ * Generated by orval v7.13.0 🍺
+ * Do not edit manually.
+ * document_storage_service
+ * OpenAPI spec version: 0.1.0
+ */
+
+/**
+ * Include tasks that are created by me, assigned to me, and not completed,
+even when they do not match other document filters.
+ */
+export type TaskFiltersIncludeCbmAtmNc = boolean | null;
diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.ts
index dbf102a5a4..fb564a3ae6 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -3959,6 +3959,23 @@ export const postItemsSoupBody = zod
.describe(
"Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions."
),
+ notification_filters: zod
+ .object({
+ done: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications.'
+ ),
+ seen: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications.'
+ ),
+ })
+ .optional()
+ .describe('Notification-level filters that apply to an entity type.'),
org_id: zod
.number()
.nullish()
@@ -3996,6 +4013,23 @@ export const postItemsSoupBody = zod
.describe(
'Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.'
),
+ notification_filters: zod
+ .object({
+ done: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications.'
+ ),
+ seen: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications.'
+ ),
+ })
+ .optional()
+ .describe('Notification-level filters that apply to an entity type.'),
owners: zod
.array(zod.string())
.optional()
@@ -4039,6 +4073,23 @@ export const postItemsSoupBody = zod
.describe(
'Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.'
),
+ notification_filters: zod
+ .object({
+ done: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications.'
+ ),
+ seen: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications.'
+ ),
+ })
+ .optional()
+ .describe('Notification-level filters that apply to an entity type.'),
owners: zod
.array(zod.string())
.optional()
@@ -4051,6 +4102,17 @@ export const postItemsSoupBody = zod
.describe(
"A list of project ids to search within. Examples: ['project1'].\nfiltering. Empty to ignore project filtering."
),
+ task_filters: zod
+ .object({
+ include_cbm_atm_nc: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Include tasks that are created by me, assigned to me, and not completed,\neven when they do not match other document filters.'
+ ),
+ })
+ .optional()
+ .describe('Task-only filters nested under document filters.'),
})
.optional()
.describe(
@@ -4082,6 +4144,23 @@ export const postItemsSoupBody = zod
.describe(
'Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.'
),
+ notification_filters: zod
+ .object({
+ done: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications.'
+ ),
+ seen: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications.'
+ ),
+ })
+ .optional()
+ .describe('Notification-level filters that apply to an entity type.'),
recipients: zod
.array(zod.string())
.optional()
@@ -4107,6 +4186,23 @@ export const postItemsSoupBody = zod
.describe(
'Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.'
),
+ notification_filters: zod
+ .object({
+ done: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications.'
+ ),
+ seen: zod
+ .boolean()
+ .nullish()
+ .describe(
+ 'Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications.'
+ ),
+ })
+ .optional()
+ .describe('Notification-level filters that apply to an entity type.'),
owners: zod
.array(zod.string())
.optional()
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 7d3c715715..4015bfd177 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -5309,6 +5309,10 @@
},
"description": "Channel user mentions to search for. Examples: ['@username']. Empty if not filtering by mentions."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by channel notification state."
+ },
"org_id": {
"type": ["integer", "null"],
"format": "int64",
@@ -5497,6 +5501,10 @@
"type": ["boolean", "null"],
"description": "Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by chat notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -6105,6 +6113,10 @@
"type": ["boolean", "null"],
"description": "Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by document notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -6118,6 +6130,10 @@
"type": "string"
},
"description": "A list of project ids to search within. Examples: ['project1'].\nfiltering. Empty to ignore project filtering."
+ },
+ "task_filters": {
+ "$ref": "#/components/schemas/TaskFilters",
+ "description": "Task-specific filters that only apply to task subtype documents."
}
}
},
@@ -6689,6 +6705,10 @@
"type": ["boolean", "null"],
"description": "Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by email notification state."
+ },
"recipients": {
"type": "array",
"items": {
@@ -7577,6 +7597,20 @@
}
}
},
+ "NotificationFilters": {
+ "type": "object",
+ "description": "Notification-level filters that apply to an entity type.",
+ "properties": {
+ "done": {
+ "type": ["boolean", "null"],
+ "description": "Filter by notification done state.\nNone to ignore, true to include only done notifications, false to include only not-done notifications."
+ },
+ "seen": {
+ "type": ["boolean", "null"],
+ "description": "Filter by notification seen state.\nNone to ignore, true to include only seen notifications, false to include only unseen notifications."
+ }
+ }
+ },
"Params": {
"type": "object",
"properties": {
@@ -8299,6 +8333,10 @@
"type": ["boolean", "null"],
"description": "Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing."
},
+ "notification_filters": {
+ "$ref": "#/components/schemas/NotificationFilters",
+ "description": "Filter by project notification state."
+ },
"owners": {
"type": "array",
"items": {
@@ -9592,6 +9630,16 @@
}
}
},
+ "TaskFilters": {
+ "type": "object",
+ "description": "Task-only filters nested under document filters.",
+ "properties": {
+ "include_cbm_atm_nc": {
+ "type": ["boolean", "null"],
+ "description": "Include tasks that are created by me, assigned to me, and not completed,\neven when they do not match other document filters."
+ }
+ }
+ },
"Thread": {
"type": "object",
"required": ["threadId", "owner", "resolved", "documentId"],
diff --git a/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql b/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
index 92b8215ef4..e82470f501 100644
--- a/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
+++ b/rust/cloud-storage/comms/src/outbound/fixtures/channels.sql
@@ -21,6 +21,19 @@ VALUES
-- user-2 is a member of channel D (DM)
('dddddddd-dddd-dddd-dddd-dddddddddddd', 'member', 'macro|[email protected]', '2024-01-04 10:00:00');
+-- Notifications for channel notification filter tests
+INSERT INTO notification (id, notification_event_type, event_item_id, event_item_type, service_sender, metadata, sender_id)
+VALUES
+ ('eeeeeeea-0000-0000-0000-000000000001', 'test', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'channel', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ ('eeeeeeeb-0000-0000-0000-000000000002', 'test', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', 'channel', 'test', '{}'::jsonb, 'macro|[email protected]');
+
+INSERT INTO user_notification (user_id, notification_id, created_at, seen_at, done)
+VALUES
+ -- Channel A: not done + unread
+ ('macro|[email protected]', 'eeeeeeea-0000-0000-0000-000000000001', '2024-01-05 10:00:00', NULL, false),
+ -- Channel B: done + seen
+ ('macro|[email protected]', 'eeeeeeeb-0000-0000-0000-000000000002', '2024-01-05 10:01:00', '2024-01-05 11:00:00', true);
+
-- Messages for latest message tests
INSERT INTO comms_messages (id, channel_id, thread_id, sender_id, content, created_at, updated_at, deleted_at)
VALUES
diff --git a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic.rs b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic.rs
index e015e6f55b..e7f2af1cc3 100644
--- a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic.rs
+++ b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic.rs
@@ -62,6 +62,49 @@ static CHANNEL_SELECT: &str = r#"
LIMIT $3
"#;
+fn build_notification_exists_clause(
+ entity_id_sql: &str,
+ entity_type: &str,
+ predicate_sql: &str,
+) -> String {
+ format!(
+ r#"EXISTS (
+ SELECT 1
+ FROM notification n
+ JOIN user_notification un ON un.notification_id = n.id
+ WHERE un.user_id = $1
+ AND un.deleted_at IS NULL
+ AND n.event_item_type = '{entity_type}'
+ AND n.event_item_id = ({entity_id_sql})::text
+ AND {predicate_sql}
+ )"#
+ )
+}
+
+fn build_notification_done_clause(entity_id_sql: &str, entity_type: &str, done: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if done {
+ "un.done = true"
+ } else {
+ "un.done = false"
+ },
+ )
+}
+
+fn build_notification_seen_clause(entity_id_sql: &str, entity_type: &str, seen: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if seen {
+ "un.seen_at IS NOT NULL"
+ } else {
+ "un.seen_at IS NULL"
+ },
+ )
+}
+
fn build_channel_filter(ast: Option<&Expr<ChannelLiteral>>) -> String {
let Some(expr) = ast else {
return String::new();
@@ -103,6 +146,12 @@ fn build_channel_filter(ast: Option<&Expr<ChannelLiteral>>) -> String {
filter_ast::ExprFrame::Literal(ChannelLiteral::Importance(true)) => String::new(),
// all channels are important, so if importance is false, exclude them
filter_ast::ExprFrame::Literal(ChannelLiteral::Importance(false)) => "1=0".to_string(),
+ filter_ast::ExprFrame::Literal(ChannelLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("c.id", "channel", done)
+ }
+ filter_ast::ExprFrame::Literal(ChannelLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("c.id", "channel", seen)
+ }
});
if formatting.is_empty() {
String::new()
diff --git a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
index 508c47d9f5..adf3678eb3 100644
--- a/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
+++ b/rust/cloud-storage/comms/src/outbound/postgres/comms_repo/dynamic/tests.rs
@@ -232,6 +232,92 @@ async fn test_get_user_channels_dynamic_filter_by_importance(pool: Pool<sqlx::Po
}
}
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("channels"))
+)]
+async fn test_get_user_channels_dynamic_filter_by_notification_done(pool: Pool<sqlx::Postgres>) {
+ use filter_ast::ExpandFrame;
+ use item_filters::{ChannelFilters, NotificationFilters};
+
+ let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+
+ let channel_filters = ChannelFilters {
+ notification_filters: NotificationFilters {
+ done: Some(false),
+ seen: None,
+ },
+ ..Default::default()
+ };
+
+ let filter_ast = ChannelFilters::expand_ast(channel_filters)
+ .unwrap()
+ .map(std::sync::Arc::new);
+
+ let params = GetChannelsRequest {
+ macro_id: user_id.into_owned(),
+ limit: Some(20),
+ query: Query::Sort(SimpleSortMethod::UpdatedAt, filter_ast),
+ }
+ .into_params();
+
+ let channels = get_user_channels_dynamic(&pool, &params).await.unwrap();
+
+ assert_eq!(
+ channels.len(),
+ 1,
+ "done=false should return exactly one channel"
+ );
+ assert_eq!(
+ channels[0].channel.id.0.to_string(),
+ "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
+ );
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("channels"))
+)]
+async fn test_get_user_channels_dynamic_filter_by_notification_seen_and_done(
+ pool: Pool<sqlx::Postgres>,
+) {
+ use filter_ast::ExpandFrame;
+ use item_filters::{ChannelFilters, NotificationFilters};
+
+ let user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+
+ let channel_filters = ChannelFilters {
+ notification_filters: NotificationFilters {
+ done: Some(true),
+ seen: Some(true),
+ },
+ ..Default::default()
+ };
+
+ let filter_ast = ChannelFilters::expand_ast(channel_filters)
+ .unwrap()
+ .map(std::sync::Arc::new);
+
+ let params = GetChannelsRequest {
+ macro_id: user_id.into_owned(),
+ limit: Some(20),
+ query: Query::Sort(SimpleSortMethod::UpdatedAt, filter_ast),
+ }
+ .into_params();
+
+ let channels = get_user_channels_dynamic(&pool, &params).await.unwrap();
+
+ assert_eq!(
+ channels.len(),
+ 1,
+ "done=true + seen=true should return exactly one channel"
+ );
+ assert_eq!(
+ channels[0].channel.id.0.to_string(),
+ "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
+ );
+}
+
#[sqlx::test(
migrator = "MACRO_DB_MIGRATIONS",
fixtures(path = "../../../fixtures", scripts("channels"))
diff --git a/rust/cloud-storage/email/.sqlx/query-7fff4575b3f9a0b18bf943f16d5371de85e0e75ba490334f1ea8000a9a96f85e.json b/rust/cloud-storage/email/.sqlx/query-7fff4575b3f9a0b18bf943f16d5371de85e0e75ba490334f1ea8000a9a96f85e.json
deleted file mode 100644
index 970042865d..0000000000
--- a/rust/cloud-storage/email/.sqlx/query-7fff4575b3f9a0b18bf943f16d5371de85e0e75ba490334f1ea8000a9a96f85e.json
+++ /dev/null
@@ -1,110 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH ApplicableLabelIDs AS (\n SELECT id\n FROM email_labels\n WHERE link_id = $1\n AND (name = 'INBOX')\n ),\n QualifyingMessages AS (\n SELECT m.thread_id,\n m.internal_date_ts,\n m.is_draft,\n m.subject,\n m.snippet,\n m.from_contact_id,\n m.from_name\n FROM email_messages m\n WHERE m.link_id = $1\n AND EXISTS (\n SELECT 1\n FROM email_message_labels ml\n JOIN email_labels l ON ml.label_id = l.id\n WHERE ml.message_id = m.id\n AND l.name = 'IMPORTANT'\n )\n AND EXISTS (\n SELECT 1\n FROM email_message_labels ml\n JOIN ApplicableLabelIDs ali ON ml.label_id = ali.id\n WHERE ml.message_id = m.id\n )\n\n UNION ALL\n\n SELECT m.thread_id,\n m.internal_date_ts,\n m.is_draft,\n m.subject,\n m.snippet,\n m.from_contact_id,\n m.from_name\n FROM email_messages m\n WHERE m.link_id = $1\n AND m.is_draft = TRUE\n ),\n AllImportantThreads AS (\n -- From all qualifying messages, get the single most recent one per thread.\n SELECT DISTINCT ON (thread_id)\n thread_id,\n internal_date_ts,\n is_draft,\n subject,\n snippet,\n from_contact_id,\n from_name\n FROM QualifyingMessages\n ORDER BY thread_id, internal_date_ts DESC\n ),\n ImportantWithSortKey AS (\n -- Join with user_history to calculate the final effective sort key.\n SELECT\n ait.thread_id,\n ait.internal_date_ts,\n ait.is_draft,\n ait.subject,\n ait.snippet,\n ait.from_contact_id,\n ait.from_name,\n ait.internal_date_ts as created_at,\n ait.internal_date_ts as updated_at,\n uh.updated_at as viewed_at,\n -- This CASE statement dynamically selects the correct timestamp for sorting.\n -- For 'updated_at' and 'created_at', we use the important message timestamp\n -- For 'viewed_at', we use the history timestamp.\n -- For 'viewed_updated', we use the history timestamp if it exists, otherwise the important message timestamp.\n CASE $5 -- sort_method_str\n WHEN 'viewed_at' THEN COALESCE(uh.\"updated_at\", '1970-01-01 00:00:00+00')\n WHEN 'viewed_updated' THEN COALESCE(uh.updated_at, ait.internal_date_ts)\n ELSE ait.internal_date_ts\n END AS effective_ts\n FROM AllImportantThreads ait\n -- This has to be a left join to support all sort methods.\n LEFT JOIN email_user_history uh ON uh.thread_id = ait.thread_id AND uh.link_id = $1\n -- user_history updated_at (aka last time opened) has to exist when viewed_at sort method is selected.\n WHERE ait.is_draft = FALSE \n )\n SELECT\n isk.thread_id as \"id!\",\n t.provider_id,\n t.inbox_visible,\n t.is_read,\n isk.effective_ts as \"sort_ts!\",\n isk.created_at as \"created_at!\",\n isk.updated_at as \"updated_at!\",\n isk.viewed_at as \"viewed_at?\",\n isk.is_draft as \"is_draft!\",\n -- It's the important view - all threads here are important\n true as \"is_important!\",\n isk.subject as \"name?\",\n isk.snippet as \"snippet?\",\n c.email_address AS \"sender_email?\",\n COALESCE(isk.from_name, c.name) AS \"sender_name?\",\n c.sfs_photo_url as \"sender_photo_url?\"\n FROM ImportantWithSortKey isk\n JOIN email_threads t ON isk.thread_id = t.id\n LEFT JOIN email_contacts c ON isk.from_contact_id = c.id\n WHERE\n ($3::timestamptz IS NULL) OR (isk.effective_ts, isk.thread_id) < ($3::timestamptz, $4::uuid)\n ORDER BY isk.effective_ts DESC, isk.thread_id DESC\n LIMIT $2\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "id!",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "provider_id",
- "type_info": "Text"
- },
- {
- "ordinal": 2,
- "name": "inbox_visible",
- "type_info": "Bool"
- },
- {
- "ordinal": 3,
- "name": "is_read",
- "type_info": "Bool"
- },
- {
- "ordinal": 4,
- "name": "sort_ts!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 5,
- "name": "created_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 6,
- "name": "updated_at!",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 7,
- "name": "viewed_at?",
- "type_info": "Timestamptz"
- },
- {
- "ordinal": 8,
- "name": "is_draft!",
- "type_info": "Bool"
- },
- {
- "ordinal": 9,
- "name": "is_important!",
- "type_info": "Bool"
- },
- {
- "ordinal": 10,
- "name": "name?",
- "type_info": "Text"
- },
- {
- "ordinal": 11,
- "name": "snippet?",
- "type_info": "Text"
- },
- {
- "ordinal": 12,
- "name": "sender_email?",
- "type_info": "Varchar"
- },
- {
- "ordinal": 13,
- "name": "sender_name?",
- "type_info": "Varchar"
- },
- {
- "ordinal": 14,
- "name": "sender_photo_url?",
- "type_info": "Text"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "Int8",
- "Timestamptz",
- "Uuid",
- "Text"
- ]
- },
- "nullable": [
- null,
- true,
- false,
- false,
- null,
- null,
- null,
- false,
- null,
- null,
- null,
- null,
- false,
- null,
- true
- ]
- },
- "hash": "7fff4575b3f9a0b18bf943f16d5371de85e0e75ba490334f1ea8000a9a96f85e"
-}
diff --git a/rust/cloud-storage/email/.sqlx/query-815adc4c19436f160e5685d1f9d8b3874b4445d1e0aac343e6e077d7df5b1e32.json b/rust/cloud-storage/email/.sqlx/query-815adc4c19436f160e5685d1f9d8b3874b4445d1e0aac343e6e077d7df5b1e32.json
new file mode 100644
index 0000000000..c2dc614775
--- /dev/null
+++ b/rust/cloud-storage/email/.sqlx/query-815adc4c19436f160e5685d1f9d8b3874b4445d1e0aac343e6e077d7df5b1e32.json
@@ -0,0 +1,110 @@
+{
+ "db_name": "PostgreSQL",
+ "query": "\n WITH ApplicableLabelIDs AS (\n SELECT id\n FROM email_labels\n WHERE link_id = $1\n AND (name = 'INBOX')\n ),\n QualifyingMessages AS (\n SELECT m.thread_id,\n m.internal_date_ts,\n m.created_at AS fallback_ts,\n m.is_draft,\n m.subject,\n m.snippet,\n m.from_contact_id,\n m.from_name\n FROM email_messages m\n WHERE m.link_id = $1\n AND EXISTS (\n SELECT 1\n FROM email_message_labels ml\n JOIN email_labels l ON ml.label_id = l.id\n WHERE ml.message_id = m.id\n AND l.name = 'IMPORTANT'\n )\n AND EXISTS (\n SELECT 1\n FROM email_message_labels ml\n JOIN ApplicableLabelIDs ali ON ml.label_id = ali.id\n WHERE ml.message_id = m.id\n )\n\n UNION ALL\n\n SELECT m.thread_id,\n m.internal_date_ts,\n m.created_at AS fallback_ts,\n m.is_draft,\n m.subject,\n m.snippet,\n m.from_contact_id,\n m.from_name\n FROM email_messages m\n WHERE m.link_id = $1\n AND m.is_draft = TRUE\n ),\n AllImportantThreads AS (\n -- From all qualifying messages, get the single most recent one per thread.\n SELECT DISTINCT ON (thread_id)\n thread_id,\n internal_date_ts,\n fallback_ts,\n is_draft,\n subject,\n snippet,\n from_contact_id,\n from_name\n FROM QualifyingMessages\n ORDER BY thread_id, COALESCE(internal_date_ts, fallback_ts) DESC\n ),\n ImportantWithSortKey AS (\n -- Join with user_history to calculate the final effective sort key.\n SELECT\n ait.thread_id,\n ait.internal_date_ts,\n ait.fallback_ts,\n ait.is_draft,\n ait.subject,\n ait.snippet,\n ait.from_contact_id,\n ait.from_name,\n COALESCE(ait.internal_date_ts, ait.fallback_ts) as created_at,\n COALESCE(ait.internal_date_ts, ait.fallback_ts) as updated_at,\n uh.updated_at as viewed_at,\n -- This CASE statement dynamically selects the correct timestamp for sorting.\n -- For 'updated_at' and 'created_at', we use the important message timestamp\n -- For 'viewed_at', we use the history timestamp.\n -- For 'viewed_updated', we use the history timestamp if it exists, otherwise the important message timestamp.\n CASE $5 -- sort_method_str\n WHEN 'viewed_at' THEN COALESCE(uh.\"updated_at\", '1970-01-01 00:00:00+00')\n WHEN 'viewed_updated' THEN COALESCE(uh.updated_at, COALESCE(ait.internal_date_ts, ait.fallback_ts))\n ELSE COALESCE(ait.internal_date_ts, ait.fallback_ts)\n END AS effective_ts\n FROM AllImportantThreads ait\n -- This has to be a left join to support all sort methods.\n LEFT JOIN email_user_history uh ON uh.thread_id = ait.thread_id AND uh.link_id = $1\n )\n SELECT\n isk.thread_id as \"id!\",\n t.provider_id,\n t.inbox_visible,\n t.is_read,\n isk.effective_ts as \"sort_ts!\",\n isk.created_at as \"created_at!\",\n isk.updated_at as \"updated_at!\",\n isk.viewed_at as \"viewed_at?\",\n isk.is_draft as \"is_draft!\",\n -- It's the important view - all threads here are important\n true as \"is_important!\",\n isk.subject as \"name?\",\n isk.snippet as \"snippet?\",\n c.email_address AS \"sender_email?\",\n COALESCE(isk.from_name, c.name) AS \"sender_name?\",\n c.sfs_photo_url as \"sender_photo_url?\"\n FROM ImportantWithSortKey isk\n JOIN email_threads t ON isk.thread_id = t.id\n LEFT JOIN email_contacts c ON isk.from_contact_id = c.id\n WHERE\n ($3::timestamptz IS NULL) OR (isk.effective_ts, isk.thread_id) < ($3::timestamptz, $4::uuid)\n ORDER BY isk.effective_ts DESC, isk.thread_id DESC\n LIMIT $2\n ",
+ "describe": {
+ "columns": [
+ {
+ "ordinal": 0,
+ "name": "id!",
+ "type_info": "Uuid"
+ },
+ {
+ "ordinal": 1,
+ "name": "provider_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 2,
+ "name": "inbox_visible",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 3,
+ "name": "is_read",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 4,
+ "name": "sort_ts!",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 5,
+ "name": "created_at!",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 6,
+ "name": "updated_at!",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 7,
+ "name": "viewed_at?",
+ "type_info": "Timestamptz"
+ },
+ {
+ "ordinal": 8,
+ "name": "is_draft!",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 9,
+ "name": "is_important!",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 10,
+ "name": "name?",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 11,
+ "name": "snippet?",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 12,
+ "name": "sender_email?",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 13,
+ "name": "sender_name?",
+ "type_info": "Varchar"
+ },
+ {
+ "ordinal": 14,
+ "name": "sender_photo_url?",
+ "type_info": "Text"
+ }
+ ],
+ "parameters": {
+ "Left": [
+ "Uuid",
+ "Int8",
+ "Timestamptz",
+ "Uuid",
+ "Text"
+ ]
+ },
+ "nullable": [
+ null,
+ true,
+ false,
+ false,
+ null,
+ null,
+ null,
+ false,
+ null,
+ null,
+ null,
+ null,
+ false,
+ null,
+ true
+ ]
+ },
+ "hash": "815adc4c19436f160e5685d1f9d8b3874b4445d1e0aac343e6e077d7df5b1e32"
+}
diff --git a/rust/cloud-storage/email/.sqlx/query-9664c74048343a599597cd14915ea3177893f42df9040b6cdd37d949588a58ed.json b/rust/cloud-storage/email/.sqlx/query-9664c74048343a599597cd14915ea3177893f42df9040b6cdd37d949588a58ed.json
deleted file mode 100644
index 5374df682d..0000000000
--- a/rust/cloud-storage/email/.sqlx/query-9664c74048343a599597cd14915ea3177893f42df9040b6cdd37d949588a58ed.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n WITH user_link AS (\n SELECT id as link_id, email_address\n FROM email_links\n WHERE id = $1\n LIMIT 1\n ),\n -- Get all email addresses the user has previously sent messages to\n previously_contacted AS (\n SELECT DISTINCT c.email_address\n FROM email_messages m\n JOIN email_message_recipients mr ON m.id = mr.message_id\n JOIN email_contacts c ON mr.contact_id = c.id\n CROSS JOIN user_link\n WHERE m.link_id = user_link.link_id\n AND m.is_sent = true\n AND c.email_address != user_link.email_address\n )\n -- Find threads where any sender is in the previously contacted list\n SELECT DISTINCT m.thread_id\n FROM email_messages m\n JOIN email_contacts c ON m.from_contact_id = c.id\n WHERE m.thread_id = ANY($2)\n AND EXISTS (\n SELECT 1\n FROM previously_contacted pc\n WHERE pc.email_address = c.email_address\n )\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "thread_id",
- "type_info": "Uuid"
- }
- ],
- "parameters": {
- "Left": [
- "Uuid",
- "UuidArray"
- ]
- },
- "nullable": [
- false
- ]
- },
- "hash": "9664c74048343a599597cd14915ea3177893f42df9040b6cdd37d949588a58ed"
-}
diff --git a/rust/cloud-storage/email/.sqlx/query-ecbe0b20fae1b19509f693cc4f1acf51e5028a38a9b13cad6f5d6bca58676feb.json b/rust/cloud-storage/email/.sqlx/query-ecbe0b20fae1b19509f693cc4f1acf51e5028a38a9b13cad6f5d6bca58676feb.json
deleted file mode 100644
index 27a1910c1e..0000000000
--- a/rust/cloud-storage/email/.sqlx/query-ecbe0b20fae1b19509f693cc4f1acf51e5028a38a9b13cad6f5d6bca58676feb.json
+++ /dev/null
@@ -1,40 +0,0 @@
-{
- "db_name": "PostgreSQL",
- "query": "\n SELECT\n m.thread_id,\n -- Check if any message in thread has table HTML\n COALESCE(bool_or(m.body_html_sanitized LIKE '%<table%'), false) as \"has_table!\",\n -- Check if any message has calendar invite attachment\n COALESCE(bool_or(has_calendar.has_invite), false) as \"has_calendar_invite!\",\n -- Collect all unique sender emails in the thread\n COALESCE(array_agg(DISTINCT c.email_address), ARRAY[]::text[]) as \"sender_emails!: Vec<String>\"\n FROM email_messages m\n LEFT JOIN email_contacts c ON m.from_contact_id = c.id\n LEFT JOIN LATERAL (\n SELECT true as has_invite\n FROM email_attachments a\n WHERE a.message_id = m.id AND a.mime_type = 'application/ics'\n LIMIT 1\n ) has_calendar ON true\n WHERE m.thread_id = ANY($1)\n GROUP BY m.thread_id\n ",
- "describe": {
- "columns": [
- {
- "ordinal": 0,
- "name": "thread_id",
- "type_info": "Uuid"
- },
- {
- "ordinal": 1,
- "name": "has_table!",
- "type_info": "Bool"
- },
- {
- "ordinal": 2,
- "name": "has_calendar_invite!",
- "type_info": "Bool"
- },
- {
- "ordinal": 3,
- "name": "sender_emails!: Vec<String>",
- "type_info": "VarcharArray"
- }
- ],
- "parameters": {
- "Left": [
- "UuidArray"
- ]
- },
- "nullable": [
- false,
- null,
- null,
- null
- ]
- },
- "hash": "ecbe0b20fae1b19509f693cc4f1acf51e5028a38a9b13cad6f5d6bca58676feb"
-}
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic.rs
index 3480cdef83..c8ed440643 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic.rs
@@ -130,6 +130,8 @@ fn build_message_email_filter(ast: &Expr<EmailLiteral>) -> String {
filter_ast::ExprFrame::Literal(EmailLiteral::Importance(true)) => {
// Signal: has a priority label OR does not have a depriority label
r#"(
+ m.is_draft = TRUE
+ OR
EXISTS (
SELECT 1 FROM email_message_labels ml
JOIN email_labels l ON ml.label_id = l.id
@@ -163,6 +165,10 @@ fn build_message_email_filter(ast: &Expr<EmailLiteral>) -> String {
)"#
.to_string()
}
+ // Email notification filters are accepted for cross-entity API compatibility
+ // but are not currently applied by email thread query logic.
+ filter_ast::ExprFrame::Literal(EmailLiteral::NotificationDone(_)) => "TRUE".to_string(),
+ filter_ast::ExprFrame::Literal(EmailLiteral::NotificationSeen(_)) => "TRUE".to_string(),
});
if formatting.is_empty() {
@@ -188,7 +194,9 @@ fn build_thread_email_filter(ast: &Expr<EmailLiteral>) -> String {
| EmailLiteral::Cc(_)
| EmailLiteral::Bcc(_)
| EmailLiteral::Recipient(_)
- | EmailLiteral::Importance(_),
+ | EmailLiteral::Importance(_)
+ | EmailLiteral::NotificationDone(_)
+ | EmailLiteral::NotificationSeen(_),
) => "TRUE".to_string(),
});
@@ -264,12 +272,15 @@ fn build_view_message_filter(view: &PreviewView, link_id_param: &str) -> String
}
PreviewView::StandardLabel(PreviewViewStandardLabel::Important) => {
format!(
- r#" AND EXISTS (
- SELECT 1 FROM email_message_labels ml
- JOIN email_labels l ON ml.label_id = l.id
- WHERE ml.message_id = m.id
- AND l.name = 'IMPORTANT'
- AND l.link_id = {}
+ r#" AND (
+ m.is_draft = TRUE
+ OR EXISTS (
+ SELECT 1 FROM email_message_labels ml
+ JOIN email_labels l ON ml.label_id = l.id
+ WHERE ml.message_id = m.id
+ AND l.name = 'IMPORTANT'
+ AND l.link_id = {}
+ )
)"#,
link_id_param
)
@@ -310,7 +321,7 @@ fn get_sort_timestamp_field(view: &PreviewView) -> &'static str {
PreviewView::StandardLabel(PreviewViewStandardLabel::Inbox) => {
"t.latest_inbound_message_ts"
}
- _ => "t.latest_non_spam_message_ts",
+ _ => "COALESCE(t.latest_non_spam_message_ts, t.updated_at)",
}
}
@@ -337,17 +348,20 @@ fn build_query<'a>(
lmp.subject AS name,
lmp.snippet,
lmp.is_draft,
- (
- SELECT EXISTS (
- SELECT 1
- FROM email_messages m_imp
- JOIN email_message_labels ml ON m_imp.id = ml.message_id
- JOIN email_labels l ON ml.label_id = l.id
- WHERE m_imp.thread_id = t.id
- AND l.name = 'IMPORTANT'
- AND l.link_id = t.link_id
+ CASE
+ WHEN $6 THEN TRUE
+ ELSE (
+ SELECT EXISTS (
+ SELECT 1
+ FROM email_messages m_imp
+ JOIN email_message_labels ml ON m_imp.id = ml.message_id
+ JOIN email_labels l ON ml.label_id = l.id
+ WHERE m_imp.thread_id = t.id
+ AND l.name = 'IMPORTANT'
+ AND l.link_id = t.link_id
+ )
)
- ) AS is_important,
+ END AS is_important,
c.email_address AS sender_email,
c.name AS sender_name,
c.sfs_photo_url as sender_photo_url
@@ -436,7 +450,7 @@ fn build_query<'a>(
builder.push(
r#"
- ORDER BY m.internal_date_ts DESC
+ ORDER BY COALESCE(m.internal_date_ts, m.created_at) DESC
LIMIT 1
) AS lmp
-- Step 3: Join to get the sender's details
@@ -496,6 +510,10 @@ pub(crate) async fn dynamic_email_thread_cursor(
.bind(query_limit) // $3
.bind(cursor_timestamp) // $4
.bind(cursor_id_str) // $5
+ .bind(matches!(
+ view,
+ PreviewView::StandardLabel(PreviewViewStandardLabel::Important)
+ )) // $6
.try_map(|row| {
Ok(ThreadPreviewCursorDbRow {
id: row.try_get("id")?,
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic/tests.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic/tests.rs
index 7577021266..0d14c5da1b 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic/tests.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/dynamic/tests.rs
@@ -28,6 +28,14 @@ fn test_build_message_email_filter_sender_partial() {
assert!(result.contains("c.email_address ILIKE '%example%'"));
}
+#[test]
+fn test_build_message_email_filter_importance_true_includes_drafts() {
+ let expr = Expr::Literal(EmailLiteral::Importance(true));
+ let result = build_message_email_filter(&expr);
+
+ assert!(result.contains("m.is_draft = TRUE"));
+}
+
#[test]
fn test_build_message_email_filter_recipient() {
let email = Email::Complete(
@@ -173,6 +181,7 @@ fn test_build_view_message_filter_important() {
let view = PreviewView::StandardLabel(PreviewViewStandardLabel::Important);
let result = build_view_message_filter(&view, "$1");
assert!(result.contains("IMPORTANT"));
+ assert!(result.contains("m.is_draft = TRUE"));
assert!(result.contains("EXISTS"));
}
@@ -202,7 +211,10 @@ fn test_get_sort_timestamp_field_inbox() {
fn test_get_sort_timestamp_field_default() {
let view = PreviewView::StandardLabel(PreviewViewStandardLabel::All);
let result = get_sort_timestamp_field(&view);
- assert_eq!(result, "t.latest_non_spam_message_ts");
+ assert_eq!(
+ result,
+ "COALESCE(t.latest_non_spam_message_ts, t.updated_at)"
+ );
}
#[test]
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/queries/important.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/queries/important.rs
index 326ca9b10b..a38bf6f5b6 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/queries/important.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/queries/important.rs
@@ -31,6 +31,7 @@ pub(crate) async fn important_preview_cursor(
QualifyingMessages AS (
SELECT m.thread_id,
m.internal_date_ts,
+ m.created_at AS fallback_ts,
m.is_draft,
m.subject,
m.snippet,
@@ -56,6 +57,7 @@ pub(crate) async fn important_preview_cursor(
SELECT m.thread_id,
m.internal_date_ts,
+ m.created_at AS fallback_ts,
m.is_draft,
m.subject,
m.snippet,
@@ -70,26 +72,28 @@ pub(crate) async fn important_preview_cursor(
SELECT DISTINCT ON (thread_id)
thread_id,
internal_date_ts,
+ fallback_ts,
is_draft,
subject,
snippet,
from_contact_id,
from_name
FROM QualifyingMessages
- ORDER BY thread_id, internal_date_ts DESC
+ ORDER BY thread_id, COALESCE(internal_date_ts, fallback_ts) DESC
),
ImportantWithSortKey AS (
-- Join with user_history to calculate the final effective sort key.
SELECT
ait.thread_id,
ait.internal_date_ts,
+ ait.fallback_ts,
ait.is_draft,
ait.subject,
ait.snippet,
ait.from_contact_id,
ait.from_name,
- ait.internal_date_ts as created_at,
- ait.internal_date_ts as updated_at,
+ COALESCE(ait.internal_date_ts, ait.fallback_ts) as created_at,
+ COALESCE(ait.internal_date_ts, ait.fallback_ts) as updated_at,
uh.updated_at as viewed_at,
-- This CASE statement dynamically selects the correct timestamp for sorting.
-- For 'updated_at' and 'created_at', we use the important message timestamp
@@ -97,14 +101,12 @@ pub(crate) async fn important_preview_cursor(
-- For 'viewed_updated', we use the history timestamp if it exists, otherwise the important message timestamp.
CASE $5 -- sort_method_str
WHEN 'viewed_at' THEN COALESCE(uh."updated_at", '1970-01-01 00:00:00+00')
- WHEN 'viewed_updated' THEN COALESCE(uh.updated_at, ait.internal_date_ts)
- ELSE ait.internal_date_ts
+ WHEN 'viewed_updated' THEN COALESCE(uh.updated_at, COALESCE(ait.internal_date_ts, ait.fallback_ts))
+ ELSE COALESCE(ait.internal_date_ts, ait.fallback_ts)
END AS effective_ts
FROM AllImportantThreads ait
-- This has to be a left join to support all sort methods.
LEFT JOIN email_user_history uh ON uh.thread_id = ait.thread_id AND uh.link_id = $1
- -- user_history updated_at (aka last time opened) has to exist when viewed_at sort method is selected.
- WHERE ait.is_draft = FALSE
)
SELECT
isk.thread_id as "id!",
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/test.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/test.rs
index b331849335..5f958ab3f0 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/test.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/test.rs
@@ -276,16 +276,56 @@ async fn test_dynamic_query_important_view(pool: Pool<Postgres>) -> anyhow::Resu
let results =
dynamic::dynamic_email_thread_cursor(&pool, &link_id, limit, &view, query).await?;
- // Should get important messages (thread 5)
- assert_eq!(results.len(), 1, "Important view should return 1 thread");
+ // Should get important messages and drafts (threads 5 and 3)
+ assert_eq!(results.len(), 2, "Important view should return 2 threads");
+
+ let result_ids: std::collections::HashSet<String> =
+ results.iter().map(|r| r.id.to_string()).collect();
+
+ assert!(
+ result_ids.contains("20000003-0000-0000-0000-000000000003"),
+ "Should include draft thread 3"
+ );
+ assert!(
+ result_ids.contains("20000005-0000-0000-0000-000000000005"),
+ "Should include important thread 5"
+ );
+ assert!(results.iter().all(|r| r.is_important));
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(path = "../../../fixtures", scripts("email_dynamic_query"))
+)]
+async fn test_static_important_query_includes_drafts(pool: Pool<Postgres>) -> anyhow::Result<()> {
+ let link_id = Uuid::parse_str("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")?;
+ let limit = 50;
+ let query = Query::Sort(SimpleSortMethod::UpdatedAt, ());
+
+ let results =
+ queries::important::important_preview_cursor(&pool, &link_id, limit, &query).await?;
+
assert_eq!(
- results[0].id.to_string(),
- "20000005-0000-0000-0000-000000000005"
+ results.len(),
+ 2,
+ "Static important query should return both important and draft threads"
+ );
+
+ let result_ids: std::collections::HashSet<String> =
+ results.iter().map(|r| r.id.to_string()).collect();
+
+ assert!(
+ result_ids.contains("20000003-0000-0000-0000-000000000003"),
+ "Should include draft thread 3"
);
assert!(
- results[0].is_important,
- "Message should be marked as important"
+ result_ids.contains("20000005-0000-0000-0000-000000000005"),
+ "Should include important thread 5"
);
+ assert!(results.iter().all(|r| r.is_important));
+ assert!(results.iter().any(|r| r.is_draft));
Ok(())
}
diff --git a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic.rs b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic.rs
index 1fa16db816..d5caa21ebf 100644
--- a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic.rs
+++ b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic.rs
@@ -15,15 +15,15 @@ use super::FrecencyStorageErr;
static DOCUMENT_CLAUSE: &str = r#"
SELECT
- entity_id,
+ fa.entity_id,
'document' as entity_type,
- user_id,
- event_count,
- frecency_score,
- first_event,
- recent_events
- FROM frecency_aggregates
- WHERE user_id = $1 AND entity_type = 'document'
+ fa.user_id,
+ fa.event_count,
+ fa.frecency_score,
+ fa.first_event,
+ fa.recent_events
+ FROM frecency_aggregates fa
+ WHERE fa.user_id = $1 AND fa.entity_type = 'document'
"#;
static CHAT_CLAUSE: &str = r#"
@@ -59,6 +59,79 @@ static SUFFIX: &str = r#"
LIMIT $3
"#;
+const ASSIGNEES_PROPERTY_ID: &str = "00000001-0000-0000-0000-000000000001";
+const STATUS_PROPERTY_ID: &str = "00000001-0000-0000-0000-000000000002";
+const COMPLETED_STATUS_OPTION_ID: &str = "00000001-0000-0000-0002-000000000004";
+
+fn build_notification_exists_clause(
+ entity_id_sql: &str,
+ entity_type: &str,
+ predicate_sql: &str,
+) -> String {
+ format!(
+ r#"EXISTS (
+ SELECT 1
+ FROM notification n
+ JOIN user_notification un ON un.notification_id = n.id
+ WHERE un.user_id = $1
+ AND un.deleted_at IS NULL
+ AND n.event_item_type = '{entity_type}'
+ AND n.event_item_id = {entity_id_sql}
+ AND {predicate_sql}
+ )"#
+ )
+}
+
+fn build_notification_done_clause(entity_id_sql: &str, entity_type: &str, done: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if done {
+ "un.done = true"
+ } else {
+ "un.done = false"
+ },
+ )
+}
+
+fn build_notification_seen_clause(entity_id_sql: &str, entity_type: &str, seen: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if seen {
+ "un.seen_at IS NOT NULL"
+ } else {
+ "un.seen_at IS NULL"
+ },
+ )
+}
+
+fn build_task_include_cbm_atm_nc_clause(entity_id_sql: &str) -> String {
+ format!(
+ r#"entity_id IN (
+ SELECT d.id::text
+ FROM "Document" d
+ LEFT JOIN document_sub_type dt ON dt.document_id = d.id
+ LEFT JOIN entity_properties ep_assignees
+ ON dt.sub_type = 'task'
+ AND ep_assignees.entity_id = d.id
+ AND ep_assignees.entity_type = 'TASK'
+ AND ep_assignees.property_definition_id = '{ASSIGNEES_PROPERTY_ID}'
+ LEFT JOIN entity_properties ep_status
+ ON dt.sub_type = 'task'
+ AND ep_status.entity_id = d.id
+ AND ep_status.entity_type = 'TASK'
+ AND ep_status.property_definition_id = '{STATUS_PROPERTY_ID}'
+ WHERE d.id::text = {entity_id_sql}
+ AND d."deletedAt" IS NULL
+ AND dt.sub_type = 'task'
+ AND d.owner = $1
+ AND ep_assignees.values->'value' @> jsonb_build_array(jsonb_build_object('entity_id', $1))
+ AND NOT COALESCE(ep_status.values->'value' ? '{COMPLETED_STATUS_OPTION_ID}', false)
+ )"#
+ )
+}
+
fn build_document_filter(ast: Option<&Expr<DocumentLiteral>>) -> String {
let Some(expr) = ast else {
return String::new();
@@ -97,6 +170,16 @@ fn build_document_filter(ast: Option<&Expr<DocumentLiteral>>) -> String {
)"#
.to_string()
}
+ filter_ast::ExprFrame::Literal(DocumentLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("fa.entity_id", "document", done)
+ }
+ filter_ast::ExprFrame::Literal(DocumentLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("fa.entity_id", "document", seen)
+ }
+ filter_ast::ExprFrame::Literal(DocumentLiteral::IncludeCbmAtmNc(true)) => {
+ build_task_include_cbm_atm_nc_clause("fa.entity_id")
+ }
+ filter_ast::ExprFrame::Literal(DocumentLiteral::IncludeCbmAtmNc(false)) => String::new(),
});
if formatting.is_empty() {
String::new()
@@ -144,6 +227,12 @@ fn build_chat_filter(ast: Option<&Expr<ChatLiteral>>) -> String {
// all chats are important, so if importance is false, exclude them
filter_ast::ExprFrame::Literal(ChatLiteral::Importance(true)) => String::new(),
filter_ast::ExprFrame::Literal(ChatLiteral::Importance(false)) => "1=0".to_string(),
+ filter_ast::ExprFrame::Literal(ChatLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("entity_id", "chat", done)
+ }
+ filter_ast::ExprFrame::Literal(ChatLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("entity_id", "chat", seen)
+ }
});
if formatting.is_empty() {
String::new()
@@ -169,6 +258,12 @@ fn build_project_filter(ast: Option<&Expr<ProjectLiteral>>) -> String {
filter_ast::ExprFrame::Literal(ProjectLiteral::Importance(true)) => String::new(),
// all projects are important, so if importance is false, exclude them
filter_ast::ExprFrame::Literal(ProjectLiteral::Importance(false)) => "1=0".to_string(),
+ filter_ast::ExprFrame::Literal(ProjectLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("entity_id", "project", done)
+ }
+ filter_ast::ExprFrame::Literal(ProjectLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("entity_id", "project", seen)
+ }
});
if formatting.is_empty() {
String::new()
diff --git a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
index 4d1ce6a387..95bf22a105 100644
--- a/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
+++ b/rust/cloud-storage/frecency/src/outbound/postgres/dynamic_tests.rs
@@ -3,7 +3,9 @@
use super::*;
use crate::domain::models::{AggregateId, FrecencyData};
use chrono::Utc;
-use item_filters::{ChatFilters, DocumentFilters, EntityFilters, ProjectFilters};
+use item_filters::{
+ ChatFilters, DocumentFilters, EntityFilters, NotificationFilters, ProjectFilters, TaskFilters,
+};
use macro_db_migrator::MACRO_DB_MIGRATIONS;
use macro_user_id::{cowlike::CowLike, user_id::MacroUserIdStr};
use model_entity::EntityType;
@@ -436,3 +438,244 @@ async fn test_dynamic_filter_no_matches(pool: PgPool) {
assert_eq!(results.len(), 0);
}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn test_dynamic_filter_document_notification_done(pool: PgPool) {
+ let storage = FrecencyPgStorage::new(pool.clone());
+ let test_user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+
+ let doc_id_1 = Uuid::new_v4();
+ let doc_id_2 = Uuid::new_v4();
+
+ for (id, score) in [(doc_id_1.to_string(), 100.0), (doc_id_2.to_string(), 90.0)] {
+ storage
+ .set_aggregate(AggregateFrecency {
+ id: AggregateId {
+ entity: EntityType::Document.with_entity_string(id),
+ user_id: test_user_id.clone(),
+ },
+ data: FrecencyData {
+ event_count: 1,
+ frecency_score: score,
+ first_event: Utc::now(),
+ recent_events: VecDeque::new(),
+ },
+ })
+ .await
+ .unwrap();
+ }
+
+ // Notification for doc 1 is not done/unseen.
+ let notification_id_1 = Uuid::new_v4();
+ sqlx::query(
+ r#"
+ INSERT INTO notification
+ (id, notification_event_type, event_item_id, event_item_type, service_sender, metadata, sender_id)
+ VALUES
+ ($1, 'test', $2, 'document', 'test', '{}'::jsonb, NULL)
+ "#,
+ )
+ .bind(notification_id_1)
+ .bind(doc_id_1.to_string())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ // Notification for doc 2 is done/seen.
+ let notification_id_2 = Uuid::new_v4();
+ sqlx::query(
+ r#"
+ INSERT INTO notification
+ (id, notification_event_type, event_item_id, event_item_type, service_sender, metadata, sender_id)
+ VALUES
+ ($1, 'test', $2, 'document', 'test', '{}'::jsonb, NULL)
+ "#,
+ )
+ .bind(notification_id_2)
+ .bind(doc_id_2.to_string())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ sqlx::query(
+ r#"
+ INSERT INTO user_notification (user_id, notification_id, created_at, seen_at, done)
+ VALUES ($1, $2, NOW(), NULL, false), ($1, $3, NOW(), NOW(), true)
+ "#,
+ )
+ .bind(test_user_id.as_ref())
+ .bind(notification_id_1)
+ .bind(notification_id_2)
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ let filter = item_filters::ast::EntityFilterAst::new_from_filters(EntityFilters {
+ document_filters: DocumentFilters {
+ notification_filters: NotificationFilters {
+ done: Some(false),
+ seen: None,
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ })
+ .unwrap()
+ .unwrap();
+
+ let results = storage
+ .get_top_entities(FrecencyPageRequest {
+ user_id: test_user_id.copied(),
+ from_score: None,
+ limit: 10,
+ filters: Some(filter),
+ })
+ .await
+ .unwrap();
+
+ assert_eq!(results.len(), 1);
+ assert_eq!(results[0].id.entity.entity_id, doc_id_1.to_string());
+}
+
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn test_dynamic_filter_document_task_include_cbm_atm_nc(pool: PgPool) {
+ let storage = FrecencyPgStorage::new(pool.clone());
+ let test_user_id = MacroUserIdStr::parse_from_str("macro|[email protected]").unwrap();
+
+ // Ensure owner row exists for foreign keys from Document.owner.
+ sqlx::query(
+ r#"
+ INSERT INTO "User" ("id", "email")
+ VALUES ($1, $2)
+ ON CONFLICT ("id") DO NOTHING
+ "#,
+ )
+ .bind(test_user_id.as_ref())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ let matching_task_id = Uuid::new_v4();
+ let non_matching_task_id = Uuid::new_v4();
+
+ sqlx::query(
+ r#"
+ INSERT INTO "Document" ("id", "name", "owner", "fileType", "createdAt", "updatedAt")
+ VALUES
+ ($1, 'Matching Task', $3, 'txt', NOW(), NOW()),
+ ($2, 'Non Matching Task', $3, 'txt', NOW(), NOW())
+ "#,
+ )
+ .bind(matching_task_id.to_string())
+ .bind(non_matching_task_id.to_string())
+ .bind(test_user_id.as_ref())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ sqlx::query(
+ r#"
+ INSERT INTO document_sub_type (document_id, sub_type)
+ VALUES ($1, 'task'), ($2, 'task')
+ "#,
+ )
+ .bind(matching_task_id.to_string())
+ .bind(non_matching_task_id.to_string())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ // Matching task: assigned to current user + status in progress.
+ sqlx::query(
+ r#"
+ INSERT INTO entity_properties (id, entity_id, entity_type, property_definition_id, values)
+ VALUES
+ (
+ gen_random_uuid(),
+ $1,
+ 'TASK',
+ '00000001-0000-0000-0000-000000000001',
+ jsonb_build_object(
+ 'type', 'EntityReference',
+ 'value', jsonb_build_array(
+ jsonb_build_object('entity_id', $3, 'entity_type', 'USER')
+ )
+ )
+ ),
+ (
+ gen_random_uuid(),
+ $1,
+ 'TASK',
+ '00000001-0000-0000-0000-000000000002',
+ '{"type":"SelectOption","value":["00000001-0000-0000-0002-000000000002"]}'::jsonb
+ ),
+ (
+ gen_random_uuid(),
+ $2,
+ 'TASK',
+ '00000001-0000-0000-0000-000000000001',
+ '{"type":"EntityReference","value":[{"entity_id":"macro|[email protected]","entity_type":"USER"}]}'::jsonb
+ ),
+ (
+ gen_random_uuid(),
+ $2,
+ 'TASK',
+ '00000001-0000-0000-0000-000000000002',
+ '{"type":"SelectOption","value":["00000001-0000-0000-0002-000000000002"]}'::jsonb
+ )
+ "#,
+ )
+ .bind(matching_task_id.to_string())
+ .bind(non_matching_task_id.to_string())
+ .bind(test_user_id.as_ref())
+ .execute(&pool)
+ .await
+ .unwrap();
+
+ for (id, score) in [
+ (matching_task_id.to_string(), 100.0),
+ (non_matching_task_id.to_string(), 90.0),
+ ] {
+ storage
+ .set_aggregate(AggregateFrecency {
+ id: AggregateId {
+ entity: EntityType::Document.with_entity_string(id),
+ user_id: test_user_id.clone(),
+ },
+ data: FrecencyData {
+ event_count: 1,
+ frecency_score: score,
+ first_event: Utc::now(),
+ recent_events: VecDeque::new(),
+ },
+ })
+ .await
+ .unwrap();
+ }
+
+ let filter = item_filters::ast::EntityFilterAst::new_from_filters(EntityFilters {
+ document_filters: DocumentFilters {
+ task_filters: TaskFilters {
+ include_cbm_atm_nc: Some(true),
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ })
+ .unwrap()
+ .unwrap();
+
+ let results = storage
+ .get_top_entities(FrecencyPageRequest {
+ user_id: test_user_id.copied(),
+ from_score: None,
+ limit: 10,
+ filters: Some(filter),
+ })
+ .await
+ .unwrap();
+
+ assert_eq!(results.len(), 1);
+ assert_eq!(results[0].id.entity.entity_id, matching_task_id.to_string());
+}
diff --git a/rust/cloud-storage/item_filters/src/ast/channel.rs b/rust/cloud-storage/item_filters/src/ast/channel.rs
index 94c61b1faf..23077b30a3 100644
--- a/rust/cloud-storage/item_filters/src/ast/channel.rs
+++ b/rust/cloud-storage/item_filters/src/ast/channel.rs
@@ -56,6 +56,10 @@ pub enum ChannelLiteral {
ChannelType(ChannelTypeFilter),
/// this node value filters by channel importance. false short-circuits to match nothing.
Importance(bool),
+ /// this node value filters by notification done state for channels.
+ NotificationDone(bool),
+ /// this node value filters by notification seen state for channels.
+ NotificationSeen(bool),
}
impl ExpandFrame<ChannelLiteral> for ChannelFilters {
@@ -72,6 +76,7 @@ impl ExpandFrame<ChannelLiteral> for ChannelFilters {
sender_ids,
channel_types,
importance,
+ notification_filters,
} = filter_request;
let thread_ids = thread_ids
@@ -104,6 +109,12 @@ impl ExpandFrame<ChannelLiteral> for ChannelFilters {
.try_expand(|r| r.map(ChannelLiteral::ChannelType), Expr::or)?;
let importance_node = importance.map(|imp| Expr::Literal(ChannelLiteral::Importance(imp)));
+ let notification_done_node = notification_filters
+ .done
+ .map(|done| Expr::Literal(ChannelLiteral::NotificationDone(done)));
+ let notification_seen_node = notification_filters
+ .seen
+ .map(|seen| Expr::Literal(ChannelLiteral::NotificationSeen(seen)));
Ok([
thread_ids,
@@ -113,6 +124,8 @@ impl ExpandFrame<ChannelLiteral> for ChannelFilters {
sender_ids,
channel_type_nodes,
importance_node,
+ notification_done_node,
+ notification_seen_node,
]
.into_iter()
.fold_with(Expr::and))
diff --git a/rust/cloud-storage/item_filters/src/ast/chat.rs b/rust/cloud-storage/item_filters/src/ast/chat.rs
index 890dcb30a2..36ce09f10e 100644
--- a/rust/cloud-storage/item_filters/src/ast/chat.rs
+++ b/rust/cloud-storage/item_filters/src/ast/chat.rs
@@ -21,6 +21,10 @@ pub enum ChatLiteral {
Owner(MacroUserIdStr<'static>),
/// this node value filters by chat importance. false short-circuits to match nothing.
Importance(bool),
+ /// this node value filters by notification done state for chats.
+ NotificationDone(bool),
+ /// this node value filters by notification seen state for chats.
+ NotificationSeen(bool),
}
/// the possible roles for a chat
@@ -58,6 +62,7 @@ impl ExpandFrame<ChatLiteral> for ChatFilters {
project_ids,
owners,
importance,
+ notification_filters,
} = filter_request;
let project_ids = project_ids
@@ -81,9 +86,23 @@ impl ExpandFrame<ChatLiteral> for ChatFilters {
.try_expand(|r| r.map(ChatLiteral::Owner), Expr::or)?;
let importance_node = importance.map(|imp| Expr::Literal(ChatLiteral::Importance(imp)));
+ let notification_done_node = notification_filters
+ .done
+ .map(|done| Expr::Literal(ChatLiteral::NotificationDone(done)));
+ let notification_seen_node = notification_filters
+ .seen
+ .map(|seen| Expr::Literal(ChatLiteral::NotificationSeen(seen)));
- Ok([project_ids, chat_ids, role, owners, importance_node]
- .into_iter()
- .fold_with(Expr::and))
+ Ok([
+ project_ids,
+ chat_ids,
+ role,
+ owners,
+ importance_node,
+ notification_done_node,
+ notification_seen_node,
+ ]
+ .into_iter()
+ .fold_with(Expr::and))
}
}
diff --git a/rust/cloud-storage/item_filters/src/ast/document.rs b/rust/cloud-storage/item_filters/src/ast/document.rs
index c1fe7ae8e9..5f0f82d5f4 100644
--- a/rust/cloud-storage/item_filters/src/ast/document.rs
+++ b/rust/cloud-storage/item_filters/src/ast/document.rs
@@ -32,6 +32,15 @@ pub enum DocumentLiteral {
/// this node value filters by document importance. false short-circuits to match nothing.
#[serde(rename = "imp")]
Importance(bool),
+ /// this node value filters by notification done state for the document.
+ #[serde(rename = "nd")]
+ NotificationDone(bool),
+ /// this node value filters by notification seen state for the document.
+ #[serde(rename = "ns")]
+ NotificationSeen(bool),
+ /// include tasks that are created by me, assigned to me, and not completed.
+ #[serde(rename = "cbm")]
+ IncludeCbmAtmNc(bool),
}
fn prefix(s: &str) -> IResult<&str, &str> {
@@ -124,6 +133,8 @@ impl ExpandFrame<DocumentLiteral> for DocumentFilters {
project_ids,
owners,
importance,
+ notification_filters,
+ task_filters,
} = filter_request;
let file_types_node = file_types
@@ -148,14 +159,35 @@ impl ExpandFrame<DocumentLiteral> for DocumentFilters {
let importance_node = importance.map(|imp| Expr::Literal(DocumentLiteral::Importance(imp)));
- Ok([
+ let notification_done_node = notification_filters
+ .done
+ .map(|done| Expr::Literal(DocumentLiteral::NotificationDone(done)));
+ let notification_seen_node = notification_filters
+ .seen
+ .map(|seen| Expr::Literal(DocumentLiteral::NotificationSeen(seen)));
+
+ let normal_expr = [
file_types_node,
document_id_nodes,
project_ids,
owners,
importance_node,
+ notification_done_node,
+ notification_seen_node,
]
.into_iter()
- .fold_with(Expr::and))
+ .fold_with(Expr::and);
+
+ let include_cbm_expr = match task_filters.include_cbm_atm_nc {
+ Some(true) => Some(Expr::Literal(DocumentLiteral::IncludeCbmAtmNc(true))),
+ Some(false) | None => None,
+ };
+
+ Ok(match (normal_expr, include_cbm_expr) {
+ (Some(normal), Some(include_cbm)) => Some(Expr::or(normal, include_cbm)),
+ (Some(normal), None) => Some(normal),
+ (None, Some(include_cbm)) => Some(include_cbm),
+ (None, None) => None,
+ })
}
}
diff --git a/rust/cloud-storage/item_filters/src/ast/email.rs b/rust/cloud-storage/item_filters/src/ast/email.rs
index a8ddfe9958..d40cdd8c14 100644
--- a/rust/cloud-storage/item_filters/src/ast/email.rs
+++ b/rust/cloud-storage/item_filters/src/ast/email.rs
@@ -29,6 +29,10 @@ pub enum EmailLiteral {
ThreadId(Uuid),
/// This node value filters by email importance. false short-circuits to match nothing.
Importance(bool),
+ /// This node value filters by notification done state for emails.
+ NotificationDone(bool),
+ /// This node value filters by notification seen state for emails.
+ NotificationSeen(bool),
}
impl ExpandFrame<EmailLiteral> for EmailFilters {
@@ -41,6 +45,7 @@ impl ExpandFrame<EmailLiteral> for EmailFilters {
recipients,
email_thread_ids,
importance,
+ notification_filters,
} = input;
fn map_email(s: String) -> Email {
@@ -73,6 +78,12 @@ impl ExpandFrame<EmailLiteral> for EmailFilters {
.try_expand(|r| r.map(EmailLiteral::ThreadId), Expr::or)?;
let importance_node = importance.map(|imp| Expr::Literal(EmailLiteral::Importance(imp)));
+ let notification_done_node = notification_filters
+ .done
+ .map(|done| Expr::Literal(EmailLiteral::NotificationDone(done)));
+ let notification_seen_node = notification_filters
+ .seen
+ .map(|seen| Expr::Literal(EmailLiteral::NotificationSeen(seen)));
Ok([
sender_nodes,
@@ -81,6 +92,8 @@ impl ExpandFrame<EmailLiteral> for EmailFilters {
recipient_nodes,
thread_id_nodes,
importance_node,
+ notification_done_node,
+ notification_seen_node,
]
.into_iter()
.fold_with(Expr::and))
diff --git a/rust/cloud-storage/item_filters/src/ast/project.rs b/rust/cloud-storage/item_filters/src/ast/project.rs
index 56fd675219..b966ddf7b3 100644
--- a/rust/cloud-storage/item_filters/src/ast/project.rs
+++ b/rust/cloud-storage/item_filters/src/ast/project.rs
@@ -14,6 +14,10 @@ pub enum ProjectLiteral {
Owner(MacroUserIdStr<'static>),
/// this node value filters by project importance. false short-circuits to match nothing.
Importance(bool),
+ /// this node value filters by notification done state for projects.
+ NotificationDone(bool),
+ /// this node value filters by notification seen state for projects.
+ NotificationSeen(bool),
}
impl ExpandFrame<ProjectLiteral> for ProjectFilters {
@@ -24,6 +28,7 @@ impl ExpandFrame<ProjectLiteral> for ProjectFilters {
project_ids,
owners,
importance,
+ notification_filters,
} = input;
let project_ids = project_ids
@@ -37,9 +42,21 @@ impl ExpandFrame<ProjectLiteral> for ProjectFilters {
.try_expand(|r| r.map(ProjectLiteral::Owner), Expr::or)?;
let importance_node = importance.map(|imp| Expr::Literal(ProjectLiteral::Importance(imp)));
-
- Ok([project_ids, owners, importance_node]
- .into_iter()
- .fold_with(Expr::and))
+ let notification_done_node = notification_filters
+ .done
+ .map(|done| Expr::Literal(ProjectLiteral::NotificationDone(done)));
+ let notification_seen_node = notification_filters
+ .seen
+ .map(|seen| Expr::Literal(ProjectLiteral::NotificationSeen(seen)));
+
+ Ok([
+ project_ids,
+ owners,
+ importance_node,
+ notification_done_node,
+ notification_seen_node,
+ ]
+ .into_iter()
+ .fold_with(Expr::and))
}
}
diff --git a/rust/cloud-storage/item_filters/src/ast/tests.rs b/rust/cloud-storage/item_filters/src/ast/tests.rs
index df77eefc38..74f7fb1d61 100644
--- a/rust/cloud-storage/item_filters/src/ast/tests.rs
+++ b/rust/cloud-storage/item_filters/src/ast/tests.rs
@@ -30,6 +30,7 @@ fn it_expands_filters() {
project_ids: vec![project_id.to_string()],
owners: vec!["macro|[email protected]".to_string()],
importance: Some(true),
+ ..Default::default()
},
..Default::default()
};
@@ -108,6 +109,7 @@ fn it_expands_file_associations() {
project_ids: vec![],
owners: vec![],
importance: Some(true),
+ ..Default::default()
},
..Default::default()
};
@@ -178,6 +180,7 @@ fn it_expands_other_association() {
project_ids: vec![],
owners: vec![],
importance: Some(true),
+ ..Default::default()
},
..Default::default()
};
@@ -330,3 +333,79 @@ fn it_expands_channel_type_with_channel_id() {
// Should be AND of channel_id and channel_type
assert!(json.get("&").is_some());
}
+
+#[test]
+fn it_expands_document_notification_filters() {
+ let f = EntityFilters {
+ document_filters: DocumentFilters {
+ notification_filters: crate::NotificationFilters {
+ done: Some(false),
+ seen: Some(false),
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let ast = Arc::into_inner(
+ EntityFilterAst::new_from_filters(f)
+ .unwrap()
+ .unwrap()
+ .document_filter
+ .unwrap(),
+ )
+ .unwrap();
+
+ let json = serde_json::to_string(&ast).unwrap();
+ assert!(json.contains(r#""nd":false"#));
+ assert!(json.contains(r#""ns":false"#));
+}
+
+#[test]
+fn it_expands_document_task_include_cbm_atm_nc_as_or() {
+ let f = EntityFilters {
+ document_filters: DocumentFilters {
+ file_types: vec!["pdf".to_string()],
+ task_filters: crate::TaskFilters {
+ include_cbm_atm_nc: Some(true),
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let ast = Arc::into_inner(
+ EntityFilterAst::new_from_filters(f)
+ .unwrap()
+ .unwrap()
+ .document_filter
+ .unwrap(),
+ )
+ .unwrap();
+
+ let json = serde_json::to_value(ast).unwrap();
+ assert!(
+ json.get("|").is_some(),
+ "include flag should OR with base filters"
+ );
+ let as_text = serde_json::to_string(&json).unwrap();
+ assert!(as_text.contains(r#""cbm":true"#));
+}
+
+#[test]
+fn task_include_cbm_atm_nc_false_is_noop() {
+ let f = EntityFilters {
+ document_filters: DocumentFilters {
+ task_filters: crate::TaskFilters {
+ include_cbm_atm_nc: Some(false),
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ assert!(
+ EntityFilterAst::new_from_filters(f).unwrap().is_none(),
+ "false should be equivalent to not setting the include flag"
+ );
+}
diff --git a/rust/cloud-storage/item_filters/src/lib.rs b/rust/cloud-storage/item_filters/src/lib.rs
index 16d765b98e..7b66e52449 100644
--- a/rust/cloud-storage/item_filters/src/lib.rs
+++ b/rust/cloud-storage/item_filters/src/lib.rs
@@ -22,6 +22,45 @@ pub enum SearchOn {
NameContent,
}
+/// Notification-level filters that apply to an entity type.
+#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
+pub struct NotificationFilters {
+ /// Filter by notification done state.
+ /// None to ignore, true to include only done notifications, false to include only not-done notifications.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub done: Option<bool>,
+
+ /// Filter by notification seen state.
+ /// None to ignore, true to include only seen notifications, false to include only unseen notifications.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub seen: Option<bool>,
+}
+
+impl IsEmpty for NotificationFilters {
+ fn is_empty(&self) -> bool {
+ let NotificationFilters { done, seen } = self;
+ done.is_none() && seen.is_none()
+ }
+}
+
+/// Task-only filters nested under document filters.
+#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
+#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
+pub struct TaskFilters {
+ /// Include tasks that are created by me, assigned to me, and not completed,
+ /// even when they do not match other document filters.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub include_cbm_atm_nc: Option<bool>,
+}
+
+impl IsEmpty for TaskFilters {
+ fn is_empty(&self) -> bool {
+ // false is equivalent to "disabled" and should not affect filtering.
+ self.include_cbm_atm_nc != Some(true)
+ }
+}
+
/// The document filters used to filter down what documents you search over.
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]
@@ -46,6 +85,14 @@ pub struct DocumentFilters {
/// Filter by document importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub importance: Option<bool>,
+
+ /// Filter by document notification state.
+ #[serde(default, skip_serializing_if = "NotificationFilters::is_empty")]
+ pub notification_filters: NotificationFilters,
+
+ /// Task-specific filters that only apply to task subtype documents.
+ #[serde(default, skip_serializing_if = "TaskFilters::is_empty")]
+ pub task_filters: TaskFilters,
}
impl IsEmpty for DocumentFilters {
@@ -56,12 +103,16 @@ impl IsEmpty for DocumentFilters {
project_ids,
owners,
importance,
+ notification_filters,
+ task_filters,
} = self;
file_types.is_empty()
&& document_ids.is_empty()
&& project_ids.is_empty()
&& owners.is_empty()
&& importance.is_none()
+ && notification_filters.is_empty()
+ && task_filters.is_empty()
}
}
@@ -88,6 +139,10 @@ pub struct ChatFilters {
/// Filter by chat importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub importance: Option<bool>,
+
+ /// Filter by chat notification state.
+ #[serde(default, skip_serializing_if = "NotificationFilters::is_empty")]
+ pub notification_filters: NotificationFilters,
}
impl IsEmpty for ChatFilters {
@@ -98,12 +153,14 @@ impl IsEmpty for ChatFilters {
project_ids,
owners,
importance,
+ notification_filters,
} = self;
role.is_empty()
&& chat_ids.is_empty()
&& project_ids.is_empty()
&& owners.is_empty()
&& importance.is_none()
+ && notification_filters.is_empty()
}
}
@@ -131,6 +188,10 @@ pub struct EmailFilters {
/// Filter by email importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub importance: Option<bool>,
+
+ /// Filter by email notification state.
+ #[serde(default, skip_serializing_if = "NotificationFilters::is_empty")]
+ pub notification_filters: NotificationFilters,
}
impl IsEmpty for EmailFilters {
@@ -142,6 +203,7 @@ impl IsEmpty for EmailFilters {
recipients,
email_thread_ids,
importance,
+ notification_filters,
} = self;
senders.is_empty()
&& cc.is_empty()
@@ -149,6 +211,7 @@ impl IsEmpty for EmailFilters {
&& recipients.is_empty()
&& email_thread_ids.is_empty()
&& importance.is_none()
+ && notification_filters.is_empty()
}
}
@@ -179,6 +242,10 @@ pub struct ChannelFilters {
/// Filter by channel importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub importance: Option<bool>,
+
+ /// Filter by channel notification state.
+ #[serde(default, skip_serializing_if = "NotificationFilters::is_empty")]
+ pub notification_filters: NotificationFilters,
}
impl IsEmpty for ChannelFilters {
@@ -191,6 +258,7 @@ impl IsEmpty for ChannelFilters {
sender_ids,
channel_types,
importance,
+ notification_filters,
} = self;
thread_ids.is_empty()
&& mentions.is_empty()
@@ -199,6 +267,7 @@ impl IsEmpty for ChannelFilters {
&& sender_ids.is_empty()
&& channel_types.is_empty()
&& importance.is_none()
+ && notification_filters.is_empty()
}
}
@@ -217,6 +286,10 @@ pub struct ProjectFilters {
/// Filter by project importance. None to ignore, true to pass through (no clause), false to short-circuit and return nothing.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub importance: Option<bool>,
+
+ /// Filter by project notification state.
+ #[serde(default, skip_serializing_if = "NotificationFilters::is_empty")]
+ pub notification_filters: NotificationFilters,
}
impl IsEmpty for ProjectFilters {
@@ -225,8 +298,12 @@ impl IsEmpty for ProjectFilters {
project_ids,
owners,
importance,
+ notification_filters,
} = self;
- project_ids.is_empty() && owners.is_empty() && importance.is_none()
+ project_ids.is_empty()
+ && owners.is_empty()
+ && importance.is_none()
+ && notification_filters.is_empty()
}
}
diff --git a/rust/cloud-storage/macro_db_client/fixtures/dynamic_query_exhaustive.sql b/rust/cloud-storage/macro_db_client/fixtures/dynamic_query_exhaustive.sql
index 97e0fe81e0..ede763ac16 100644
--- a/rust/cloud-storage/macro_db_client/fixtures/dynamic_query_exhaustive.sql
+++ b/rust/cloud-storage/macro_db_client/fixtures/dynamic_query_exhaustive.sql
@@ -105,7 +105,7 @@ VALUES
('bb000007-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Doc Task Incomplete', 'macro|[email protected]',
'aa000001-ffff-ffff-ffff-ffffffffffff', 107, 'txt',
'2024-01-06 10:00:00', '2024-02-06 10:00:00', NULL),
- -- doc-task-no-status: in root, txt, user-1, task, no status, no assignee
+ -- doc-task-no-status: in root, txt, user-1, task, no status, assigned to user-1
('bb000008-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Doc Task No Status', 'macro|[email protected]',
'aa000001-ffff-ffff-ffff-ffffffffffff', 108, 'txt',
'2024-01-07 10:00:00', '2024-02-07 10:00:00', NULL),
@@ -166,7 +166,7 @@ VALUES ('bb000006-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'task'),
('bb000007-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'task'),
('bb000008-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'task');
--- Entity properties: Status for completed task
+-- Entity properties: status + assignees
INSERT INTO public."entity_properties" ("id", "entity_id", "entity_type", "property_definition_id", "values")
VALUES
-- Completed task: Status = Completed
@@ -176,8 +176,20 @@ VALUES
-- Incomplete task: Status = In Progress
(gen_random_uuid(), 'bb000007-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'TASK',
'00000001-0000-0000-0000-000000000002',
- '{"type": "SelectOption", "value": ["00000001-0000-0000-0002-000000000002"]}'::jsonb);
--- No entity_properties for doc-task-no-status (to test false case)
+ '{"type": "SelectOption", "value": ["00000001-0000-0000-0002-000000000002"]}'::jsonb),
+ -- Completed task: assigned to user-1
+ (gen_random_uuid(), 'bb000006-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'TASK',
+ '00000001-0000-0000-0000-000000000001',
+ '{"type": "EntityReference", "value": [{"entity_id": "macro|[email protected]", "entity_type": "USER"}]}'::jsonb),
+ -- Incomplete task: assigned to user-2
+ (gen_random_uuid(), 'bb000007-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'TASK',
+ '00000001-0000-0000-0000-000000000001',
+ '{"type": "EntityReference", "value": [{"entity_id": "macro|[email protected]", "entity_type": "USER"}]}'::jsonb),
+ -- No-status task: assigned to user-1 (used by include_cbm_atm_nc path)
+ (gen_random_uuid(), 'bb000008-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'TASK',
+ '00000001-0000-0000-0000-000000000001',
+ '{"type": "EntityReference", "value": [{"entity_id": "macro|[email protected]", "entity_type": "USER"}]}'::jsonb);
+-- No status property for doc-task-no-status (to test incomplete status fallback)
---------------------------------
-- USER ACCESS PERMISSIONS
@@ -232,6 +244,42 @@ VALUES
('macro|[email protected]', 'aa000003-ffff-ffff-ffff-ffffffffffff', 'project',
'2024-01-01 00:00:00', '2024-03-01 10:00:00');
+---------------------------------
+-- NOTIFICATIONS
+-- Used by inbox-style done/seen backend filters.
+---------------------------------
+
+INSERT INTO public."notification" (
+ "id",
+ "notification_event_type",
+ "event_item_id",
+ "event_item_type",
+ "service_sender",
+ "metadata",
+ "sender_id"
+)
+VALUES
+ -- Document notifications
+ ('dd000001-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'bb000001-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'document', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ ('dd000002-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'bb000002-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'document', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ -- Chat notifications
+ ('dd000003-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'cc000001-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'chat', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ ('dd000004-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'cc000005-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'chat', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ -- Project notifications
+ ('dd000005-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'aa000001-ffff-ffff-ffff-ffffffffffff', 'project', 'test', '{}'::jsonb, 'macro|[email protected]'),
+ ('dd000006-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'test', 'aa000003-ffff-ffff-ffff-ffffffffffff', 'project', 'test', '{}'::jsonb, 'macro|[email protected]');
+
+INSERT INTO public."user_notification" ("user_id", "notification_id", "created_at", "seen_at", "done")
+VALUES
+ -- not done + unread
+ ('macro|[email protected]', 'dd000001-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:00:00', NULL, false),
+ ('macro|[email protected]', 'dd000003-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:01:00', NULL, false),
+ ('macro|[email protected]', 'dd000005-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:02:00', NULL, false),
+ -- done + seen
+ ('macro|[email protected]', 'dd000002-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:03:00', '2024-03-09 11:00:00', true),
+ ('macro|[email protected]', 'dd000004-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:04:00', '2024-03-09 11:01:00', true),
+ ('macro|[email protected]', 'dd000006-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2024-03-09 10:05:00', '2024-03-09 11:02:00', true);
+
---------------------------------
-- FRECENCY RECORDS
-- doc-root-pdf and chat-root have frecency for user-1
diff --git a/rust/cloud-storage/models_search/src/chat/test.rs b/rust/cloud-storage/models_search/src/chat/test.rs
index e5aaaca15d..dfb3d03900 100644
--- a/rust/cloud-storage/models_search/src/chat/test.rs
+++ b/rust/cloud-storage/models_search/src/chat/test.rs
@@ -13,6 +13,7 @@ fn test_chat_search_request_json_serialization() {
project_ids: vec![],
owners: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
@@ -87,6 +88,7 @@ fn test_chat_search_request_round_trip() {
project_ids: vec![],
owners: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
diff --git a/rust/cloud-storage/models_search/src/document/test.rs b/rust/cloud-storage/models_search/src/document/test.rs
index 085d847110..50800ed0fd 100644
--- a/rust/cloud-storage/models_search/src/document/test.rs
+++ b/rust/cloud-storage/models_search/src/document/test.rs
@@ -13,6 +13,7 @@ fn test_document_search_request_json_serialization() {
project_ids: vec![],
owners: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
@@ -87,6 +88,7 @@ fn test_document_search_request_round_trip() {
project_ids: vec![],
owners: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
diff --git a/rust/cloud-storage/models_search/src/email/test.rs b/rust/cloud-storage/models_search/src/email/test.rs
index e52924360d..324cca41c3 100644
--- a/rust/cloud-storage/models_search/src/email/test.rs
+++ b/rust/cloud-storage/models_search/src/email/test.rs
@@ -14,6 +14,7 @@ fn test_email_search_request_json_serialization() {
recipients: vec![],
email_thread_ids: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
@@ -100,6 +101,7 @@ fn test_email_search_request_round_trip() {
recipients: vec![],
email_thread_ids: vec![],
importance: None,
+ ..Default::default()
}),
search_on: SearchOn::Content,
collapse: None,
diff --git a/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs b/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs
index 7aaed69e95..9d918595fc 100644
--- a/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs
+++ b/rust/cloud-storage/soup/src/inbound/axum_router/tests.rs
@@ -623,3 +623,79 @@ async fn it_parses_channel_filters() {
}
)
}
+
+#[tokio::test]
+async fn it_parses_notification_and_task_filters() {
+ let soup = MockSoup::new();
+ let inner_counter = soup.called.clone();
+ let router: Router = soup_router(SoupRouterState::new(
+ soup,
+ MockEmailLinkResult {
+ get_link_result: Arc::new(|| Ok(None)),
+ },
+ ))
+ .layer(Extension(UserContext {
+ user_id: "macro|[email protected]".to_string(),
+ fusion_user_id: "1234".to_string(),
+ permissions: None,
+ organization_id: None,
+ }));
+
+ let request = Request::builder()
+ .uri("/soup")
+ .method(Method::POST)
+ .header("content-type", "application/json")
+ .body(axum::body::Body::from(
+ serde_json::to_vec(&serde_json::json!({
+ "document_filters": {
+ "notification_filters": { "done": false, "seen": false },
+ "task_filters": { "include_cbm_atm_nc": true }
+ },
+ "chat_filters": {
+ "notification_filters": { "done": false, "seen": false }
+ },
+ "project_filters": {
+ "notification_filters": { "done": false, "seen": false }
+ },
+ "channel_filters": {
+ "notification_filters": { "done": false, "seen": false }
+ }
+ }))
+ .unwrap(),
+ ))
+ .unwrap();
+
+ let _res = router.oneshot(request).await.unwrap();
+
+ let arg = {
+ let mut guard = inner_counter.lock().unwrap();
+ guard.pop().unwrap()
+ };
+
+ assert_matches!(
+ arg,
+ SoupRequest {
+ cursor: SoupQuery::Simple(SimpleQueryInner(Query::Sort(
+ _,
+ EntityFilters {
+ document_filters,
+ chat_filters,
+ project_filters,
+ channel_filters,
+ ..
+ },
+ ))),
+ ..
+ } => {
+ assert_eq!(document_filters.notification_filters.done, Some(false));
+ assert_eq!(document_filters.notification_filters.seen, Some(false));
+ assert_eq!(document_filters.task_filters.include_cbm_atm_nc, Some(true));
+ assert_eq!(chat_filters.notification_filters.done, Some(false));
+ assert_eq!(chat_filters.notification_filters.seen, Some(false));
+ assert_eq!(project_filters.notification_filters.done, Some(false));
+ assert_eq!(project_filters.notification_filters.seen, Some(false));
+ assert_eq!(channel_filters.notification_filters.done, Some(false));
+ assert_eq!(channel_filters.notification_filters.seen, Some(false));
+ }
+ )
+}
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs
index 219aab564b..1da69dbfe4 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/dynamic.rs
@@ -88,6 +88,11 @@ static DOCUMENT_TOP_CLAUSE: &str = r#"
AND ep_assignees.entity_id = d.id
AND ep_assignees.entity_type = 'TASK'
AND ep_assignees.property_definition_id = $8
+ LEFT JOIN entity_properties ep_status
+ ON dt.sub_type = 'task'
+ AND ep_status.entity_id = d.id
+ AND ep_status.entity_type = 'TASK'
+ AND ep_status.property_definition_id = $7
INNER JOIN UserAccessibleItems uai ON uai.item_id = d.id AND uai.item_type = 'document'
LEFT JOIN "UserHistory" uh ON uh."itemId" = d.id AND uh."itemType" = 'document' AND uh."userId" = $1
WHERE d."deletedAt" IS NULL
@@ -252,6 +257,59 @@ static DETAIL_SUFFIX: &str = r#"
LIMIT $3
"#;
+fn build_notification_exists_clause(
+ entity_id_sql: &str,
+ entity_type: &str,
+ predicate_sql: &str,
+) -> String {
+ format!(
+ r#"EXISTS (
+ SELECT 1
+ FROM notification n
+ JOIN user_notification un ON un.notification_id = n.id
+ WHERE un.user_id = $1
+ AND un.deleted_at IS NULL
+ AND n.event_item_type = '{entity_type}'
+ AND n.event_item_id = ({entity_id_sql})::text
+ AND {predicate_sql}
+ )"#
+ )
+}
+
+fn build_notification_done_clause(entity_id_sql: &str, entity_type: &str, done: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if done {
+ "un.done = true"
+ } else {
+ "un.done = false"
+ },
+ )
+}
+
+fn build_notification_seen_clause(entity_id_sql: &str, entity_type: &str, seen: bool) -> String {
+ build_notification_exists_clause(
+ entity_id_sql,
+ entity_type,
+ if seen {
+ "un.seen_at IS NOT NULL"
+ } else {
+ "un.seen_at IS NULL"
+ },
+ )
+}
+
+fn build_task_include_cbm_atm_nc_clause() -> String {
+ r#"(
+ dt.sub_type = 'task'
+ AND d.owner = $1
+ AND ep_assignees.values->'value' @> jsonb_build_array(jsonb_build_object('entity_id', $1))
+ AND NOT COALESCE(ep_status.values->'value' ? $6, false)
+ )"#
+ .to_string()
+}
+
fn build_document_filter(ast: Option<&Expr<DocumentLiteral>>) -> String {
let Some(expr) = ast else {
return String::new();
@@ -288,6 +346,17 @@ fn build_document_filter(ast: Option<&Expr<DocumentLiteral>>) -> String {
)"#
.to_string()
}
+ filter_ast::ExprFrame::Literal(DocumentLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("d.id", "document", done)
+ }
+ filter_ast::ExprFrame::Literal(DocumentLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("d.id", "document", seen)
+ }
+ filter_ast::ExprFrame::Literal(DocumentLiteral::IncludeCbmAtmNc(true)) => {
+ build_task_include_cbm_atm_nc_clause()
+ }
+ // false is equivalent to disabled/no-op.
+ filter_ast::ExprFrame::Literal(DocumentLiteral::IncludeCbmAtmNc(false)) => String::new(),
});
if formatting.is_empty() {
String::new()
@@ -314,6 +383,12 @@ fn build_chat_filter(ast: Option<&Expr<ChatLiteral>>) -> String {
filter_ast::ExprFrame::Literal(ChatLiteral::Importance(true)) => String::new(),
// all chats are important, so if importance is false, exclude them
filter_ast::ExprFrame::Literal(ChatLiteral::Importance(false)) => "1=0".to_string(),
+ filter_ast::ExprFrame::Literal(ChatLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("c.id", "chat", done)
+ }
+ filter_ast::ExprFrame::Literal(ChatLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("c.id", "chat", seen)
+ }
});
if formatting.is_empty() {
String::new()
@@ -337,6 +412,12 @@ fn build_project_filter(ast: Option<&Expr<ProjectLiteral>>) -> String {
filter_ast::ExprFrame::Literal(ProjectLiteral::Importance(true)) => String::new(),
// all projects are important, so if importance is false, exclude them
filter_ast::ExprFrame::Literal(ProjectLiteral::Importance(false)) => "1=0".to_string(),
+ filter_ast::ExprFrame::Literal(ProjectLiteral::NotificationDone(done)) => {
+ build_notification_done_clause("p.id", "project", done)
+ }
+ filter_ast::ExprFrame::Literal(ProjectLiteral::NotificationSeen(seen)) => {
+ build_notification_seen_clause("p.id", "project", seen)
+ }
});
if formatting.is_empty() {
String::new()
diff --git a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
index f2a6b38ff5..60ee44f158 100644
--- a/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
+++ b/rust/cloud-storage/soup/src/outbound/pg_soup_repo/expanded/tests.rs
@@ -3959,6 +3959,185 @@ async fn test_dyn_filter_multiple_file_types(db: PgPool) -> anyhow::Result<()> {
Ok(())
}
+// ---- Notification + task include filters (3 tests) ----
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../../../macro_db_client/fixtures",
+ scripts("dynamic_query_exhaustive")
+ )
+)]
+async fn test_dyn_filter_notification_done_false(db: PgPool) -> anyhow::Result<()> {
+ use item_filters::{
+ ChatFilters, DocumentFilters, EntityFilters, NotificationFilters, ProjectFilters,
+ };
+
+ let entity_filters = EntityFilters {
+ document_filters: DocumentFilters {
+ notification_filters: NotificationFilters {
+ done: Some(false),
+ seen: None,
+ },
+ ..Default::default()
+ },
+ chat_filters: ChatFilters {
+ notification_filters: NotificationFilters {
+ done: Some(false),
+ seen: None,
+ },
+ ..Default::default()
+ },
+ project_filters: ProjectFilters {
+ notification_filters: NotificationFilters {
+ done: Some(false),
+ seen: None,
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let filters = EntityFilterAst::new_from_filters(entity_filters)?.unwrap();
+
+ let items = dyn_fetch(
+ &db,
+ 50,
+ SimpleSortMethod::UpdatedAt,
+ filters,
+ false,
+ )
+ .await?;
+
+ let ids: HashSet<Uuid> = items.iter().map(|i| i.id()).collect();
+ let expected: HashSet<Uuid> = [DYN_DOC_ROOT_PDF, DYN_CHAT_ROOT, DYN_PROJECT_ROOT]
+ .iter()
+ .map(|s| uuid(s))
+ .collect();
+
+ assert_eq!(
+ ids, expected,
+ "done=false should only return entities with matching not-done notifications"
+ );
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../../../macro_db_client/fixtures",
+ scripts("dynamic_query_exhaustive")
+ )
+)]
+async fn test_dyn_filter_notification_done_and_seen_false(db: PgPool) -> anyhow::Result<()> {
+ use item_filters::{
+ ChatFilters, DocumentFilters, EntityFilters, NotificationFilters, ProjectFilters,
+ };
+
+ let notification_filters = NotificationFilters {
+ done: Some(false),
+ seen: Some(false),
+ };
+ let entity_filters = EntityFilters {
+ document_filters: DocumentFilters {
+ notification_filters: notification_filters.clone(),
+ ..Default::default()
+ },
+ chat_filters: ChatFilters {
+ notification_filters: notification_filters.clone(),
+ ..Default::default()
+ },
+ project_filters: ProjectFilters {
+ notification_filters,
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let filters = EntityFilterAst::new_from_filters(entity_filters)?.unwrap();
+
+ let items = dyn_fetch(
+ &db,
+ 50,
+ SimpleSortMethod::UpdatedAt,
+ filters,
+ false,
+ )
+ .await?;
+
+ let ids: HashSet<Uuid> = items.iter().map(|i| i.id()).collect();
+ let expected: HashSet<Uuid> = [DYN_DOC_ROOT_PDF, DYN_CHAT_ROOT, DYN_PROJECT_ROOT]
+ .iter()
+ .map(|s| uuid(s))
+ .collect();
+
+ assert_eq!(
+ ids, expected,
+ "done=false + seen=false should require both constraints on notifications"
+ );
+
+ Ok(())
+}
+
+#[sqlx::test(
+ migrator = "MACRO_DB_MIGRATIONS",
+ fixtures(
+ path = "../../../../../macro_db_client/fixtures",
+ scripts("dynamic_query_exhaustive")
+ )
+)]
+async fn test_dyn_task_include_cbm_atm_nc_bypasses_document_filters(
+ db: PgPool,
+) -> anyhow::Result<()> {
+ use item_filters::{DocumentFilters, EntityFilters, TaskFilters};
+
+ let entity_filters = EntityFilters {
+ document_filters: DocumentFilters {
+ file_types: vec!["pdf".to_string()],
+ task_filters: TaskFilters {
+ include_cbm_atm_nc: Some(true),
+ },
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let filters = EntityFilterAst::new_from_filters(entity_filters)?.unwrap();
+
+ let items = dyn_fetch(
+ &db,
+ 50,
+ SimpleSortMethod::UpdatedAt,
+ filters,
+ false,
+ )
+ .await?;
+
+ let doc_ids: HashSet<Uuid> = items
+ .iter()
+ .filter_map(|i| match i {
+ SoupItem::Document(d) => Some(d.id),
+ _ => None,
+ })
+ .collect();
+
+ let expected_docs: HashSet<Uuid> = [DYN_DOC_ROOT_PDF, DYN_DOC_DEEP_PDF, DYN_DOC_TASK_NO_STATUS]
+ .iter()
+ .map(|s| uuid(s))
+ .collect();
+
+ assert_eq!(
+ doc_ids, expected_docs,
+ "include_cbm_atm_nc should OR in matching assigned not-completed tasks"
+ );
+
+ Ok(())
+}
+
// ---- Task completion & document fields (2 tests) ----
/// 11. Task documents should have correct is_completed values.