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.

chore(soup/email): Remove metadata field from email threads (#1345)

Evan Hutnik6b1f684af364
diff --git a/js/app/packages/app/component/settings/Inbox.tsx b/js/app/packages/app/component/settings/Inbox.tsx
index 6fa45ca08f..685a5b5459 100644
--- a/js/app/packages/app/component/settings/Inbox.tsx
+++ b/js/app/packages/app/component/settings/Inbox.tsx
@@ -2,20 +2,12 @@ import { ToggleSwitch } from '@core/component/FormControls/ToggleSwitch';
import { For } from 'solid-js';
import {
DEPRIORITY_LABEL_SIGNAL_TOGGLES,
- DEPRIORITY_METADATA_SIGNAL_TOGGLES,
PRIORITY_LABEL_SIGNAL_TOGGLES,
- PRIORITY_METADATA_SIGNAL_TOGGLES,
} from '../soupFilters';
export function Inbox() {
- const prioritySignals = [
- ...PRIORITY_LABEL_SIGNAL_TOGGLES,
- ...PRIORITY_METADATA_SIGNAL_TOGGLES,
- ];
- const deprioritySignals = [
- ...DEPRIORITY_LABEL_SIGNAL_TOGGLES,
- ...DEPRIORITY_METADATA_SIGNAL_TOGGLES,
- ];
+ const prioritySignals = [...PRIORITY_LABEL_SIGNAL_TOGGLES];
+ const deprioritySignals = [...DEPRIORITY_LABEL_SIGNAL_TOGGLES];
return (
<div class="font-mono flex flex-col gap-3 text-sm p-2">
diff --git a/js/app/packages/app/component/soupFilters.ts b/js/app/packages/app/component/soupFilters.ts
index 1e2fb7d33a..3e38e59203 100644
--- a/js/app/packages/app/component/soupFilters.ts
+++ b/js/app/packages/app/component/soupFilters.ts
@@ -4,8 +4,6 @@ import {
isTaskEntity,
type TaskEntityWithProperties,
} from '@macro-entity';
-import type { APIEmailThreadPreviewMetadata } from '@service-email/generated/schemas';
-import type { SoupEmailThreadPreviewMetadata } from '@service-storage/generated/schemas';
import { makePersisted } from '@solid-primitives/storage';
import { createMemo, createSignal } from 'solid-js';
import { isSignalTask } from './Soup/utils/filterHelpers';
@@ -58,16 +56,6 @@ const PRIORITY_LABEL_SIGNAL_CONFIGS: SignalConfig<string>[] = [
},
];
-const PRIORITY_METADATA_SIGNAL_CONFIGS: SignalConfig<
- keyof SoupEmailThreadPreviewMetadata
->[] = [
- {
- key: 'knownSender',
- label: 'Known Sender',
- defaultValue: false,
- },
-];
-
const DEPRIORITY_LABEL_SIGNAL_CONFIGS: SignalConfig<string>[] = [
{
key: 'CATEGORY_UPDATES',
@@ -91,37 +79,14 @@ const DEPRIORITY_LABEL_SIGNAL_CONFIGS: SignalConfig<string>[] = [
},
];
-const DEPRIORITY_METADATA_SIGNAL_CONFIGS: SignalConfig<
- keyof SoupEmailThreadPreviewMetadata
->[] = [
- {
- key: 'tabular',
- label: 'Tabular',
- defaultValue: false,
- },
- {
- key: 'genericSender',
- label: 'Generic Sender',
- defaultValue: false,
- },
-];
-
export const PRIORITY_LABEL_SIGNAL_TOGGLES = createSignalToggles(
'priority_label',
PRIORITY_LABEL_SIGNAL_CONFIGS
);
-export const PRIORITY_METADATA_SIGNAL_TOGGLES = createSignalToggles(
- 'priority_metadata',
- PRIORITY_METADATA_SIGNAL_CONFIGS
-);
export const DEPRIORITY_LABEL_SIGNAL_TOGGLES = createSignalToggles(
'depriority_label',
DEPRIORITY_LABEL_SIGNAL_CONFIGS
);
-export const DEPRIORITY_METADATA_SIGNAL_TOGGLES = createSignalToggles(
- 'depriority_metadata',
- DEPRIORITY_METADATA_SIGNAL_CONFIGS
-);
// Computed Sets based on persisted settings
const SIGNAL_PRIORITY_LABELS = createMemo(
@@ -142,24 +107,6 @@ const SIGNAL_DEPRIORITY_LABELS = createMemo(
)
);
-const SIGNAL_PRIORITY_METADATA = createMemo(
- () =>
- new Set<keyof SoupEmailThreadPreviewMetadata>(
- PRIORITY_METADATA_SIGNAL_TOGGLES.filter(({ enabled }) => enabled()).map(
- ({ key }) => key
- )
- )
-);
-
-const SIGNAL_DEPRIORITY_METADATA = createMemo(
- () =>
- new Set<keyof SoupEmailThreadPreviewMetadata>(
- DEPRIORITY_METADATA_SIGNAL_TOGGLES.filter(({ enabled }) => enabled()).map(
- ({ key }) => key
- )
- )
-);
-
const getLabelTokens = (
labels?: Array<{ id?: string; providerLabelId?: string; name?: string }>
): string[] => {
@@ -175,38 +122,10 @@ const getLabelTokens = (
return tokens.map((token) => token.toUpperCase());
};
-// Helper to safely check metadata properties that may use different naming conventions. We can removed this when we're no longer using Email query, and only Soup query.
-const getMetadataValue = (
- metadata:
- | SoupEmailThreadPreviewMetadata
- | APIEmailThreadPreviewMetadata
- | undefined,
- key: keyof SoupEmailThreadPreviewMetadata
-): boolean | undefined => {
- if (!metadata) return undefined;
-
- // Check SoupEmailThreadPreviewMetadata format (camelCase)
- if (key in metadata) {
- return (metadata as SoupEmailThreadPreviewMetadata)[key];
- }
-
- // Check APIEmailThreadPreviewMetadata format (snake_case)
- const snakeCaseKey = key
- .replace(/([A-Z])/g, '_$1')
- .toLowerCase() as keyof APIEmailThreadPreviewMetadata;
- if (snakeCaseKey in metadata) {
- return (metadata as APIEmailThreadPreviewMetadata)[snakeCaseKey];
- }
-
- return undefined;
-};
-
const getEmailSignalInfo = (entity: Extract<EntityData, { type: 'email' }>) => {
const labelTokens = getLabelTokens(entity.labels);
const priorityLabels = SIGNAL_PRIORITY_LABELS();
const depriorityLabels = SIGNAL_DEPRIORITY_LABELS();
- const priorityMetadata = SIGNAL_PRIORITY_METADATA();
- const depriorityMetadata = SIGNAL_DEPRIORITY_METADATA();
const hasPriorityLabel = labelTokens.some((label) =>
priorityLabels.has(label)
@@ -215,20 +134,9 @@ const getEmailSignalInfo = (entity: Extract<EntityData, { type: 'email' }>) => {
depriorityLabels.has(label)
);
- const hasPriorityMetadata = entity.metadata
- ? Array.from(priorityMetadata).some(
- (key) => getMetadataValue(entity.metadata, key) === true
- )
- : false;
- const hasDeprioritizingMetadata = entity.metadata
- ? Array.from(depriorityMetadata).some(
- (key) => getMetadataValue(entity.metadata, key) === true
- )
- : false;
-
return {
- hasPriority: hasPriorityMetadata || hasPriorityLabel,
- hasDepriority: hasDeprioritizingLabel || hasDeprioritizingMetadata,
+ hasPriority: hasPriorityLabel,
+ hasDepriority: hasDeprioritizingLabel,
};
};
diff --git a/js/app/packages/macro-entity/src/types/entity.ts b/js/app/packages/macro-entity/src/types/entity.ts
index 993c7f2a73..4cb98721da 100644
--- a/js/app/packages/macro-entity/src/types/entity.ts
+++ b/js/app/packages/macro-entity/src/types/entity.ts
@@ -1,10 +1,6 @@
import { isEntityType } from '@core/types/utils';
+import type { ApiLabel } from '@service-email/generated/schemas';
import type {
- APIEmailThreadPreviewMetadata,
- ApiLabel,
-} from '@service-email/generated/schemas';
-import type {
- SoupEmailThreadPreviewMetadata,
SoupLabel,
SoupProperty,
} from '@service-storage/generated/schemas';
@@ -85,7 +81,6 @@ export type EmailEntity = EntityBase & {
senderEmail?: string;
senderName?: string;
labels?: SoupLabel[] | ApiLabel[];
- metadata?: SoupEmailThreadPreviewMetadata | APIEmailThreadPreviewMetadata;
};
export type ProjectEntity = EntityBase & {
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/aPIEmailThreadPreviewMetadata.ts b/js/app/packages/service-clients/service-email/generated/schemas/aPIEmailThreadPreviewMetadata.ts
deleted file mode 100644
index 95e8095c47..0000000000
--- a/js/app/packages/service-clients/service-email/generated/schemas/aPIEmailThreadPreviewMetadata.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * email_service
- * OpenAPI spec version: 0.1.0
- */
-
-export interface APIEmailThreadPreviewMetadata {
- /** if any email contains a calendar invite */
- calendar_invite: boolean;
- /** if any sender in the thread is a generic email */
- generic_sender: boolean;
- /** if user has previously emailed any sender in the thread */
- known_sender: boolean;
- /** if any email contains a <table> html tag */
- tabular: boolean;
-}
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/apiThreadPreviewCursorAllOf.ts b/js/app/packages/service-clients/service-email/generated/schemas/apiThreadPreviewCursorAllOf.ts
index 28b6f558c4..b8caeb7363 100644
--- a/js/app/packages/service-clients/service-email/generated/schemas/apiThreadPreviewCursorAllOf.ts
+++ b/js/app/packages/service-clients/service-email/generated/schemas/apiThreadPreviewCursorAllOf.ts
@@ -4,8 +4,6 @@
* email_service
* OpenAPI spec version: 0.1.0
*/
-
-import type { APIEmailThreadPreviewMetadata } from './aPIEmailThreadPreviewMetadata';
import type { ApiAttachment } from './apiAttachment';
import type { ApiContact } from './apiContact';
import type { ApiLabel } from './apiLabel';
@@ -16,5 +14,4 @@ export type ApiThreadPreviewCursorAllOf = {
contacts: ApiContact[];
frecencyScore?: ApiThreadPreviewCursorAllOfFrecencyScore;
labels: ApiLabel[];
- metadata: APIEmailThreadPreviewMetadata;
};
diff --git a/js/app/packages/service-clients/service-email/generated/schemas/index.ts b/js/app/packages/service-clients/service-email/generated/schemas/index.ts
index 5357897a4b..8d91b1a030 100644
--- a/js/app/packages/service-clients/service-email/generated/schemas/index.ts
+++ b/js/app/packages/service-clients/service-email/generated/schemas/index.ts
@@ -8,7 +8,6 @@
export * from './accessLevel';
export * from './addDraftAttachmentRequest';
export * from './addDraftAttachmentResponse';
-export * from './aPIEmailThreadPreviewMetadata';
export * from './aPIThread';
export * from './aPIThreadLatestInboundMessageTs';
export * from './aPIThreadLatestNonSpamMessageTs';
diff --git a/js/app/packages/service-clients/service-email/openapi.json b/js/app/packages/service-clients/service-email/openapi.json
index fc6a74e4cf..1844f4cfc7 100644
--- a/js/app/packages/service-clients/service-email/openapi.json
+++ b/js/app/packages/service-clients/service-email/openapi.json
@@ -1972,33 +1972,6 @@
},
"components": {
"schemas": {
- "APIEmailThreadPreviewMetadata": {
- "type": "object",
- "required": [
- "known_sender",
- "tabular",
- "calendar_invite",
- "generic_sender"
- ],
- "properties": {
- "calendar_invite": {
- "type": "boolean",
- "description": "if any email contains a calendar invite"
- },
- "generic_sender": {
- "type": "boolean",
- "description": "if any sender in the thread is a generic email"
- },
- "known_sender": {
- "type": "boolean",
- "description": "if user has previously emailed any sender in the thread"
- },
- "tabular": {
- "type": "boolean",
- "description": "if any email contains a <table> html tag"
- }
- }
- },
"APIThread": {
"type": "object",
"description": "Thread object exposed to the FE in Get Threads Call",
@@ -2243,7 +2216,7 @@
},
{
"type": "object",
- "required": ["attachments", "contacts", "labels", "metadata"],
+ "required": ["attachments", "contacts", "labels"],
"properties": {
"attachments": {
"type": "array",
@@ -2266,9 +2239,6 @@
"items": {
"$ref": "#/components/schemas/ApiLabel"
}
- },
- "metadata": {
- "$ref": "#/components/schemas/APIEmailThreadPreviewMetadata"
}
}
}
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 36d47edaf2..a3f3377ddc 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
@@ -482,7 +482,6 @@ export * from './soupDocumentSubTypeOneOfType';
export * from './soupDocumentSubTypeProperty';
export * from './soupDocumentViewedAt';
export * from './soupEmailThreadPreview';
-export * from './soupEmailThreadPreviewMetadata';
export * from './soupEmailThreadPreviewName';
export * from './soupEmailThreadPreviewProviderId';
export * from './soupEmailThreadPreviewSenderEmail';
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts
deleted file mode 100644
index 0724efbcad..0000000000
--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * document_storage_service
- * OpenAPI spec version: 0.1.0
- */
-
-export interface SoupEmailThreadPreviewMetadata {
- /** if any email contains a calendar invite */
- calendarInvite: boolean;
- /** if any sender is a generic email */
- genericSender: boolean;
- /** if user has previously emailed any sender */
- knownSender: boolean;
- /** if any email contains a <table> html tag */
- tabular: boolean;
-}
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts b/js/app/packages/service-clients/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts
index b5f15b3060..6b5dff2b04 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/soupEnrichedEmailThreadPreviewAllOf.ts
@@ -6,14 +6,12 @@
*/
import type { SoupAttachment } from './soupAttachment';
import type { SoupContact } from './soupContact';
-import type { SoupEmailThreadPreviewMetadata } from './soupEmailThreadPreviewMetadata';
import type { SoupLabel } from './soupLabel';
import type { SoupProperty } from './soupProperty';
export type SoupEnrichedEmailThreadPreviewAllOf = {
attachments: SoupAttachment[];
labels: SoupLabel[];
- metadata: SoupEmailThreadPreviewMetadata;
participants: SoupContact[];
properties: SoupProperty[];
};
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 51cba70cf5..eff1ae37b4 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -3183,20 +3183,6 @@ export const getItemsSoupResponse = zod.object({
type: zod.enum(['system', 'user']),
})
),
- metadata: zod.object({
- calendarInvite: zod
- .boolean()
- .describe('if any email contains a calendar invite'),
- genericSender: zod
- .boolean()
- .describe('if any sender is a generic email'),
- knownSender: zod
- .boolean()
- .describe('if user has previously emailed any sender'),
- tabular: zod
- .boolean()
- .describe('if any email contains a <table> html tag'),
- }),
participants: zod.array(
zod.object({
emailAddress: zod.string().nullish(),
@@ -4602,20 +4588,6 @@ export const postItemsSoupResponse = zod.object({
type: zod.enum(['system', 'user']),
})
),
- metadata: zod.object({
- calendarInvite: zod
- .boolean()
- .describe('if any email contains a calendar invite'),
- genericSender: zod
- .boolean()
- .describe('if any sender is a generic email'),
- knownSender: zod
- .boolean()
- .describe('if user has previously emailed any sender'),
- tabular: zod
- .boolean()
- .describe('if any email contains a <table> html tag'),
- }),
participants: zod.array(
zod.object({
emailAddress: zod.string().nullish(),
diff --git a/js/app/packages/service-clients/service-storage/openapi.json b/js/app/packages/service-clients/service-storage/openapi.json
index 82f49d29bd..88d692149b 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -8606,33 +8606,6 @@
}
}
},
- "SoupEmailThreadPreviewMetadata": {
- "type": "object",
- "required": [
- "knownSender",
- "tabular",
- "calendarInvite",
- "genericSender"
- ],
- "properties": {
- "calendarInvite": {
- "type": "boolean",
- "description": "if any email contains a calendar invite"
- },
- "genericSender": {
- "type": "boolean",
- "description": "if any sender is a generic email"
- },
- "knownSender": {
- "type": "boolean",
- "description": "if user has previously emailed any sender"
- },
- "tabular": {
- "type": "boolean",
- "description": "if any email contains a <table> html tag"
- }
- }
- },
"SoupEnrichedEmailThreadPreview": {
"allOf": [
{
@@ -8640,13 +8613,7 @@
},
{
"type": "object",
- "required": [
- "attachments",
- "participants",
- "metadata",
- "labels",
- "properties"
- ],
+ "required": ["attachments", "participants", "labels", "properties"],
"properties": {
"attachments": {
"type": "array",
@@ -8660,9 +8627,6 @@
"$ref": "#/components/schemas/SoupLabel"
}
},
- "metadata": {
- "$ref": "#/components/schemas/SoupEmailThreadPreviewMetadata"
- },
"participants": {
"type": "array",
"items": {
diff --git a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts b/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts
deleted file mode 100644
index 0724efbcad..0000000000
--- a/js/app/packages/service-storage/generated/schemas/soupEmailThreadPreviewMetadata.ts
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Generated by orval v7.13.0 🍺
- * Do not edit manually.
- * document_storage_service
- * OpenAPI spec version: 0.1.0
- */
-
-export interface SoupEmailThreadPreviewMetadata {
- /** if any email contains a calendar invite */
- calendarInvite: boolean;
- /** if any sender is a generic email */
- genericSender: boolean;
- /** if user has previously emailed any sender */
- knownSender: boolean;
- /** if any email contains a <table> html tag */
- tabular: boolean;
-}
diff --git a/rust/cloud-storage/document_storage_service/src/api/swagger.rs b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
index e86ca46165..718cf6a682 100644
--- a/rust/cloud-storage/document_storage_service/src/api/swagger.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/swagger.rs
@@ -103,9 +103,8 @@ use models_permissions::share_permission::channel_share_permission::UpdateOperat
use models_soup::chat::SoupChat;
use models_soup::document::SoupDocument;
use models_soup::email_thread::{
- SoupAttachment, SoupContact, SoupEmailThreadPreview, SoupEmailThreadPreviewMetadata,
- SoupEnrichedEmailThreadPreview, SoupLabel, SoupLabelListVisibility, SoupLabelType,
- SoupMessageListVisibility,
+ SoupAttachment, SoupContact, SoupEmailThreadPreview, SoupEnrichedEmailThreadPreview, SoupLabel,
+ SoupLabelListVisibility, SoupLabelType, SoupMessageListVisibility,
};
use models_soup::item::SoupItem;
use models_soup::project::SoupProject;
@@ -291,7 +290,6 @@ use utoipa::OpenApi;
SoupEmailThreadPreview,
SoupAttachment,
SoupContact,
- SoupEmailThreadPreviewMetadata,
SoupLabel,
SoupLabelListVisibility,
SoupMessageListVisibility,
diff --git a/rust/cloud-storage/email/fixtures/email_thread_metadata.sql b/rust/cloud-storage/email/fixtures/email_thread_metadata.sql
deleted file mode 100644
index 93c3bdf3eb..0000000000
--- a/rust/cloud-storage/email/fixtures/email_thread_metadata.sql
+++ /dev/null
@@ -1,28 +0,0 @@
--- Link
-INSERT INTO public.email_links (id, macro_id, fusionauth_user_id, email_address, provider)
-VALUES ('00000000-0000-0000-0000-000000000001', 'user_1', 'fa_user_1', '[email protected]', 'GMAIL');
-
--- Contacts
-INSERT INTO public.email_contacts (id, link_id, email_address, name) VALUES
- ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Sender One'),
- ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Sender Two');
-
--- Thread 1: Has table HTML, single sender, NO calendar invite
-INSERT INTO public.email_threads (id, link_id) VALUES ('11111111-1111-1111-1111-111111111111', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, body_html_sanitized) VALUES
- ('10000000-0000-0000-0000-000000000001', '11111111-1111-1111-1111-111111111111', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '<div><table><tr><td>Data</td></tr></table></div>');
-
--- Thread 2: No table, HAS calendar invite, multiple senders
-INSERT INTO public.email_threads (id, link_id) VALUES ('22222222-2222-2222-2222-222222222222', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, body_html_sanitized) VALUES
- ('20000000-0000-0000-0000-000000000001', '22222222-2222-2222-2222-222222222222', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '<p>Here is the invite</p>'),
- ('20000000-0000-0000-0000-000000000002', '22222222-2222-2222-2222-222222222222', '00000000-0000-0000-0000-000000000001', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '<p>Thanks</p>');
-
-INSERT INTO public.email_attachments (id, message_id, mime_type, filename) VALUES
- ('20000000-0000-0000-0000-00000000000a', '20000000-0000-0000-0000-000000000001', 'application/ics', 'invite.ics');
-
--- Thread 3: Duplicate sender test (same contact sends multiple messages), plain text
-INSERT INTO public.email_threads (id, link_id) VALUES ('33333333-3333-3333-3333-333333333333', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, body_html_sanitized) VALUES
- ('30000000-0000-0000-0000-000000000001', '33333333-3333-3333-3333-333333333333', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Message 1'),
- ('30000000-0000-0000-0000-000000000002', '33333333-3333-3333-3333-333333333333', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'Message 2');
\ No newline at end of file
diff --git a/rust/cloud-storage/email/fixtures/threads_with_known_senders.sql b/rust/cloud-storage/email/fixtures/threads_with_known_senders.sql
deleted file mode 100644
index 4087dd8428..0000000000
--- a/rust/cloud-storage/email/fixtures/threads_with_known_senders.sql
+++ /dev/null
@@ -1,53 +0,0 @@
--- Link (The User)
-INSERT INTO public.email_links (id, macro_id, fusionauth_user_id, email_address, provider)
-VALUES ('00000000-0000-0000-0000-000000000001', 'user_1', 'fa_user_1', '[email protected]', 'GMAIL');
-
--- Contacts
-INSERT INTO public.email_contacts (id, link_id, email_address, name) VALUES
- ('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Known Contact A'),
- ('bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Unknown Contact B'),
- ('cccccccc-cccc-cccc-cccc-cccccccccccc', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Known Contact C'),
- ('55555555-5555-5555-5555-555555555555', '00000000-0000-0000-0000-000000000001', '[email protected]', 'Me');
-
--- Establish "Known" contacts logic:
--- The query looks for contacts the user has SENT emails TO.
-
--- 1. User sent email to Contact A (making A "known")
-INSERT INTO public.email_threads (id, link_id) VALUES ('99999999-9999-9999-9999-999999999991', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, is_sent, from_contact_id) VALUES
- ('90000000-0000-0000-0000-000000000001', '99999999-9999-9999-9999-999999999991', '00000000-0000-0000-0000-000000000001', true, '55555555-5555-5555-5555-555555555555');
-
-INSERT INTO public.email_message_recipients (message_id, contact_id, recipient_type) VALUES
- ('90000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', 'TO');
-
--- 2. User sent email to Contact C (making C "known")
-INSERT INTO public.email_threads (id, link_id) VALUES ('99999999-9999-9999-9999-999999999992', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, is_sent, from_contact_id) VALUES
- ('90000000-0000-0000-0000-000000000002', '99999999-9999-9999-9999-999999999992', '00000000-0000-0000-0000-000000000001', true, '55555555-5555-5555-5555-555555555555');
-
-INSERT INTO public.email_message_recipients (message_id, contact_id, recipient_type) VALUES
- ('90000000-0000-0000-0000-000000000002', 'cccccccc-cccc-cccc-cccc-cccccccccccc', 'TO');
-
-
--- Test Threads to Query Against
-
--- Thread 1: Incoming message from Contact A (Known) -> Should Match
-INSERT INTO public.email_threads (id, link_id) VALUES ('11111111-1111-1111-1111-111111111111', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, is_sent) VALUES
- ('10000000-0000-0000-0000-000000000001', '11111111-1111-1111-1111-111111111111', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', false);
-
--- Thread 2: Incoming message from Contact B (Unknown) -> Should NOT Match
-INSERT INTO public.email_threads (id, link_id) VALUES ('22222222-2222-2222-2222-222222222222', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, is_sent) VALUES
- ('20000000-0000-0000-0000-000000000001', '22222222-2222-2222-2222-222222222222', '00000000-0000-0000-0000-000000000001', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', false);
-
--- Thread 3: Incoming message from Contact C (Known) -> Should Match
-INSERT INTO public.email_threads (id, link_id) VALUES ('33333333-3333-3333-3333-333333333333', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, is_sent) VALUES
- ('30000000-0000-0000-0000-000000000001', '33333333-3333-3333-3333-333333333333', '00000000-0000-0000-0000-000000000001', 'cccccccc-cccc-cccc-cccc-cccccccccccc', false);
-
--- Thread 4: Mixed Thread. Contact B (Unknown) + Contact A (Known) -> Should Match (because A is there)
-INSERT INTO public.email_threads (id, link_id) VALUES ('44444444-4444-4444-4444-444444444444', '00000000-0000-0000-0000-000000000001');
-INSERT INTO public.email_messages (id, thread_id, link_id, from_contact_id, created_at) VALUES
- ('40000000-0000-0000-0000-000000000001', '44444444-4444-4444-4444-444444444444', '00000000-0000-0000-0000-000000000001', 'bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb', '2023-01-01 10:00:00Z'), -- Unknown B
- ('40000000-0000-0000-0000-000000000002', '44444444-4444-4444-4444-444444444444', '00000000-0000-0000-0000-000000000001', 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', '2023-01-01 11:00:00Z'); -- Known A
\ No newline at end of file
diff --git a/rust/cloud-storage/email/src/domain/models.rs b/rust/cloud-storage/email/src/domain/models.rs
index 99e7cecd64..91881e0b35 100644
--- a/rust/cloud-storage/email/src/domain/models.rs
+++ b/rust/cloud-storage/email/src/domain/models.rs
@@ -94,7 +94,6 @@ pub struct EnrichedEmailThreadPreview {
pub thread: EmailThreadPreview,
pub attachments: Vec<Attachment>,
pub labels: Vec<Label>,
- pub metadata: EmailThreadPreviewMetadata,
pub frecency_score: Option<AggregateFrecency>,
pub participants: Vec<Contact>,
}
@@ -129,19 +128,6 @@ impl SortOn<SimpleSortMethod> for EnrichedEmailThreadPreview {
}
}
-/// derived metadata for the email thread that the FE uses for filtering
-#[derive(Debug, Clone, Default)]
-pub struct EmailThreadPreviewMetadata {
- /// if user has previously emailed any sender
- pub known_sender: bool,
- /// if any email contains a <table> html tag
- pub tabular: bool,
- /// if any email contains a calendar invite
- pub calendar_invite: bool,
- /// if any sender is a generic email
- pub generic_sender: bool,
-}
-
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct Attachment {
@@ -250,12 +236,3 @@ pub struct Link {
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
-
-/// thread values needed to build thread preview metadata
-#[derive(Debug)]
-pub struct IntermediateThreadMetadata {
- pub thread_id: Uuid,
- pub has_table: bool,
- pub has_calendar_invite: bool,
- pub sender_emails: Vec<String>,
-}
diff --git a/rust/cloud-storage/email/src/domain/ports.rs b/rust/cloud-storage/email/src/domain/ports.rs
index 47331be22b..492904ed7f 100644
--- a/rust/cloud-storage/email/src/domain/ports.rs
+++ b/rust/cloud-storage/email/src/domain/ports.rs
@@ -1,6 +1,6 @@
use crate::domain::models::{
Attachment, Contact, EmailErr, EmailThreadPreview, EnrichedEmailThreadPreview,
- GetEmailsRequest, IntermediateThreadMetadata, Label, Link, PreviewCursorQuery, UserProvider,
+ GetEmailsRequest, Label, Link, PreviewCursorQuery, UserProvider,
};
use macro_user_id::user_id::MacroUserIdStr;
use models_pagination::{PaginatedCursor, SimpleSortMethod};
@@ -35,15 +35,6 @@ pub trait EmailRepo: Send + Sync + 'static {
macro_id: MacroUserIdStr<'_>,
provider: UserProvider,
) -> impl Future<Output = Result<Option<Link>, Self::Err>> + Send;
- fn threads_with_known_senders(
- &self,
- link_id: &Uuid,
- thread_ids: &[Uuid],
- ) -> impl Future<Output = Result<Vec<Uuid>, Self::Err>> + Send;
- fn thread_metadata_by_thread_ids(
- &self,
- thread_ids: &[Uuid],
- ) -> impl Future<Output = Result<Vec<IntermediateThreadMetadata>, Self::Err>> + Send;
}
pub trait EmailService: Send + Sync + 'static {
diff --git a/rust/cloud-storage/email/src/domain/service.rs b/rust/cloud-storage/email/src/domain/service.rs
index b72af67936..f2a1fd2108 100644
--- a/rust/cloud-storage/email/src/domain/service.rs
+++ b/rust/cloud-storage/email/src/domain/service.rs
@@ -1,5 +1,3 @@
-mod preview_metadata;
-
use crate::domain::{
models::{
EmailErr, EnrichedEmailThreadPreview, GetEmailsRequest, PreviewCursorQuery, UserProvider,
@@ -85,17 +83,10 @@ where
ids: ids.as_slice(),
};
- let (
- attachment_map_result,
- participant_result,
- labels_result,
- metadata_result,
- frecency_scores,
- ) = tokio::join!(
+ let (attachment_map_result, participant_result, labels_result, frecency_scores) = tokio::join!(
self.email_repo.attachments_by_thread_ids(&thread_ids),
self.email_repo.contacts_by_thread_ids(&thread_ids),
self.email_repo.labels_by_thread_ids(&thread_ids),
- self.get_preview_metadata(&previews, &link_id),
self.frecency_service
.get_frecencies_by_ids(frecency_request)
);
@@ -112,7 +103,6 @@ where
.map_err(anyhow::Error::from)?
.into_iter()
.group_by(|v| v.thread_id);
- let mut metadata_map = metadata_result.map_err(anyhow::Error::from)?;
let mut frecency_scores_map: HashMap<AggregateId<'static>, FrecencyData> =
frecency_scores?.into_inner();
@@ -129,7 +119,6 @@ where
attachments: attachment_map.remove(&thread.id).unwrap_or_default(),
labels: labels_map.remove(&thread.id).unwrap_or_default(),
participants: participant_map.remove(&thread.id).unwrap_or_default(),
- metadata: metadata_map.remove(&thread.id).unwrap_or_default(),
frecency_score: frecency_scores_map
.remove(&id)
.map(|data| id.into_aggregate(data)),
diff --git a/rust/cloud-storage/email/src/domain/service/preview_metadata.rs b/rust/cloud-storage/email/src/domain/service/preview_metadata.rs
deleted file mode 100644
index 315aed8832..0000000000
--- a/rust/cloud-storage/email/src/domain/service/preview_metadata.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-use crate::domain::models::{
- EmailThreadPreview, EmailThreadPreviewMetadata, IntermediateThreadMetadata,
-};
-use crate::domain::ports::EmailRepo;
-use crate::domain::service::EmailServiceImpl;
-use frecency::domain::ports::FrecencyQueryService;
-use std::collections::HashMap;
-use uuid::Uuid;
-
-impl<T, U> EmailServiceImpl<T, U>
-where
- T: EmailRepo,
- U: FrecencyQueryService,
-{
- /// get metadata for thread previews, used by FE for filtering Important vs Other threads
- pub async fn get_preview_metadata(
- &self,
- previews: &[EmailThreadPreview],
- link_id: &Uuid,
- ) -> Result<HashMap<Uuid, EmailThreadPreviewMetadata>, T::Err> {
- let thread_ids: Vec<Uuid> = previews.iter().map(|p| p.id).collect();
-
- let (known_senders_threads, thread_metadata) = tokio::join!(
- self.email_repo
- .threads_with_known_senders(link_id, &thread_ids),
- self.email_repo.thread_metadata_by_thread_ids(&thread_ids)
- );
-
- let known_senders_threads = known_senders_threads?;
- let thread_metadata = thread_metadata?;
-
- let metadata_map_by_thread: HashMap<Uuid, &IntermediateThreadMetadata> =
- thread_metadata.iter().map(|m| (m.thread_id, m)).collect();
-
- let metadata_map: HashMap<Uuid, EmailThreadPreviewMetadata> = thread_ids
- .into_iter()
- .map(|id| {
- let metadata = metadata_map_by_thread.get(&id);
- let generic_sender = metadata
- .map(|m| {
- m.sender_emails
- .iter()
- .any(|e| email_utils::is_generic_email(e))
- })
- .unwrap_or(false);
-
- (
- id,
- EmailThreadPreviewMetadata {
- known_sender: known_senders_threads.contains(&id),
- tabular: metadata.map(|m| m.has_table).unwrap_or(false),
- calendar_invite: metadata.map(|m| m.has_calendar_invite).unwrap_or(false),
- generic_sender,
- },
- )
- })
- .collect();
-
- Ok(metadata_map)
- }
-}
diff --git a/rust/cloud-storage/email/src/inbound/axum/api_types.rs b/rust/cloud-storage/email/src/inbound/axum/api_types.rs
index 0491339890..c865a8474e 100644
--- a/rust/cloud-storage/email/src/inbound/axum/api_types.rs
+++ b/rust/cloud-storage/email/src/inbound/axum/api_types.rs
@@ -8,8 +8,8 @@ use utoipa::ToSchema;
use uuid::Uuid;
use crate::domain::models::{
- Attachment, Contact, EmailThreadPreview, EmailThreadPreviewMetadata,
- EnrichedEmailThreadPreview, Label, LabelListVisibility, LabelType, MessageListVisibility,
+ Attachment, Contact, EmailThreadPreview, EnrichedEmailThreadPreview, Label,
+ LabelListVisibility, LabelType, MessageListVisibility,
};
/// common types of sorts based on timestamps
@@ -48,7 +48,6 @@ struct ApiThreadPreviewCursor {
#[dg(rename = "participants")]
contacts: Vec<ApiContact>,
labels: Vec<ApiLabel>,
- metadata: APIEmailThreadPreviewMetadata,
#[dg(map = map_frecency)]
frecency_score: Option<f64>,
}
@@ -168,20 +167,6 @@ pub enum ApiLabelType {
User,
}
-#[derive(Debug, ToSchema, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Doppleganger)]
-#[cfg_attr(feature = "ai_schema", derive(schemars::JsonSchema))]
-#[dg(backward = EmailThreadPreviewMetadata)]
-pub struct APIEmailThreadPreviewMetadata {
- /// if user has previously emailed any sender in the thread
- pub known_sender: bool,
- /// if any email contains a <table> html tag
- pub tabular: bool,
- /// if any email contains a calendar invite
- pub calendar_invite: bool,
- /// if any sender in the thread is a generic email
- pub generic_sender: bool,
-}
-
#[derive(Debug, ToSchema, Serialize, Deserialize)]
#[cfg_attr(feature = "ai_schema", derive(schemars::JsonSchema))]
pub struct ApiPaginatedThreadCursor {
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
index cb946d226c..cc88d45bdb 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo.rs
@@ -1,4 +1,4 @@
-use crate::domain::models::{IntermediateThreadMetadata, Label};
+use crate::domain::models::Label;
use crate::domain::{
models::{
Attachment, Contact, EmailThreadPreview, Link, PreviewCursorQuery, PreviewView,
@@ -242,85 +242,4 @@ impl EmailRepo for EmailPgRepo {
.transpose()
.map_err(|e| sqlx::Error::Decode(Box::new(e)))
}
-
- async fn threads_with_known_senders(
- &self,
- link_id: &Uuid,
- thread_ids: &[Uuid],
- ) -> Result<Vec<Uuid>, Self::Err> {
- // Returns thread IDs where the user has emailed at least one sender in the thread
- let result = sqlx::query_scalar!(
- r#"
- WITH user_link AS (
- SELECT id as link_id, email_address
- FROM email_links
- WHERE id = $1
- LIMIT 1
- ),
- -- Get all email addresses the user has previously sent messages to
- previously_contacted AS (
- SELECT DISTINCT c.email_address
- FROM email_messages m
- JOIN email_message_recipients mr ON m.id = mr.message_id
- JOIN email_contacts c ON mr.contact_id = c.id
- CROSS JOIN user_link
- WHERE m.link_id = user_link.link_id
- AND m.is_sent = true
- AND c.email_address != user_link.email_address
- )
- -- Find threads where any sender is in the previously contacted list
- SELECT DISTINCT m.thread_id
- FROM email_messages m
- JOIN email_contacts c ON m.from_contact_id = c.id
- WHERE m.thread_id = ANY($2)
- AND EXISTS (
- SELECT 1
- FROM previously_contacted pc
- WHERE pc.email_address = c.email_address
- )
- "#,
- link_id,
- thread_ids
- )
- .fetch_all(&self.pool)
- .await?;
-
- Ok(result)
- }
-
- async fn thread_metadata_by_thread_ids(
- &self,
- thread_ids: &[Uuid],
- ) -> Result<Vec<IntermediateThreadMetadata>, Self::Err> {
- // Returns thread metadata for the provided thread IDs.
- Ok(sqlx::query_as!(
- IntermediateThreadMetadataDbRow,
- r#"
- SELECT
- m.thread_id,
- -- Check if any message in thread has table HTML
- COALESCE(bool_or(m.body_html_sanitized LIKE '%<table%'), false) as "has_table!",
- -- Check if any message has calendar invite attachment
- COALESCE(bool_or(has_calendar.has_invite), false) as "has_calendar_invite!",
- -- Collect all unique sender emails in the thread
- COALESCE(array_agg(DISTINCT c.email_address), ARRAY[]::text[]) as "sender_emails!: Vec<String>"
- FROM email_messages m
- LEFT JOIN email_contacts c ON m.from_contact_id = c.id
- LEFT JOIN LATERAL (
- SELECT true as has_invite
- FROM email_attachments a
- WHERE a.message_id = m.id AND a.mime_type = 'application/ics'
- LIMIT 1
- ) has_calendar ON true
- WHERE m.thread_id = ANY($1)
- GROUP BY m.thread_id
- "#,
- thread_ids
- )
- .fetch_all(&self.pool)
- .await?
- .into_iter()
- .map(crate::outbound::email_pg_repo::IntermediateThreadMetadataDbRow::mirror)
- .collect())
- }
}
diff --git a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
index b922b36e5e..bb592a0e81 100644
--- a/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
+++ b/rust/cloud-storage/email/src/outbound/email_pg_repo/db_types.rs
@@ -1,6 +1,6 @@
use crate::domain::models::{
- Attachment, EmailThreadPreview, IntermediateThreadMetadata, Label, LabelListVisibility,
- LabelType, Link, MessageListVisibility,
+ Attachment, EmailThreadPreview, Label, LabelListVisibility, LabelType, Link,
+ MessageListVisibility,
};
use chrono::{DateTime, Utc};
use doppleganger::{Doppleganger, Mirror};
@@ -91,17 +91,6 @@ pub struct LabelDbRow {
pub type_: LabelTypeDbRow,
}
-/// database values needed to build thread preview metadata
-#[derive(Doppleganger)]
-#[dg(forward = IntermediateThreadMetadata)]
-#[derive(Debug, Clone)]
-pub struct IntermediateThreadMetadataDbRow {
- pub thread_id: Uuid,
- pub has_table: bool,
- pub has_calendar_invite: bool,
- pub sender_emails: Vec<String>,
-}
-
impl ThreadPreviewCursorDbRow {
pub fn with_user_id(self, owner_id: MacroUserIdStr<'_>) -> EmailThreadPreview {
let ThreadPreviewCursorDbRow {
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 19be571656..962a14e611 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
@@ -722,201 +722,3 @@ async fn test_dynamic_query_with_importance_filter(pool: Pool<Postgres>) -> anyh
Ok(())
}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("email_thread_metadata"))
-)]
-async fn test_thread_metadata_has_table(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let thread_id = Uuid::parse_str("11111111-1111-1111-1111-111111111111")?;
-
- let metadata = repo.thread_metadata_by_thread_ids(&[thread_id]).await?;
-
- assert_eq!(metadata.len(), 1);
- let item = &metadata[0];
-
- assert_eq!(item.thread_id, thread_id);
- assert!(item.has_table, "Should detect HTML table");
- assert!(
- !item.has_calendar_invite,
- "Should not detect calendar invite"
- );
- assert_eq!(item.sender_emails.len(), 1);
- assert_eq!(item.sender_emails[0], "[email protected]");
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("email_thread_metadata"))
-)]
-async fn test_thread_metadata_has_calendar_invite(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let thread_id = Uuid::parse_str("22222222-2222-2222-2222-222222222222")?;
-
- let metadata = repo.thread_metadata_by_thread_ids(&[thread_id]).await?;
-
- assert_eq!(metadata.len(), 1);
- let item = &metadata[0];
-
- assert_eq!(item.thread_id, thread_id);
- assert!(!item.has_table, "Should not detect HTML table");
- assert!(item.has_calendar_invite, "Should detect calendar invite");
-
- // Verify multiple senders are collected
- assert_eq!(item.sender_emails.len(), 2);
- assert!(
- item.sender_emails
- .contains(&"[email protected]".to_string())
- );
- assert!(
- item.sender_emails
- .contains(&"[email protected]".to_string())
- );
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("email_thread_metadata"))
-)]
-async fn test_thread_metadata_sender_deduplication(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- // Thread 3 has 2 messages from the same sender
- let thread_id = Uuid::parse_str("33333333-3333-3333-3333-333333333333")?;
-
- let metadata = repo.thread_metadata_by_thread_ids(&[thread_id]).await?;
-
- assert_eq!(metadata.len(), 1);
- let item = &metadata[0];
-
- assert_eq!(
- item.sender_emails.len(),
- 1,
- "Should deduplicate identical senders"
- );
- assert_eq!(item.sender_emails[0], "[email protected]");
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("email_thread_metadata"))
-)]
-async fn test_thread_metadata_batch_retrieval(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let t1 = Uuid::parse_str("11111111-1111-1111-1111-111111111111")?;
- let t2 = Uuid::parse_str("22222222-2222-2222-2222-222222222222")?;
-
- let metadata = repo.thread_metadata_by_thread_ids(&[t1, t2]).await?;
-
- assert_eq!(metadata.len(), 2);
-
- let meta1 = metadata.iter().find(|m| m.thread_id == t1).unwrap();
- assert!(meta1.has_table);
-
- let meta2 = metadata.iter().find(|m| m.thread_id == t2).unwrap();
- assert!(meta2.has_calendar_invite);
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("threads_with_known_senders"))
-)]
-async fn test_known_senders_single_match(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let link_id = Uuid::parse_str("00000000-0000-0000-0000-000000000001")?;
-
- // Thread 1 is from Known Contact A
- let thread_id = Uuid::parse_str("11111111-1111-1111-1111-111111111111")?;
-
- let result = repo
- .threads_with_known_senders(&link_id, &[thread_id])
- .await?;
-
- assert_eq!(result.len(), 1);
- assert_eq!(
- result[0], thread_id,
- "Should identify thread from known sender"
- );
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("threads_with_known_senders"))
-)]
-async fn test_known_senders_no_match(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let link_id = Uuid::parse_str("00000000-0000-0000-0000-000000000001")?;
-
- // Thread 2 is from Unknown Contact B
- let thread_id = Uuid::parse_str("22222222-2222-2222-2222-222222222222")?;
-
- let result = repo
- .threads_with_known_senders(&link_id, &[thread_id])
- .await?;
-
- assert!(
- result.is_empty(),
- "Should NOT return thread from unknown sender"
- );
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("threads_with_known_senders"))
-)]
-async fn test_known_senders_mixed_input(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let link_id = Uuid::parse_str("00000000-0000-0000-0000-000000000001")?;
-
- let t1_known = Uuid::parse_str("11111111-1111-1111-1111-111111111111")?;
- let t2_unknown = Uuid::parse_str("22222222-2222-2222-2222-222222222222")?;
- let t3_known = Uuid::parse_str("33333333-3333-3333-3333-333333333333")?;
-
- let result = repo
- .threads_with_known_senders(&link_id, &[t1_known, t2_unknown, t3_known])
- .await?;
-
- assert_eq!(result.len(), 2);
- assert!(result.contains(&t1_known));
- assert!(result.contains(&t3_known));
- assert!(!result.contains(&t2_unknown));
-
- Ok(())
-}
-
-#[sqlx::test(
- migrator = "MACRO_DB_MIGRATIONS",
- fixtures(path = "../../../fixtures", scripts("threads_with_known_senders"))
-)]
-async fn test_known_senders_mixed_thread_participants(pool: Pool<Postgres>) -> anyhow::Result<()> {
- let repo = EmailPgRepo::new(pool);
- let link_id = Uuid::parse_str("00000000-0000-0000-0000-000000000001")?;
-
- // Thread 4 has messages from both Unknown B and Known A
- let thread_id = Uuid::parse_str("44444444-4444-4444-4444-444444444444")?;
-
- let result = repo
- .threads_with_known_senders(&link_id, &[thread_id])
- .await?;
-
- assert_eq!(
- result.len(),
- 1,
- "Should match because at least one participant is known"
- );
- assert_eq!(result[0], thread_id);
-
- Ok(())
-}
diff --git a/rust/cloud-storage/models_soup/src/email_thread.rs b/rust/cloud-storage/models_soup/src/email_thread.rs
index 42e99b5571..31ad6b7c36 100644
--- a/rust/cloud-storage/models_soup/src/email_thread.rs
+++ b/rust/cloud-storage/models_soup/src/email_thread.rs
@@ -19,22 +19,6 @@ pub struct SoupContact {
pub sfs_photo_url: Option<String>,
}
-#[derive(Debug, Doppleganger, Serialize, Deserialize)]
-#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
-#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
-#[dg(backward = email::domain::models::EmailThreadPreviewMetadata)]
-#[serde(rename_all = "camelCase")]
-pub struct SoupEmailThreadPreviewMetadata {
- /// if user has previously emailed any sender
- pub known_sender: bool,
- /// if any email contains a <table> html tag
- pub tabular: bool,
- /// if any email contains a calendar invite
- pub calendar_invite: bool,
- /// if any sender is a generic email
- pub generic_sender: bool,
-}
-
#[derive(Debug, Doppleganger, Serialize, Deserialize)]
#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
#[cfg_attr(feature = "mock", derive(PartialEq, Eq))]
@@ -141,7 +125,6 @@ pub struct SoupEnrichedEmailThreadPreview {
pub thread: SoupEmailThreadPreview,
pub attachments: Vec<SoupAttachment>,
pub participants: Vec<SoupContact>,
- pub metadata: SoupEmailThreadPreviewMetadata,
pub labels: Vec<SoupLabel>,
pub properties: Vec<SoupProperty>,
}
diff --git a/rust/cloud-storage/soup/src/domain/service.rs b/rust/cloud-storage/soup/src/domain/service.rs
index e6b2463b60..cb6ffaeafa 100644
--- a/rust/cloud-storage/soup/src/domain/service.rs
+++ b/rust/cloud-storage/soup/src/domain/service.rs
@@ -25,8 +25,8 @@ use models_pagination::{
use models_soup::{
comms::SoupChannel,
email_thread::{
- SoupAttachment, SoupContact, SoupEmailThreadPreview, SoupEmailThreadPreviewMetadata,
- SoupEnrichedEmailThreadPreview, SoupLabel,
+ SoupAttachment, SoupContact, SoupEmailThreadPreview, SoupEnrichedEmailThreadPreview,
+ SoupLabel,
},
item::SoupItem,
};
@@ -275,7 +275,6 @@ where
thread,
attachments,
labels,
- metadata,
mut frecency_score,
participants,
..
@@ -285,7 +284,6 @@ where
thread: SoupEmailThreadPreview::mirror(thread),
attachments: Vec::<SoupAttachment>::mirror(attachments),
participants: Vec::<SoupContact>::mirror(participants),
- metadata: SoupEmailThreadPreviewMetadata::mirror(metadata),
labels: Vec::<SoupLabel>::mirror(labels),
properties: Default::default(),
};