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.

fix(convert): notify DOCX uploads with mixed-case extensions (#5594)

hari43eb0db86298
diff --git a/services/convert_service/src/process/convert.rs b/services/convert_service/src/process/convert.rs
index f09f928f82..74eb7b7a18 100644
--- a/services/convert_service/src/process/convert.rs
+++ b/services/convert_service/src/process/convert.rs
@@ -16,6 +16,10 @@ use crate::{
static MAX_WAIT_TIME_SECONDS: u64 = 30;
+pub(super) fn is_docx_key(key: &str) -> bool {
+ key.to_ascii_lowercase().ends_with(".docx")
+}
+
/// Processes a message from the convert queue
/// Returns the job id and the convert queue message
#[tracing::instrument(skip(worker, s3_client, lambda_client, message), fields(message_id = message.message_id))]
@@ -69,7 +73,7 @@ pub async fn process_message(
match result {
Ok(_) => {
- if req.from_key.ends_with(".docx") {
+ if is_docx_key(&req.from_key) {
tracing::trace!("sending success message to lambda");
lambda_client
.invoke_event(
@@ -97,7 +101,7 @@ pub async fn process_message(
}
}
Err(e) => {
- if req.from_key.ends_with(".docx") {
+ if is_docx_key(&req.from_key) {
tracing::trace!("sending failure message to lambda");
lambda_client
.invoke_event(
diff --git a/services/convert_service/src/process/mod.rs b/services/convert_service/src/process/mod.rs
index 338c0b9774..28f1b900b3 100644
--- a/services/convert_service/src/process/mod.rs
+++ b/services/convert_service/src/process/mod.rs
@@ -1,2 +1,5 @@
mod convert;
pub mod runner;
+
+#[cfg(test)]
+mod test;
diff --git a/services/convert_service/src/process/test.rs b/services/convert_service/src/process/test.rs
new file mode 100644
index 0000000000..41e9e51df7
--- /dev/null
+++ b/services/convert_service/src/process/test.rs
@@ -0,0 +1,13 @@
+use super::convert::is_docx_key;
+
+#[test]
+fn docx_detection_accepts_mixed_case_extensions() {
+ assert!(is_docx_key("uploads/report.DOCX"));
+ assert!(is_docx_key("uploads/report.DoCx"));
+}
+
+#[test]
+fn docx_detection_requires_the_final_extension() {
+ assert!(!is_docx_key("uploads/report.docx.tmp"));
+ assert!(!is_docx_key("uploads/docx"));
+}