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): channel_thread participants filter (#4441)

teoda13d6247beb
diff --git a/js/app/packages/service-clients/service-search/generated/models/channelThreadFilters.ts b/js/app/packages/service-clients/service-search/generated/models/channelThreadFilters.ts
index e260c946b5..a70f3d346f 100644
--- a/js/app/packages/service-clients/service-search/generated/models/channelThreadFilters.ts
+++ b/js/app/packages/service-clients/service-search/generated/models/channelThreadFilters.ts
@@ -11,6 +11,11 @@
export interface ChannelThreadFilters {
/** Channel IDs containing the thread. Empty to include threads from all accessible channels. */
channel_ids?: string[];
+ /** Thread participant user IDs. A participant is the root message sender, anyone
+who replied in the thread, or anyone @-mentioned in the thread (group mentions
+like @here count through their per-user expansion at send time). Empty to
+include threads regardless of participants. */
+ participant_ids?: string[];
/** Sender IDs for the root thread message. Empty to include all root senders. */
root_sender_ids?: string[];
/** Channel thread parent message IDs to include. Empty to include all accessible threads. */
diff --git a/js/app/packages/service-clients/service-search/openapi.json b/js/app/packages/service-clients/service-search/openapi.json
index 48bfaf2ac4..afe9594f7e 100644
--- a/js/app/packages/service-clients/service-search/openapi.json
+++ b/js/app/packages/service-clients/service-search/openapi.json
@@ -634,6 +634,13 @@
},
"description": "Channel IDs containing the thread. Empty to include threads from all accessible channels."
},
+ "participant_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Thread participant user IDs. A participant is the root message sender, anyone\nwho replied in the thread, or anyone @-mentioned in the thread (group mentions\nlike @here count through their per-user expansion at send time). Empty to\ninclude threads regardless of participants."
+ },
"root_sender_ids": {
"type": "array",
"items": {
diff --git a/js/app/packages/service-clients/service-storage/generated/schemas/channelThreadFilters.ts b/js/app/packages/service-clients/service-storage/generated/schemas/channelThreadFilters.ts
index 96f61dd53c..b27781cf5e 100644
--- a/js/app/packages/service-clients/service-storage/generated/schemas/channelThreadFilters.ts
+++ b/js/app/packages/service-clients/service-storage/generated/schemas/channelThreadFilters.ts
@@ -11,6 +11,11 @@
export interface ChannelThreadFilters {
/** Channel IDs containing the thread. Empty to include threads from all accessible channels. */
channel_ids?: string[];
+ /** Thread participant user IDs. A participant is the root message sender, anyone
+who replied in the thread, or anyone @-mentioned in the thread (group mentions
+like @here count through their per-user expansion at send time). Empty to
+include threads regardless of participants. */
+ participant_ids?: string[];
/** Sender IDs for the root thread message. Empty to include all root senders. */
root_sender_ids?: string[];
/** Channel thread parent message IDs to include. Empty to include all accessible threads. */
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 a0069df955..49fec4b10f 100644
--- a/js/app/packages/service-clients/service-storage/generated/zod.ts
+++ b/js/app/packages/service-clients/service-storage/generated/zod.ts
@@ -8353,6 +8353,12 @@ export const postItemsSoupBody = zod
.describe(
'Channel IDs containing the thread. Empty to include threads from all accessible channels.'
),
+ participant_ids: zod
+ .array(zod.string())
+ .optional()
+ .describe(
+ 'Thread participant user IDs. A participant is the root message sender, anyone\nwho replied in the thread, or anyone @-mentioned in the thread (group mentions\nlike @here count through their per-user expansion at send time). Empty to\ninclude threads regardless of participants.'
+ ),
root_sender_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.json
index 1fd9819188..0f5ef78458 100644
--- a/js/app/packages/service-clients/service-storage/openapi.json
+++ b/js/app/packages/service-clients/service-storage/openapi.json
@@ -11433,6 +11433,13 @@
},
"description": "Channel IDs containing the thread. Empty to include threads from all accessible channels."
},
+ "participant_ids": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Thread participant user IDs. A participant is the root message sender, anyone\nwho replied in the thread, or anyone @-mentioned in the thread (group mentions\nlike @here count through their per-user expansion at send time). Empty to\ninclude threads regardless of participants."
+ },
"root_sender_ids": {
"type": "array",
"items": {
diff --git a/rust/cloud-storage/channels/fixtures/channels_repo.sql b/rust/cloud-storage/channels/fixtures/channels_repo.sql
index 8f65c77385..cec0916772 100644
--- a/rust/cloud-storage/channels/fixtures/channels_repo.sql
+++ b/rust/cloud-storage/channels/fixtures/channels_repo.sql
@@ -120,6 +120,81 @@ INSERT INTO comms_channel_participants (channel_id, user_id, role, joined_at, le
('00000000-0000-0000-0000-000000000c03', 'macro|[email protected]', 'owner', '2024-01-01 00:00:00+00', NULL),
('00000000-0000-0000-0000-000000000c03', 'macro|[email protected]', 'member', '2024-01-01 00:03:00+00', '2024-01-05 00:00:00+00');
+-- Channel ch4: participant-filter fixture (no user-a so ch4 threads stay out of the
+-- user-a listing assertions above).
+-- Participants: user-b (owner), user-c (member), user-e (member), left-user (left).
+-- Threads (all rooted by user-b):
+-- t41 (10:00): user-c replied (10:05); left-user replied (10:06); a soft-deleted
+-- reply from user-e (10:07) that must NOT make user-e a participant
+-- t42 (11:00): user-c is @-mentioned in the root message
+-- t43 (12:00): root message contains a group mention (@here), stored as the
+-- client-side expansion: one user mention row per member at send time
+-- t44 (13:00): plain root; a reply (13:05) contains a group mention (@here),
+-- likewise expanded into per-user mention rows
+INSERT INTO comms_channels (id, name, channel_type, org_id, owner_id, created_at, updated_at) VALUES
+ ('00000000-0000-0000-0000-000000000c04', 'participant-filter', 'public', NULL, 'macro|[email protected]',
+ '2024-01-02 00:00:00+00', '2024-01-02 00:00:00+00');
+
+INSERT INTO comms_channel_participants (channel_id, user_id, role, joined_at, left_at) VALUES
+ ('00000000-0000-0000-0000-000000000c04', 'macro|[email protected]', 'owner', '2024-01-02 00:00:00+00', NULL),
+ ('00000000-0000-0000-0000-000000000c04', 'macro|[email protected]', 'member', '2024-01-02 00:01:00+00', NULL),
+ ('00000000-0000-0000-0000-000000000c04', 'macro|[email protected]', 'member', '2024-01-02 00:02:00+00', NULL),
+ ('00000000-0000-0000-0000-000000000c04', 'macro|[email protected]', 'member', '2024-01-02 00:03:00+00', '2024-01-05 00:00:00+00');
+
+INSERT INTO comms_messages (id, channel_id, thread_id, sender_id, content, created_at, updated_at, edited_at, deleted_at) VALUES
+ -- t41: replies determine participants
+ ('00000000-0000-0000-0000-000000000041', '00000000-0000-0000-0000-000000000c04', NULL,
+ 'macro|[email protected]', 'participant thread parent', '2024-01-02 10:00:00+00', '2024-01-02 10:00:00+00', NULL, NULL),
+ ('00000000-0000-0000-0000-00000000b041', '00000000-0000-0000-0000-000000000c04',
+ '00000000-0000-0000-0000-000000000041', 'macro|[email protected]', 'reply from user-c',
+ '2024-01-02 10:05:00+00', '2024-01-02 10:05:00+00', NULL, NULL),
+ ('00000000-0000-0000-0000-00000000b042', '00000000-0000-0000-0000-000000000c04',
+ '00000000-0000-0000-0000-000000000041', 'macro|[email protected]', 'reply from departed user',
+ '2024-01-02 10:06:00+00', '2024-01-02 10:06:00+00', NULL, NULL),
+ ('00000000-0000-0000-0000-00000000b043', '00000000-0000-0000-0000-000000000c04',
+ '00000000-0000-0000-0000-000000000041', 'macro|[email protected]', 'deleted reply from user-e',
+ '2024-01-02 10:07:00+00', '2024-01-02 10:07:00+00', NULL, '2024-01-02 10:08:00+00'),
+ -- t42: @-mention determines participants (mention row below)
+ ('00000000-0000-0000-0000-000000000042', '00000000-0000-0000-0000-000000000c04', NULL,
+ 'macro|[email protected]', 'mentioning <m-user-mention>{"userId":"macro|[email protected]","email":"[email protected]"}</m-user-mention>',
+ '2024-01-02 11:00:00+00', '2024-01-02 11:00:00+00', NULL, NULL),
+ -- t43: group mention in the root message
+ ('00000000-0000-0000-0000-000000000043', '00000000-0000-0000-0000-000000000c04', NULL,
+ 'macro|[email protected]', 'heads up <m-group-mention>{"groupAlias":"here"}</m-group-mention>',
+ '2024-01-02 12:00:00+00', '2024-01-02 12:00:00+00', NULL, NULL),
+ -- t44: group mention in a reply
+ ('00000000-0000-0000-0000-000000000044', '00000000-0000-0000-0000-000000000c04', NULL,
+ 'macro|[email protected]', 'plain parent', '2024-01-02 13:00:00+00', '2024-01-02 13:00:00+00', NULL, NULL),
+ ('00000000-0000-0000-0000-00000000b044', '00000000-0000-0000-0000-000000000c04',
+ '00000000-0000-0000-0000-000000000044', 'macro|[email protected]',
+ 'pinging <m-group-mention>{"groupAlias":"here"}</m-group-mention>',
+ '2024-01-02 13:05:00+00', '2024-01-02 13:05:00+00', NULL, NULL);
+
+-- user-c is @-mentioned in t42's root message
+INSERT INTO comms_entity_mentions (id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at) VALUES
+ ('00000000-0000-0000-0000-00000000e042', 'message', '00000000-0000-0000-0000-000000000042',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 11:00:00+00');
+
+-- @here in t43's root message and t44's reply, as sent by the client: expanded into
+-- one user mention row per channel member at send time (left-user had not left yet)
+INSERT INTO comms_entity_mentions (id, source_entity_type, source_entity_id, entity_type, entity_id, user_id, created_at) VALUES
+ ('00000000-0000-0000-0000-00000000e431', 'message', '00000000-0000-0000-0000-000000000043',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 12:00:00+00'),
+ ('00000000-0000-0000-0000-00000000e432', 'message', '00000000-0000-0000-0000-000000000043',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 12:00:00+00'),
+ ('00000000-0000-0000-0000-00000000e433', 'message', '00000000-0000-0000-0000-000000000043',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 12:00:00+00'),
+ ('00000000-0000-0000-0000-00000000e434', 'message', '00000000-0000-0000-0000-000000000043',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 12:00:00+00'),
+ ('00000000-0000-0000-0000-00000000e441', 'message', '00000000-0000-0000-0000-00000000b044',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 13:05:00+00'),
+ ('00000000-0000-0000-0000-00000000e442', 'message', '00000000-0000-0000-0000-00000000b044',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 13:05:00+00'),
+ ('00000000-0000-0000-0000-00000000e443', 'message', '00000000-0000-0000-0000-00000000b044',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 13:05:00+00'),
+ ('00000000-0000-0000-0000-00000000e444', 'message', '00000000-0000-0000-0000-00000000b044',
+ 'user', 'macro|[email protected]', NULL, '2024-01-02 13:05:00+00');
+
-- entity mentions (used by attachment-references tests)
-- doc-mention is mentioned inside msg3 (a message source → channel reference, gated by participation)
-- doc-generic is mentioned by a non-message source (doc → generic reference, not gated)
diff --git a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
index 245962fdda..b59ef6441b 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo.rs
@@ -854,6 +854,9 @@ fn push_channel_thread_filter_expr(
builder.push("m.sender_id = ");
builder.push_bind(sender.as_ref().to_string());
}
+ Expr::Literal(ChannelThreadLiteral::Participant(participant)) => {
+ push_channel_thread_participant_filter_expr(builder, participant);
+ }
Expr::Literal(ChannelThreadLiteral::NotificationDone(done)) => {
push_channel_thread_notification_filter_expr(
builder,
@@ -879,6 +882,64 @@ fn push_channel_thread_filter_expr(
}
}
+/// A user is a participant of a thread when they are still an active member of the
+/// channel AND they sent the root message or any reply, or were @-mentioned anywhere
+/// in the thread.
+///
+/// Group mentions (e.g. @here) are covered indirectly: the client expands them into
+/// per-user mention rows for every channel member at send time, so they match the
+/// mention arm below. That expansion is a send-time snapshot made by a single
+/// producer (the web client) — members who join the channel later, and messages from
+/// producers that don't expand (bots, webhooks), are missed. TODO: persist group
+/// mentions as `entity_type = 'group'` rows in `comms_entity_mentions` (parsed
+/// server-side from the `<m-group-mention>` content tag, see `mention_utils`) and
+/// add an arm here treating every active channel member as a participant of threads
+/// containing one.
+#[cfg(feature = "list")]
+fn push_channel_thread_participant_filter_expr(
+ builder: &mut QueryBuilder<'static, Postgres>,
+ participant: &MacroUserIdStr<'_>,
+) {
+ let participant = participant.as_ref().to_string();
+ builder.push(
+ r#"(EXISTS (
+ SELECT 1
+ FROM comms_channel_participants pcp
+ WHERE pcp.channel_id = m.channel_id
+ AND pcp.user_id = "#,
+ );
+ builder.push_bind(participant.clone());
+ builder.push(
+ r#"
+ AND pcp.left_at IS NULL
+ ) AND EXISTS (
+ SELECT 1
+ FROM comms_messages tm
+ WHERE (tm.id = m.id OR tm.thread_id = m.id)
+ AND tm.deleted_at IS NULL
+ AND (
+ tm.sender_id = "#,
+ );
+ builder.push_bind(participant.clone());
+ builder.push(
+ r#"
+ OR EXISTS (
+ SELECT 1
+ FROM comms_entity_mentions em
+ WHERE em.source_entity_type = 'message'
+ AND em.source_entity_id = tm.id::text
+ AND em.entity_type = 'user'
+ AND em.entity_id = "#,
+ );
+ builder.push_bind(participant);
+ builder.push(
+ r#"
+ )
+ )
+ ))"#,
+ );
+}
+
#[cfg(feature = "list")]
fn push_channel_thread_notification_filter_expr(
builder: &mut QueryBuilder<'static, Postgres>,
diff --git a/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs b/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
index 9c92ade9e3..838107a1c7 100644
--- a/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
+++ b/rust/cloud-storage/channels/src/outbound/pg_channels_repo/tests.rs
@@ -39,8 +39,15 @@ const REPLY4: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000b005);
const DELETED_MSG_ATTACHMENT: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_00000000a004);
const USER_A: &str = "macro|[email protected]";
const USER_B: &str = "macro|[email protected]";
+const USER_C: &str = "macro|[email protected]";
const NON_MEMBER: &str = "macro|[email protected]";
+const USER_E: &str = "macro|[email protected]";
const LEFT_USER: &str = "macro|[email protected]";
+// Participant-filter fixture threads in ch4 (see channels_repo.sql).
+const T41: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000041);
+const T42: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000042);
+const T43: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000043);
+const T44: Uuid = Uuid::from_u128(0x00000000_0000_0000_0000_000000000044);
fn repo(pool: Pool<Postgres>) -> PgChannelsRepo {
PgChannelsRepo::new(pool)
@@ -366,6 +373,84 @@ async fn channel_thread_rows_filter_by_root_sender(pool: Pool<Postgres>) -> anyh
Ok(())
}
+async fn threads_matching_participant(
+ pool: Pool<Postgres>,
+ querying_user: &str,
+ participant: &str,
+) -> anyhow::Result<Vec<Uuid>> {
+ let rows = repo(pool)
+ .get_thread_messages(
+ thread_rows_request(
+ querying_user,
+ thread_filter(ChannelThreadLiteral::Participant(macro_user_id(
+ participant,
+ ))),
+ SimpleSortMethod::UpdatedAt,
+ 50,
+ )
+ .into_params(),
+ )
+ .await
+ .map_err(report_err)?;
+ Ok(rows.iter().map(|row| row.id).collect())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("channels_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn channel_thread_rows_filter_by_participant_reply_and_mention(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ // user-c replied in t41, is @-mentioned in t42, and is in the @here expansion
+ // rows on t43/t44. No ch1 threads match despite user-c being a ch1 member.
+ let parent_ids = threads_matching_participant(pool, USER_B, USER_C).await?;
+ assert_eq!(parent_ids, vec![T44, T43, T42, T41]);
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("channels_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn channel_thread_rows_filter_by_participant_group_mention(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ // user-e's only reply is soft-deleted, so they match only through the @here
+ // expansion rows: t43 (root @here) and t44 (reply @here).
+ let parent_ids = threads_matching_participant(pool, USER_B, USER_E).await?;
+ assert_eq!(parent_ids, vec![T44, T43]);
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("channels_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn channel_thread_rows_filter_by_participant_root_sender(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ // user-b rooted every ch4 thread and replied to msg1 in ch1; msg3 doesn't match
+ // because channel membership alone doesn't make a participant.
+ let parent_ids = threads_matching_participant(pool, USER_B, USER_B).await?;
+ assert_eq!(parent_ids, vec![T44, T43, T42, T41, MSG1]);
+ Ok(())
+}
+
+#[sqlx::test(
+ fixtures(path = "../../../fixtures", scripts("channels_repo")),
+ migrator = "MACRO_DB_MIGRATIONS"
+)]
+async fn channel_thread_rows_filter_by_participant_excludes_departed_users(
+ pool: Pool<Postgres>,
+) -> anyhow::Result<()> {
+ // left-user replied in t41 and sits in the @here expansion rows on t43/t44, but
+ // they left the channel, so nothing matches.
+ let parent_ids = threads_matching_participant(pool, USER_B, LEFT_USER).await?;
+ assert!(parent_ids.is_empty());
+ Ok(())
+}
+
#[sqlx::test(
fixtures(path = "../../../fixtures", scripts("channels_repo")),
migrator = "MACRO_DB_MIGRATIONS"
diff --git a/rust/cloud-storage/graphql_soup/src/inputs.rs b/rust/cloud-storage/graphql_soup/src/inputs.rs
index d85a9734f0..690222915b 100644
--- a/rust/cloud-storage/graphql_soup/src/inputs.rs
+++ b/rust/cloud-storage/graphql_soup/src/inputs.rs
@@ -632,6 +632,7 @@ enum GraphqlChannelThreadLiteral {
ThreadId(ID),
ChannelId(ID),
RootSender(String),
+ Participant(String),
NotificationDone(bool),
NotificationSeen(bool),
}
@@ -644,6 +645,9 @@ impl IntoFilterExpr<ChannelThreadLiteral> for GraphqlChannelThreadLiteral {
Self::RootSender(sender) => {
ChannelThreadLiteral::RootSender(parse_macro_user_id(sender, "rootSender")?)
}
+ Self::Participant(participant) => {
+ ChannelThreadLiteral::Participant(parse_macro_user_id(participant, "participant")?)
+ }
Self::NotificationDone(done) => ChannelThreadLiteral::NotificationDone(done),
Self::NotificationSeen(seen) => ChannelThreadLiteral::NotificationSeen(seen),
};
diff --git a/rust/cloud-storage/item_filters/src/ast/channel.rs b/rust/cloud-storage/item_filters/src/ast/channel.rs
index 21c10169a6..5fed3631e6 100644
--- a/rust/cloud-storage/item_filters/src/ast/channel.rs
+++ b/rust/cloud-storage/item_filters/src/ast/channel.rs
@@ -150,6 +150,10 @@ pub enum ChannelThreadLiteral {
ChannelId(Uuid),
/// The sender of the root thread message must be the included user.
RootSender(MacroUserIdStr<'static>),
+ /// The included user must be a participant of the thread: the root message sender,
+ /// anyone who replied in the thread, or anyone @-mentioned in the thread (group
+ /// mentions like @here count through their per-user expansion at send time).
+ Participant(MacroUserIdStr<'static>),
/// this node value filters by notification done state for the thread notification.
NotificationDone(bool),
/// this node value filters by notification seen state for the thread notification.
@@ -166,6 +170,7 @@ impl ExpandFrame<ChannelThreadLiteral> for ChannelThreadFilters {
thread_ids,
channel_ids,
root_sender_ids,
+ participant_ids,
} = filter_request;
let thread_ids = thread_ids
@@ -183,7 +188,12 @@ impl ExpandFrame<ChannelThreadLiteral> for ChannelThreadFilters {
.map(|s| MacroUserIdStr::parse_from_str(s).map(CowLike::into_owned))
.try_expand(|r| r.map(ChannelThreadLiteral::RootSender), Expr::or)?;
- Ok([thread_ids, channel_ids, root_sender_ids]
+ let participant_ids = participant_ids
+ .iter()
+ .map(|s| MacroUserIdStr::parse_from_str(s).map(CowLike::into_owned))
+ .try_expand(|r| r.map(ChannelThreadLiteral::Participant), Expr::or)?;
+
+ Ok([thread_ids, channel_ids, root_sender_ids, participant_ids]
.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 082b4fef93..b17750e3f1 100644
--- a/rust/cloud-storage/item_filters/src/ast/tests.rs
+++ b/rust/cloud-storage/item_filters/src/ast/tests.rs
@@ -344,6 +344,7 @@ fn it_expands_channel_thread_filters() {
thread_ids: vec![thread_id.to_string()],
channel_ids: vec![channel_id.to_string()],
root_sender_ids: vec!["macro|[email protected]".to_string()],
+ participant_ids: vec!["macro|[email protected]".to_string()],
},
..Default::default()
};
@@ -391,6 +392,35 @@ fn it_expands_single_channel_thread_id() {
assert_eq!(json, exp);
}
+#[test]
+fn it_expands_single_channel_thread_participant() {
+ let f = EntityFilters {
+ channel_thread_filters: crate::ChannelThreadFilters {
+ participant_ids: vec!["macro|[email protected]".to_string()],
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+
+ let ast = Arc::into_inner(
+ EntityFilterAst::new_from_filters(f)
+ .unwrap()
+ .unwrap()
+ .channel_thread_filter
+ .unwrap(),
+ )
+ .unwrap();
+
+ let json = serde_json::to_value(ast).unwrap();
+ let exp = json!({
+ "l": {
+ "Participant": "macro|[email protected]"
+ }
+ });
+
+ assert_eq!(json, exp);
+}
+
#[test]
fn it_expands_document_notification_filters() {
let f = EntityFilters {
diff --git a/rust/cloud-storage/item_filters/src/lib.rs b/rust/cloud-storage/item_filters/src/lib.rs
index 2f82f5e601..461ef8cf7c 100644
--- a/rust/cloud-storage/item_filters/src/lib.rs
+++ b/rust/cloud-storage/item_filters/src/lib.rs
@@ -487,6 +487,13 @@ pub struct ChannelThreadFilters {
/// Sender IDs for the root thread message. Empty to include all root senders.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub root_sender_ids: Vec<String>,
+
+ /// Thread participant user IDs. A participant is the root message sender, anyone
+ /// who replied in the thread, or anyone @-mentioned in the thread (group mentions
+ /// like @here count through their per-user expansion at send time). Empty to
+ /// include threads regardless of participants.
+ #[serde(default, skip_serializing_if = "Vec::is_empty")]
+ pub participant_ids: Vec<String>,
}
impl IsEmpty for ChannelThreadFilters {
@@ -495,8 +502,12 @@ impl IsEmpty for ChannelThreadFilters {
thread_ids,
channel_ids,
root_sender_ids,
+ participant_ids,
} = self;
- thread_ids.is_empty() && channel_ids.is_empty() && root_sender_ids.is_empty()
+ thread_ids.is_empty()
+ && channel_ids.is_empty()
+ && root_sender_ids.is_empty()
+ && participant_ids.is_empty()
}
}
diff --git a/rust/cloud-storage/schema.graphql b/rust/cloud-storage/schema.graphql
index dff716217a..568ec48f63 100644
--- a/rust/cloud-storage/schema.graphql
+++ b/rust/cloud-storage/schema.graphql
@@ -65,6 +65,7 @@ input GraphqlChannelThreadLiteral @oneOf {
threadId: ID
channelId: ID
rootSender: String
+ participant: String
notificationDone: Boolean
notificationSeen: Boolean
}