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(sps): add deletion_filter to search backfill requests (#3080)

gbirman8cadeb092dee
diff --git a/rust/cloud-storage/.sqlx/query-b4610bd3a0c3e13755b2f9500f9ee6c70139ba5411aae2fe0bb67040ff4060ba.json b/rust/cloud-storage/.sqlx/query-14291546e09d0832632e223b7472be044d62d501a10564bc46a13e408415fe5b.json
similarity index 73%
rename from rust/cloud-storage/.sqlx/query-b4610bd3a0c3e13755b2f9500f9ee6c70139ba5411aae2fe0bb67040ff4060ba.json
rename to rust/cloud-storage/.sqlx/query-14291546e09d0832632e223b7472be044d62d501a10564bc46a13e408415fe5b.json
index f0901e8538..36f32f38a6 100644
--- a/rust/cloud-storage/.sqlx/query-b4610bd3a0c3e13755b2f9500f9ee6c70139ba5411aae2fe0bb67040ff4060ba.json
+++ b/rust/cloud-storage/.sqlx/query-14291546e09d0832632e223b7472be044d62d501a10564bc46a13e408415fe5b.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n WHERE\n c.\"userId\" = ANY($1)\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $2\n OFFSET $3\n ",
+ "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n WHERE\n c.\"userId\" = ANY($1)\n AND (\n $4::bool IS NULL\n OR ($4 AND c.\"deletedAt\" IS NOT NULL)\n OR (NOT $4 AND c.\"deletedAt\" IS NULL)\n )\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $2\n OFFSET $3\n ",
"describe": {
"columns": [
{
@@ -33,7 +33,8 @@
"Left": [
"TextArray",
"Int8",
- "Int8"
+ "Int8",
+ "Bool"
]
},
"nullable": [
@@ -44,5 +45,5 @@
false
]
},
- "hash": "b4610bd3a0c3e13755b2f9500f9ee6c70139ba5411aae2fe0bb67040ff4060ba"
+ "hash": "14291546e09d0832632e223b7472be044d62d501a10564bc46a13e408415fe5b"
}
diff --git a/rust/cloud-storage/.sqlx/query-7a648c2b6fb238695165051b64883dbc7d0e3fe4ecf4e65943e6c3c897261799.json b/rust/cloud-storage/.sqlx/query-2f26d3b3e0337d1b7b7c31345c0cde73657c5fc5e53fd86a8a2eb14ad063af2c.json
similarity index 54%
rename from rust/cloud-storage/.sqlx/query-7a648c2b6fb238695165051b64883dbc7d0e3fe4ecf4e65943e6c3c897261799.json
rename to rust/cloud-storage/.sqlx/query-2f26d3b3e0337d1b7b7c31345c0cde73657c5fc5e53fd86a8a2eb14ad063af2c.json
index b7303fb33f..d3ca62a73c 100644
--- a/rust/cloud-storage/.sqlx/query-7a648c2b6fb238695165051b64883dbc7d0e3fe4ecf4e65943e6c3c897261799.json
+++ b/rust/cloud-storage/.sqlx/query-2f26d3b3e0337d1b7b7c31345c0cde73657c5fc5e53fd86a8a2eb14ad063af2c.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n channel_id,\n id\n FROM comms_messages\n ORDER BY created_at ASC\n LIMIT $1\n OFFSET $2\n ",
+ "query": "\n SELECT\n channel_id,\n id\n FROM comms_messages\n WHERE\n $3::bool IS NULL\n OR ($3 AND deleted_at IS NOT NULL)\n OR (NOT $3 AND deleted_at IS NULL)\n ORDER BY created_at ASC\n LIMIT $1\n OFFSET $2\n ",
"describe": {
"columns": [
{
@@ -17,7 +17,8 @@
"parameters": {
"Left": [
"Int8",
- "Int8"
+ "Int8",
+ "Bool"
]
},
"nullable": [
@@ -25,5 +26,5 @@
false
]
},
- "hash": "7a648c2b6fb238695165051b64883dbc7d0e3fe4ecf4e65943e6c3c897261799"
+ "hash": "2f26d3b3e0337d1b7b7c31345c0cde73657c5fc5e53fd86a8a2eb14ad063af2c"
}
diff --git a/rust/cloud-storage/.sqlx/query-13a3a2c05506fe36d0420c3ed6eb711ece07b50c77690ce7ef2336c9390896d4.json b/rust/cloud-storage/.sqlx/query-33d8d28ce312d4a08adb044b24dfb86936cbb07a9021854308a919bc6e363ec8.json
similarity index 73%
rename from rust/cloud-storage/.sqlx/query-13a3a2c05506fe36d0420c3ed6eb711ece07b50c77690ce7ef2336c9390896d4.json
rename to rust/cloud-storage/.sqlx/query-33d8d28ce312d4a08adb044b24dfb86936cbb07a9021854308a919bc6e363ec8.json
index 33afb88352..5efac54453 100644
--- a/rust/cloud-storage/.sqlx/query-13a3a2c05506fe36d0420c3ed6eb711ece07b50c77690ce7ef2336c9390896d4.json
+++ b/rust/cloud-storage/.sqlx/query-33d8d28ce312d4a08adb044b24dfb86936cbb07a9021854308a919bc6e363ec8.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n WHERE\n m.\"chatId\" = ANY($1)\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $2\n OFFSET $3\n ",
+ "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n WHERE\n m.\"chatId\" = ANY($1)\n AND (\n $4::bool IS NULL\n OR ($4 AND c.\"deletedAt\" IS NOT NULL)\n OR (NOT $4 AND c.\"deletedAt\" IS NULL)\n )\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $2\n OFFSET $3\n ",
"describe": {
"columns": [
{
@@ -33,7 +33,8 @@
"Left": [
"TextArray",
"Int8",
- "Int8"
+ "Int8",
+ "Bool"
]
},
"nullable": [
@@ -44,5 +45,5 @@
false
]
},
- "hash": "13a3a2c05506fe36d0420c3ed6eb711ece07b50c77690ce7ef2336c9390896d4"
+ "hash": "33d8d28ce312d4a08adb044b24dfb86936cbb07a9021854308a919bc6e363ec8"
}
diff --git a/rust/cloud-storage/.sqlx/query-ded3c77986c957d0b5edbfb5e04cb63ffd5becc08d842380dd9f89767e139a5d.json b/rust/cloud-storage/.sqlx/query-7c07eebbc4d89f86a5d9c04bcecaddeb7090d3d74ad131b9c9621373c9ccb971.json
similarity index 72%
rename from rust/cloud-storage/.sqlx/query-ded3c77986c957d0b5edbfb5e04cb63ffd5becc08d842380dd9f89767e139a5d.json
rename to rust/cloud-storage/.sqlx/query-7c07eebbc4d89f86a5d9c04bcecaddeb7090d3d74ad131b9c9621373c9ccb971.json
index 3f0dac7de0..4e2ac7e828 100644
--- a/rust/cloud-storage/.sqlx/query-ded3c77986c957d0b5edbfb5e04cb63ffd5becc08d842380dd9f89767e139a5d.json
+++ b/rust/cloud-storage/.sqlx/query-7c07eebbc4d89f86a5d9c04bcecaddeb7090d3d74ad131b9c9621373c9ccb971.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $1\n OFFSET $2\n ",
+ "query": "\n SELECT\n c.\"id\" as \"chat_id\",\n m.id as \"message_id\",\n c.\"userId\" as \"user_id\",\n c.\"createdAt\" as \"created_at\",\n c.\"updatedAt\" as \"updated_at\"\n FROM\n \"ChatMessage\" m\n JOIN\n \"Chat\" c on c.\"id\" = m.\"chatId\"\n WHERE\n $3::bool IS NULL\n OR ($3 AND c.\"deletedAt\" IS NOT NULL)\n OR (NOT $3 AND c.\"deletedAt\" IS NULL)\n ORDER BY\n m.\"createdAt\" DESC\n LIMIT $1\n OFFSET $2\n ",
"describe": {
"columns": [
{
@@ -32,7 +32,8 @@
"parameters": {
"Left": [
"Int8",
- "Int8"
+ "Int8",
+ "Bool"
]
},
"nullable": [
@@ -43,5 +44,5 @@
false
]
},
- "hash": "ded3c77986c957d0b5edbfb5e04cb63ffd5becc08d842380dd9f89767e139a5d"
+ "hash": "7c07eebbc4d89f86a5d9c04bcecaddeb7090d3d74ad131b9c9621373c9ccb971"
}
diff --git a/rust/cloud-storage/.sqlx/query-8a64d1a5859b13c18516410d4fd512dd8b1359893d3e414b18f082fb48bfd907.json b/rust/cloud-storage/.sqlx/query-800de0c6f22c73c54578e396f83b4a8f8673487c3af5b163f9bd60d7b418bda4.json
similarity index 85%
rename from rust/cloud-storage/.sqlx/query-8a64d1a5859b13c18516410d4fd512dd8b1359893d3e414b18f082fb48bfd907.json
rename to rust/cloud-storage/.sqlx/query-800de0c6f22c73c54578e396f83b4a8f8673487c3af5b163f9bd60d7b418bda4.json
index 3e3560d659..57e71652d1 100644
--- a/rust/cloud-storage/.sqlx/query-8a64d1a5859b13c18516410d4fd512dd8b1359893d3e414b18f082fb48bfd907.json
+++ b/rust/cloud-storage/.sqlx/query-800de0c6f22c73c54578e396f83b4a8f8673487c3af5b163f9bd60d7b418bda4.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.\"fileType\" as \"file_type!\",\n COALESCE(db.id, di.id, dipdf.id) as \"document_version_id!\",\n d.\"createdAt\"::timestamptz as \"created_at\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dst ON dst.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" ASC\n LIMIT 1\n ) dipdf ON d.\"fileType\" = 'pdf'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx' AND d.\"fileType\" IS DISTINCT FROM 'pdf'\n WHERE\n d.\"fileType\" IS NOT NULL\n AND ($3::text[] IS NULL OR d.\"fileType\" = ANY($3))\n AND ($4::text IS NULL OR dst.sub_type::text = $4)\n AND ($5::timestamptz IS NULL OR d.\"createdAt\" >= $5)\n AND ($6::timestamptz IS NULL OR d.\"createdAt\" < $6)\n ORDER BY d.\"createdAt\" ASC, d.id ASC\n LIMIT $1 OFFSET $2\n ",
+ "query": "\n SELECT\n d.id as document_id,\n d.owner as owner,\n d.\"fileType\" as \"file_type!\",\n COALESCE(db.id, di.id, dipdf.id) as \"document_version_id!\",\n d.\"createdAt\"::timestamptz as \"created_at\"\n FROM\n \"Document\" d\n LEFT JOIN document_sub_type dst ON dst.document_id = d.id\n LEFT JOIN LATERAL (\n SELECT\n b.id\n FROM\n \"DocumentBom\" b\n WHERE\n b.\"documentId\" = d.id\n ORDER BY\n b.\"createdAt\" DESC\n LIMIT 1\n ) db ON d.\"fileType\" = 'docx'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"updatedAt\" ASC\n LIMIT 1\n ) dipdf ON d.\"fileType\" = 'pdf'\n LEFT JOIN LATERAL (\n SELECT\n i.id\n FROM\n \"DocumentInstance\" i\n WHERE\n i.\"documentId\" = d.id\n ORDER BY\n i.\"createdAt\" DESC\n LIMIT 1\n ) di ON d.\"fileType\" IS DISTINCT FROM 'docx' AND d.\"fileType\" IS DISTINCT FROM 'pdf'\n WHERE\n d.\"fileType\" IS NOT NULL\n AND ($3::text[] IS NULL OR d.\"fileType\" = ANY($3))\n AND ($4::text IS NULL OR dst.sub_type::text = $4)\n AND ($5::timestamptz IS NULL OR d.\"createdAt\" >= $5)\n AND ($6::timestamptz IS NULL OR d.\"createdAt\" < $6)\n AND (\n $7::bool IS NULL\n OR ($7 AND d.\"deletedAt\" IS NOT NULL)\n OR (NOT $7 AND d.\"deletedAt\" IS NULL)\n )\n ORDER BY d.\"createdAt\" ASC, d.id ASC\n LIMIT $1 OFFSET $2\n ",
"describe": {
"columns": [
{
@@ -36,7 +36,8 @@
"TextArray",
"Text",
"Timestamptz",
- "Timestamptz"
+ "Timestamptz",
+ "Bool"
]
},
"nullable": [
@@ -47,5 +48,5 @@
null
]
},
- "hash": "8a64d1a5859b13c18516410d4fd512dd8b1359893d3e414b18f082fb48bfd907"
+ "hash": "800de0c6f22c73c54578e396f83b4a8f8673487c3af5b163f9bd60d7b418bda4"
}
diff --git a/rust/cloud-storage/comms_db_client/src/messages/get_messages.rs b/rust/cloud-storage/comms_db_client/src/messages/get_messages.rs
index cfea08e110..b9e96926c1 100644
--- a/rust/cloud-storage/comms_db_client/src/messages/get_messages.rs
+++ b/rust/cloud-storage/comms_db_client/src/messages/get_messages.rs
@@ -67,6 +67,7 @@ pub async fn get_channel_messages(
db: &Pool<Postgres>,
limit: i64,
offset: i64,
+ only_deleted: Option<bool>,
) -> Result<Vec<(Uuid, Uuid)>> {
let messages = sqlx::query!(
r#"
@@ -74,12 +75,17 @@ pub async fn get_channel_messages(
channel_id,
id
FROM comms_messages
+ WHERE
+ $3::bool IS NULL
+ OR ($3 AND deleted_at IS NOT NULL)
+ OR (NOT $3 AND deleted_at IS NULL)
ORDER BY created_at ASC
LIMIT $1
OFFSET $2
"#,
limit,
- offset
+ offset,
+ only_deleted,
)
.map(|row| (row.channel_id, row.id))
.fetch_all(db)
diff --git a/rust/cloud-storage/macro_db_client/src/chat/get.rs b/rust/cloud-storage/macro_db_client/src/chat/get.rs
index 4cafe618f1..c571bdcb84 100644
--- a/rust/cloud-storage/macro_db_client/src/chat/get.rs
+++ b/rust/cloud-storage/macro_db_client/src/chat/get.rs
@@ -20,13 +20,21 @@ pub async fn get_chat_messages_for_search_backfill(
offset: i64,
chat_ids: Option<&Vec<String>>,
user_ids: Option<&Vec<String>>,
+ only_deleted: Option<bool>,
) -> anyhow::Result<Vec<ChatSearchBackfill>> {
if let Some(chat_ids) = chat_ids {
if chat_ids.is_empty() {
return Ok(vec![]);
}
- return get_chat_messages_for_search_backfill_chat_ids(db, limit, offset, chat_ids).await;
+ return get_chat_messages_for_search_backfill_chat_ids(
+ db,
+ limit,
+ offset,
+ chat_ids,
+ only_deleted,
+ )
+ .await;
}
if let Some(user_ids) = user_ids {
@@ -34,7 +42,14 @@ pub async fn get_chat_messages_for_search_backfill(
return Ok(vec![]);
}
- return get_chat_messages_for_search_backfill_user_ids(db, limit, offset, user_ids).await;
+ return get_chat_messages_for_search_backfill_user_ids(
+ db,
+ limit,
+ offset,
+ user_ids,
+ only_deleted,
+ )
+ .await;
}
let result = sqlx::query!(
@@ -49,13 +64,18 @@ pub async fn get_chat_messages_for_search_backfill(
"ChatMessage" m
JOIN
"Chat" c on c."id" = m."chatId"
+ WHERE
+ $3::bool IS NULL
+ OR ($3 AND c."deletedAt" IS NOT NULL)
+ OR (NOT $3 AND c."deletedAt" IS NULL)
ORDER BY
m."createdAt" DESC
LIMIT $1
OFFSET $2
"#,
limit,
- offset
+ offset,
+ only_deleted,
)
.map(|row| ChatSearchBackfill {
chat_id: row.chat_id,
@@ -76,6 +96,7 @@ async fn get_chat_messages_for_search_backfill_chat_ids(
limit: i64,
offset: i64,
chat_ids: &[String],
+ only_deleted: Option<bool>,
) -> anyhow::Result<Vec<ChatSearchBackfill>> {
let result = sqlx::query!(
r#"
@@ -91,6 +112,11 @@ async fn get_chat_messages_for_search_backfill_chat_ids(
"Chat" c on c."id" = m."chatId"
WHERE
m."chatId" = ANY($1)
+ AND (
+ $4::bool IS NULL
+ OR ($4 AND c."deletedAt" IS NOT NULL)
+ OR (NOT $4 AND c."deletedAt" IS NULL)
+ )
ORDER BY
m."createdAt" DESC
LIMIT $2
@@ -98,7 +124,8 @@ async fn get_chat_messages_for_search_backfill_chat_ids(
"#,
chat_ids,
limit,
- offset
+ offset,
+ only_deleted,
)
.map(|row| ChatSearchBackfill {
chat_id: row.chat_id,
@@ -119,6 +146,7 @@ async fn get_chat_messages_for_search_backfill_user_ids(
limit: i64,
offset: i64,
user_ids: &[String],
+ only_deleted: Option<bool>,
) -> anyhow::Result<Vec<ChatSearchBackfill>> {
let result = sqlx::query!(
r#"
@@ -134,6 +162,11 @@ async fn get_chat_messages_for_search_backfill_user_ids(
"Chat" c on c."id" = m."chatId"
WHERE
c."userId" = ANY($1)
+ AND (
+ $4::bool IS NULL
+ OR ($4 AND c."deletedAt" IS NOT NULL)
+ OR (NOT $4 AND c."deletedAt" IS NULL)
+ )
ORDER BY
m."createdAt" DESC
LIMIT $2
@@ -141,7 +174,8 @@ async fn get_chat_messages_for_search_backfill_user_ids(
"#,
user_ids,
limit,
- offset
+ offset,
+ only_deleted,
)
.map(|row| ChatSearchBackfill {
chat_id: row.chat_id,
diff --git a/rust/cloud-storage/macro_db_client/src/document/get_documents_search.rs b/rust/cloud-storage/macro_db_client/src/document/get_documents_search.rs
index 3a8a17e676..bb3d66cd64 100644
--- a/rust/cloud-storage/macro_db_client/src/document/get_documents_search.rs
+++ b/rust/cloud-storage/macro_db_client/src/document/get_documents_search.rs
@@ -8,6 +8,7 @@ use model::document::{BackfillSearchDocumentInformation, FileType};
/// Used to get all documents in a paginated format
/// This will get the latest version of the document for non-pdf documents
/// For pdf documents, this will get the oldest version of the document
+#[allow(clippy::too_many_arguments)]
#[tracing::instrument(skip(db))]
pub async fn get_documents_for_search(
db: &Pool<Postgres>,
@@ -17,6 +18,7 @@ pub async fn get_documents_for_search(
sub_type: &Option<String>,
created_after: &Option<DateTime<Utc>>,
created_before: &Option<DateTime<Utc>>,
+ only_deleted: Option<bool>,
) -> anyhow::Result<Vec<BackfillSearchDocumentInformation>> {
let result = sqlx::query!(
r#"
@@ -68,6 +70,11 @@ pub async fn get_documents_for_search(
AND ($4::text IS NULL OR dst.sub_type::text = $4)
AND ($5::timestamptz IS NULL OR d."createdAt" >= $5)
AND ($6::timestamptz IS NULL OR d."createdAt" < $6)
+ AND (
+ $7::bool IS NULL
+ OR ($7 AND d."deletedAt" IS NOT NULL)
+ OR (NOT $7 AND d."deletedAt" IS NULL)
+ )
ORDER BY d."createdAt" ASC, d.id ASC
LIMIT $1 OFFSET $2
"#,
@@ -77,6 +84,7 @@ pub async fn get_documents_for_search(
sub_type.as_deref() as Option<&str>,
*created_after as Option<DateTime<Utc>>,
*created_before as Option<DateTime<Utc>>,
+ only_deleted,
)
.try_map(|row| {
Ok(BackfillSearchDocumentInformation {
diff --git a/rust/cloud-storage/search_processing_service/src/domain/models.rs b/rust/cloud-storage/search_processing_service/src/domain/models.rs
index 9585c67c4f..6d29eee2d1 100644
--- a/rust/cloud-storage/search_processing_service/src/domain/models.rs
+++ b/rust/cloud-storage/search_processing_service/src/domain/models.rs
@@ -39,6 +39,25 @@ pub enum BackfillError {
Publish(#[source] anyhow::Error),
}
+#[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq)]
+#[serde(rename_all = "snake_case")]
+pub enum DeletionFilter {
+ #[default]
+ Any,
+ Active,
+ Deleted,
+}
+
+impl DeletionFilter {
+ pub fn as_only_deleted(self) -> Option<bool> {
+ match self {
+ DeletionFilter::Any => None,
+ DeletionFilter::Active => Some(false),
+ DeletionFilter::Deleted => Some(true),
+ }
+ }
+}
+
/// Call-record backfill filter. Empty `call_ids` means "all archived calls".
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
@@ -53,13 +72,16 @@ pub struct CallBackfillRequest {
pub struct ChatBackfillRequest {
pub chat_ids: Vec<String>,
pub user_ids: Vec<String>,
+ pub deletion_filter: DeletionFilter,
}
/// Channel-message backfill filter. No scoping knobs yet — reserved so adding
/// one later doesn't break the request shape.
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
-pub struct ChannelBackfillRequest {}
+pub struct ChannelBackfillRequest {
+ pub deletion_filter: DeletionFilter,
+}
/// Document backfill filter. Every field is additive — all `None` means "every
/// document this service knows about".
@@ -70,6 +92,7 @@ pub struct DocumentBackfillRequest {
pub sub_type: Option<String>,
pub created_after: Option<DateTime<Utc>>,
pub created_before: Option<DateTime<Utc>>,
+ pub deletion_filter: DeletionFilter,
}
/// Email-thread backfill filter.
diff --git a/rust/cloud-storage/search_processing_service/src/outbound/source.rs b/rust/cloud-storage/search_processing_service/src/outbound/source.rs
index 06b263e0b2..aa8b680b16 100644
--- a/rust/cloud-storage/search_processing_service/src/outbound/source.rs
+++ b/rust/cloud-storage/search_processing_service/src/outbound/source.rs
@@ -100,6 +100,7 @@ impl BackfillSource for PgBackfillSource {
offset as i64,
chat_ids,
user_ids,
+ req.deletion_filter.as_only_deleted(),
)
.await
.map_err(BackfillError::Source)?;
@@ -126,13 +127,14 @@ impl BackfillSource for PgBackfillSource {
async fn fetch_channels(
&self,
- _req: &ChannelBackfillRequest,
+ req: &ChannelBackfillRequest,
offset: usize,
) -> Result<SourcePage, BackfillError> {
let batch = comms_db_client::messages::get_messages::get_channel_messages(
&self.db,
self.page_sizes.channels as i64,
offset as i64,
+ req.deletion_filter.as_only_deleted(),
)
.await
.map_err(BackfillError::Source)?;
@@ -167,6 +169,7 @@ impl BackfillSource for PgBackfillSource {
&req.sub_type,
&req.created_after,
&req.created_before,
+ req.deletion_filter.as_only_deleted(),
)
.await
.map_err(BackfillError::Source)?;