Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat: add call_ids as a soup filter for call records (#3031)
gbirman273c2782edcf
diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts b/js/app/packages/app/component/next-soup/filters/filter-store/compile.tsindex 1fa52df3bc..47f52dd691 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts@@ -88,6 +88,7 @@ const FIELD_CONFIG: Record<folderOwnerId: { target: 'pf', field: 'o' },folderSeen: { target: 'pf', field: 'ns' },folderDone: { target: 'pf', field: 'nd' },+ callId: { target: 'callf', field: 'CallId' },callChannelId: { target: 'callf', field: 'ChannelId' },callSpeakerId: { target: 'callf', field: 'Speaker' },callAttended: { target: 'callf', field: 'Attended' },@@ -220,7 +221,7 @@ const ID_FIELD_NAMES: Partial<Record<QueryTarget, FieldName>> = {chanf: 'channelId',cf: 'chatId',pf: 'folderId',- callf: 'callChannelId',+ callf: 'callId',};type DefineQueryFiltersOptions = {diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts b/js/app/packages/app/component/next-soup/filters/filter-store/types.tsindex 2345343b03..a2c9ff2d42 100644--- a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts+++ b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts@@ -24,6 +24,7 @@ export type ArrayFieldFilters = {chatProjectId?: string[];folderId?: string[];folderOwnerId?: string[];+ callId?: string[];callChannelId?: string[];callSpeakerId?: string[];properties?: PropertyFilter[];diff --git a/js/app/packages/app/component/next-soup/filters/query-filters.ts b/js/app/packages/app/component/next-soup/filters/query-filters.tsindex d508e039a4..867ed59c43 100644--- a/js/app/packages/app/component/next-soup/filters/query-filters.ts+++ b/js/app/packages/app/component/next-soup/filters/query-filters.ts@@ -8,7 +8,7 @@ export const EXCLUDE: string[] = [NIL_UUID];// Base filter that excludes all entity types by defaultexport const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {- call_filters: { channel_ids: EXCLUDE },+ call_filters: { call_ids: EXCLUDE },channel_filters: { channel_ids: EXCLUDE },chat_filters: { chat_ids: EXCLUDE },document_filters: { document_ids: EXCLUDE },@@ -75,7 +75,7 @@ export function filterSoupItemByRequestBody(.with({ tag: 'call' },({ data }) =>- !isIdFilteredOut(body.call_filters?.channel_ids, data.channelId) &&+ !isIdFilteredOut(body.call_filters?.call_ids, data.callId) &&!isAttendedFilteredOut(body.call_filters?.attended, data.attended)).exhaustive();diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.tsindex 9e9d48a3dc..433cf6f568 100644--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts@@ -92,11 +92,13 @@ function filterDataToQueryFilters(data: QueryState): EntityFilters {// Call filtersif (+ include.callId?.length ||include.callChannelId?.length ||include.callSpeakerId?.length ||include.callAttended !== undefined) {filters.call_filters = {+ call_ids: include.callId,channel_ids: include.callChannelId,speaker_ids: include.callSpeakerId,attended: include.callAttended,diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsxindex 61073a87a4..010fa57d73 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx@@ -175,7 +175,7 @@ type PersistedSoupViewState = {assigneeFilter: string[];};-const PERSISTED_STATE_VERSION = 5;+const PERSISTED_STATE_VERSION = 6;const listStateCache = new Map<string,diff --git a/js/app/packages/channel/Attachments/ChannelAttachmentEntitySection.tsx b/js/app/packages/channel/Attachments/ChannelAttachmentEntitySection.tsxindex 14ef3e8718..08a908989c 100644--- a/js/app/packages/channel/Attachments/ChannelAttachmentEntitySection.tsx+++ b/js/app/packages/channel/Attachments/ChannelAttachmentEntitySection.tsx@@ -31,10 +31,7 @@ export function ChannelAttachmentEntitySection(props: { channelId: string }) {const soupQuery = useSoupItemsQuery(() => ({params: { limit: 500 },- body: buildAttachmentEntityFilters(- documentAttachments(),- props.channelId- ),+ body: buildAttachmentEntityFilters(documentAttachments()),}),() => ({ enabled: documentAttachments().length > 0 }));diff --git a/js/app/packages/channel/Attachments/attachment-utils.ts b/js/app/packages/channel/Attachments/attachment-utils.tsindex 25090101bb..0ad00d62e2 100644--- a/js/app/packages/channel/Attachments/attachment-utils.ts+++ b/js/app/packages/channel/Attachments/attachment-utils.ts@@ -26,14 +26,14 @@ export function itemsPerRow(containerWidth: number): number {* so they return nothing instead of everything.*/export function buildAttachmentEntityFilters(- attachments: ApiChannelAttachment[],- channelId: string+ attachments: ApiChannelAttachment[]) {const documentIds: string[] = [];const emailIds: string[] = [];const chatIds: string[] = [];const channelIds: string[] = [];const projectIds: string[] = [];+ const callIds: string[] = [];for (const a of attachments) {const itemType = stringToItemType(a.entity_type);@@ -71,7 +71,7 @@ export function buildAttachmentEntityFilters(project_ids: projectIds.length > 0 ? projectIds : [NIL_ID],},call_filters: {- channel_ids: [channelId],+ call_ids: callIds.length > 0 ? callIds : [NIL_ID],},};}diff --git a/js/app/packages/queries/soup/recently-viewed.ts b/js/app/packages/queries/soup/recently-viewed.tsindex b8ac7eabff..80c2726478 100644--- a/js/app/packages/queries/soup/recently-viewed.ts+++ b/js/app/packages/queries/soup/recently-viewed.ts@@ -20,7 +20,7 @@ const recentlyViewedArgs: SoupItemsQueryArgs = {params: { sort_method: 'viewed_at', limit: RECENTLY_VIEWED_LIMIT },body: {call_filters: {- channel_ids: ['00000000-0000-0000-0000-000000000000'],+ call_ids: ['00000000-0000-0000-0000-000000000000'],},},};diff --git a/js/app/packages/service-clients/service-search/generated/models/callFilters.ts b/js/app/packages/service-clients/service-search/generated/models/callFilters.tsindex 048d996ace..d17de9a5d5 100644--- a/js/app/packages/service-clients/service-search/generated/models/callFilters.ts+++ b/js/app/packages/service-clients/service-search/generated/models/callFilters.ts@@ -14,6 +14,8 @@ export interface CallFilters {`None` = no filter, `Some(true)` = only calls the user joined,`Some(false)` = only calls the user did not join. */attended?: CallFiltersAttended;+ /** Call record IDs to filter by. Empty to include all calls. */+ call_ids?: string[];/** Channel IDs to filter calls by. Empty to include all calls. */channel_ids?: string[];/** Speaker macro user ids. Empty to include all. */diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.jsonindex e4add8a5f7..0051b3b62c 100644--- a/js/app/packages/service-clients/service-search/openapi.json+++ b/js/app/packages/service-clients/service-search/openapi.json@@ -181,6 +181,13 @@"type": ["boolean", "null"],"description": "Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."},+ "call_ids": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Call record IDs to filter by. Empty to include all calls."+ },"channel_ids": {"type": "array","items": {diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.tsindex 5e4ca07a2a..38abf27366 100644--- a/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts+++ b/js/app/packages/service-clients/service-storage/generated/schemas/callFilters.ts@@ -14,6 +14,8 @@ export interface CallFilters {`None` = no filter, `Some(true)` = only calls the user joined,`Some(false)` = only calls the user did not join. */attended?: CallFiltersAttended;+ /** Call record IDs to filter by. Empty to include all calls. */+ call_ids?: string[];/** Channel IDs to filter calls by. Empty to include all calls. */channel_ids?: string[];/** Speaker macro user ids. Empty to include all. */diff --git a/js/app/packages/service-clients/service-storage/generated/zod.ts b/js/app/packages/service-clients/service-storage/generated/zod.tsindex 747c8149c2..3ba78b8e07 100644--- a/js/app/packages/service-clients/service-storage/generated/zod.ts+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts@@ -5186,6 +5186,12 @@ export const postItemsSoupBody = zod.describe('Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join.'),+ call_ids: zod+ .array(zod.string())+ .optional()+ .describe(+ 'Call record IDs to filter by. Empty to include all calls.'+ ),channel_ids: 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.jsonindex b46592f795..a8d4d105e7 100644--- a/js/app/packages/service-clients/service-storage/openapi.json+++ b/js/app/packages/service-clients/service-storage/openapi.json@@ -6452,6 +6452,13 @@"type": ["boolean", "null"],"description": "Filter by whether the requesting user attended the call.\n`None` = no filter, `Some(true)` = only calls the user joined,\n`Some(false)` = only calls the user did not join."},+ "call_ids": {+ "type": "array",+ "items": {+ "type": "string"+ },+ "description": "Call record IDs to filter by. Empty to include all calls."+ },"channel_ids": {"type": "array","items": {diff --git a/rust/cloud-storage/.sqlx/query-83c08cb37967db1ed7bdeea17cc5d764bd5f1e87d6cce7734b5758c5a82dd84a.json b/rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.jsonsimilarity index 68%rename from rust/cloud-storage/.sqlx/query-83c08cb37967db1ed7bdeea17cc5d764bd5f1e87d6cce7734b5758c5a82dd84a.jsonrename to rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.jsonindex eaf871b3b1..953e991ed2 100644--- a/rust/cloud-storage/.sqlx/query-83c08cb37967db1ed7bdeea17cc5d764bd5f1e87d6cce7734b5758c5a82dd84a.json+++ b/rust/cloud-storage/.sqlx/query-e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c.json@@ -1,6 +1,6 @@{"db_name": "PostgreSQL",- "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text AS source_id\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1 AS source_id\n )\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n created_at as \"started_at!\",\n NULL::timestamptz as \"ended_at\",\n NULL::bigint as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n NULL::text as \"custom_name\",\n NULL::text as \"summary\",\n true as \"is_active!\"\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = c.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1\n ) = $5)\n UNION ALL\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n started_at as \"started_at!\",\n ended_at as \"ended_at\",\n duration_ms as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n custom_name,\n summary,\n false as \"is_active!\"\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) = $5)\n ORDER BY \"started_at!\" DESC\n LIMIT $2\n ",+ "query": "\n WITH user_source_ids AS (\n SELECT cp.channel_id::text AS source_id\n FROM comms_channel_participants cp\n WHERE cp.user_id = $1 AND cp.left_at IS NULL\n UNION ALL\n SELECT t.team_id::text AS source_id\n FROM team_user t\n WHERE t.user_id = $1\n UNION ALL\n SELECT $1 AS source_id\n )\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n created_at as \"started_at!\",\n NULL::timestamptz as \"ended_at\",\n NULL::bigint as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n NULL::text as \"custom_name\",\n NULL::text as \"summary\",\n true as \"is_active!\"\n FROM calls c\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = c.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR c.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_participants cp\n WHERE cp.call_id = c.id AND cp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR c.id = ANY($7))\n UNION ALL\n SELECT\n id as \"call_id!\",\n channel_id as \"channel_id!\",\n room_name as \"room_name!\",\n created_by as \"created_by!\",\n started_at as \"started_at!\",\n ended_at as \"ended_at\",\n duration_ms as \"duration_ms\",\n egress_id,\n recording_key,\n recording_started_at,\n custom_name,\n summary,\n false as \"is_active!\"\n FROM call_records cr\n WHERE EXISTS (\n SELECT 1 FROM entity_access ea\n JOIN user_source_ids u ON u.source_id = ea.source_id\n WHERE ea.entity_id = cr.id\n AND ea.entity_type = 'call'\n )\n AND ($3::bool IS FALSE OR cr.channel_id = ANY($4))\n AND ($5::bool IS NULL OR EXISTS (\n SELECT 1 FROM call_record_participants crp\n WHERE crp.call_record_id = cr.id AND crp.user_id = $1\n ) = $5)\n AND ($6::bool IS FALSE OR cr.id = ANY($7))\n ORDER BY \"started_at!\" DESC\n LIMIT $2\n ","describe": {"columns": [{@@ -75,7 +75,9 @@"Int8","Bool","UuidArray",- "Bool"+ "Bool",+ "Bool",+ "UuidArray"]},"nullable": [@@ -94,5 +96,5 @@null]},- "hash": "83c08cb37967db1ed7bdeea17cc5d764bd5f1e87d6cce7734b5758c5a82dd84a"+ "hash": "e2c56203be986cfddced6fdc1dad55e15f226bd72a17498c501b273762ca201c"}diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo.rsindex 527ee2f4db..d2b66b3a74 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo.rs@@ -53,6 +53,7 @@ fn extract_channel_ids(filter: &LiteralTree<CallLiteral>) -> Vec<Uuid> {fn collect_channel_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {match expr {Expr::Literal(CallLiteral::ChannelId(id)) => ids.push(*id),+ Expr::Literal(CallLiteral::CallId(_)) => {}Expr::Literal(CallLiteral::Attended(_)) => {}// Speaker is transcript-segment-only; soup's call list ignores it.Expr::Literal(CallLiteral::Speaker(_)) => {}@@ -64,6 +65,30 @@ fn collect_channel_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {}}+/// Extract call_id UUIDs from a call filter AST.+fn extract_call_ids(filter: &LiteralTree<CallLiteral>) -> Vec<Uuid> {+ let Some(expr) = filter else {+ return Vec::new();+ };+ let mut ids = Vec::new();+ collect_call_ids(expr, &mut ids);+ ids+}++fn collect_call_ids(expr: &Expr<CallLiteral>, ids: &mut Vec<Uuid>) {+ match expr {+ Expr::Literal(CallLiteral::CallId(id)) => ids.push(*id),+ Expr::Literal(CallLiteral::ChannelId(_)) => {}+ Expr::Literal(CallLiteral::Attended(_)) => {}+ Expr::Literal(CallLiteral::Speaker(_)) => {}+ Expr::And(a, b) | Expr::Or(a, b) => {+ collect_call_ids(a, ids);+ collect_call_ids(b, ids);+ }+ Expr::Not(inner) => collect_call_ids(inner, ids),+ }+}+/// Extract the `attended` literal from a call filter AST, if any.////// `ExpandFrame::expand_ast` only emits at most one `Attended` literal, so we@@ -76,6 +101,7 @@ fn extract_attended(filter: &LiteralTree<CallLiteral>) -> Option<bool> {fn find_attended(expr: &Expr<CallLiteral>) -> Option<bool> {match expr {Expr::Literal(CallLiteral::Attended(b)) => Some(*b),+ Expr::Literal(CallLiteral::CallId(_)) => None,Expr::Literal(CallLiteral::ChannelId(_)) => None,Expr::Literal(CallLiteral::Speaker(_)) => None,Expr::And(a, b) | Expr::Or(a, b) => find_attended(a).or_else(|| find_attended(b)),@@ -1023,6 +1049,8 @@ impl CallRepository for PgCallRepo {// This mirrors `entity_access::pg_access_repo::queries::call_access`.let channel_ids = extract_channel_ids(filter);let has_channel_filter = !channel_ids.is_empty();+ let call_ids = extract_call_ids(filter);+ let has_call_id_filter = !call_ids.is_empty();let attended = extract_attended(filter);let rows = sqlx::query!(@@ -1064,6 +1092,7 @@ impl CallRepository for PgCallRepo {SELECT 1 FROM call_participants cpWHERE cp.call_id = c.id AND cp.user_id = $1) = $5)+ AND ($6::bool IS FALSE OR c.id = ANY($7))UNION ALLSELECTid as "call_id!",@@ -1091,6 +1120,7 @@ impl CallRepository for PgCallRepo {SELECT 1 FROM call_record_participants crpWHERE crp.call_record_id = cr.id AND crp.user_id = $1) = $5)+ AND ($6::bool IS FALSE OR cr.id = ANY($7))ORDER BY "started_at!" DESCLIMIT $2"#,@@ -1099,6 +1129,8 @@ impl CallRepository for PgCallRepo {has_channel_filter,&channel_ids,attended,+ has_call_id_filter,+ &call_ids,).fetch_all(&self.pool).await?;diff --git a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rsindex c58ea6310d..15b81480d2 100644--- a/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs+++ b/rust/cloud-storage/call/src/outbound/pg_call_repo/test.rs@@ -23,6 +23,15 @@ fn attended_filter(b: bool) -> LiteralTree<CallLiteral> {Some(Arc::new(Expr::Literal(CallLiteral::Attended(b))))}+fn call_ids_filter(ids: &[Uuid]) -> LiteralTree<CallLiteral> {+ let mut iter = ids.iter().copied().map(CallLiteral::CallId);+ let first = iter.next()?;+ let expr = iter.fold(Expr::Literal(first), |acc, lit| {+ Expr::Or(Box::new(acc), Box::new(Expr::Literal(lit)))+ });+ Some(Arc::new(expr))+}+const CH1: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000c01);const CH2: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000c02);const CALL1: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_0000000ca110);@@ -1144,6 +1153,39 @@ async fn get_call_records_by_user_attended_none_returns_all(Ok(())}+#[sqlx::test(+ fixtures(path = "../../../fixtures", scripts("call_repo")),+ migrator = "MACRO_DB_MIGRATIONS"+)]+async fn get_call_records_by_user_call_ids_filter_narrows_results(+ pool: Pool<Postgres>,+) -> anyhow::Result<()> {+ let repo = repo(pool);++ let filter = call_ids_filter(&[CALL_ARCHIVED]);+ let records = repo+ .get_call_records_by_user(USER_A.deref().copied(), 10, &filter)+ .await?;+ assert_eq!(records.len(), 1);+ assert_eq!(records[0].call_id, CALL_ARCHIVED);++ let filter = call_ids_filter(&[CALL1, CALL_ARCHIVED]);+ let records = repo+ .get_call_records_by_user(USER_A.deref().copied(), 10, &filter)+ .await?;+ assert_eq!(records.len(), 2);++ let filter = call_ids_filter(&[Uuid::nil()]);+ let records = repo+ .get_call_records_by_user(USER_A.deref().copied(), 10, &filter)+ .await?;+ assert!(+ records.is_empty(),+ "no call should match an unrelated call id"+ );+ Ok(())+}+#[sqlx::test(fixtures(path = "../../../fixtures", scripts("call_repo")),migrator = "MACRO_DB_MIGRATIONS"diff --git a/rust/cloud-storage/item_filters/src/ast/call.rs b/rust/cloud-storage/item_filters/src/ast/call.rsindex dce4a3d6c3..0d32621870 100644--- a/rust/cloud-storage/item_filters/src/ast/call.rs+++ b/rust/cloud-storage/item_filters/src/ast/call.rs@@ -8,6 +8,8 @@ use crate::{CallFilters, ast::ExpandErr};/// the possible literal values in a call filter ast#[derive(Debug, Serialize, Deserialize, Clone)]pub enum CallLiteral {+ /// filter by an individual call record id+ CallId(Uuid),/// filter by the channel a call belongs toChannelId(Uuid),/// filter by the speaker of a transcript segment@@ -21,11 +23,17 @@ impl ExpandFrame<CallLiteral> for CallFilters {fn expand_ast(filter_request: CallFilters) -> Result<Option<Expr<CallLiteral>>, Self::Err> {let CallFilters {+ call_ids,channel_ids,speaker_ids,attended,} = filter_request;+ let call_ids = call_ids+ .iter()+ .map(|s| Uuid::parse_str(s))+ .try_expand(|r| r.map(CallLiteral::CallId), Expr::or)?;+let channel_ids = channel_ids.iter().map(|s| Uuid::parse_str(s))@@ -38,7 +46,7 @@ impl ExpandFrame<CallLiteral> for CallFilters {let attended = attended.map(|b| Expr::Literal(CallLiteral::Attended(b)));- Ok([channel_ids, speaker_ids, attended]+ Ok([call_ids, channel_ids, speaker_ids, attended].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.rsindex e7f12a5224..3f6c302b66 100644--- a/rust/cloud-storage/item_filters/src/ast/tests.rs+++ b/rust/cloud-storage/item_filters/src/ast/tests.rs@@ -802,9 +802,8 @@ fn entity_type_ast_deserialization_rejects_invalid() {#[test]fn it_expands_call_filter_with_attended_only() {let f = CallFilters {- channel_ids: vec![],- speaker_ids: vec![],attended: Some(true),+ ..Default::default()};let ast = CallFilters::expand_ast(f).unwrap()@@ -817,9 +816,8 @@ fn it_expands_call_filter_with_attended_only() {#[test]fn it_expands_call_filter_with_attended_false() {let f = CallFilters {- channel_ids: vec![],- speaker_ids: vec![],attended: Some(false),+ ..Default::default()};let ast = CallFilters::expand_ast(f).unwrap().unwrap();let json = serde_json::to_value(&ast).unwrap();@@ -832,8 +830,8 @@ fn it_expands_call_filter_with_channel_and_attended_as_and() {let channel_id = Uuid::new_v4();let f = CallFilters {channel_ids: vec![channel_id.to_string()],- speaker_ids: vec![],attended: Some(true),+ ..Default::default()};let ast = CallFilters::expand_ast(f).unwrap().unwrap();let json = serde_json::to_value(&ast).unwrap();@@ -846,6 +844,19 @@ fn it_expands_call_filter_with_channel_and_attended_as_and() {assert_eq!(json, exp);}+#[test]+fn it_expands_call_filter_with_call_ids() {+ let call_id = Uuid::new_v4();+ let f = CallFilters {+ call_ids: vec![call_id.to_string()],+ ..Default::default()+ };+ let ast = CallFilters::expand_ast(f).unwrap().unwrap();+ let json = serde_json::to_value(&ast).unwrap();+ let exp = json!({ "l": { "CallId": call_id } });+ assert_eq!(json, exp);+}+#[test]fn it_expands_call_filter_without_attended_is_none_when_empty() {let f = CallFilters::default();diff --git a/rust/cloud-storage/item_filters/src/lib.rs b/rust/cloud-storage/item_filters/src/lib.rsindex dfe1eef9a5..8965e77fa9 100644--- a/rust/cloud-storage/item_filters/src/lib.rs+++ b/rust/cloud-storage/item_filters/src/lib.rs@@ -289,6 +289,9 @@ impl IsEmpty for EmailFilters {#[derive(Debug, Serialize, Deserialize, Default, PartialEq, Clone)]#[cfg_attr(feature = "schema", derive(utoipa::ToSchema, schemars::JsonSchema))]pub struct CallFilters {+ /// Call record IDs to filter by. Empty to include all calls.+ #[serde(default, skip_serializing_if = "Vec::is_empty")]+ pub call_ids: Vec<String>,/// Channel IDs to filter calls by. Empty to include all calls.#[serde(default, skip_serializing_if = "Vec::is_empty")]pub channel_ids: Vec<String>,@@ -305,11 +308,15 @@ pub struct CallFilters {impl IsEmpty for CallFilters {fn is_empty(&self) -> bool {let CallFilters {+ call_ids,channel_ids,speaker_ids,attended,} = self;- channel_ids.is_empty() && speaker_ids.is_empty() && attended.is_none()+ call_ids.is_empty()+ && channel_ids.is_empty()+ && speaker_ids.is_empty()+ && attended.is_none()}}diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rsindex 01d1c90192..0b23383bfe 100644--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_call_record.rs@@ -1,3 +1,5 @@+use std::collections::HashSet;+use item_filters::CallFilters;use crate::api::context::SearchHandlerState;@@ -23,7 +25,17 @@ pub(in crate::api::search) async fn filter_calls(.await.map_err(SearchError::InternalError)?;- let call_ids = accessible.into_iter().map(|id| id.to_string()).collect();+ let accessible_ids: Vec<String> = accessible.into_iter().map(|id| id.to_string()).collect();++ let call_ids = if filters.call_ids.is_empty() {+ accessible_ids+ } else {+ let requested: HashSet<&str> = filters.call_ids.iter().map(String::as_str).collect();+ accessible_ids+ .into_iter()+ .filter(|id| requested.contains(id.as_str()))+ .collect()+ };Ok(FilterCallResponse {call_ids,