Skip to content

Commit f182ff4

Browse files
authored
feat: subfolder routing for auto-send users in ingest processor
1 parent 32793cb commit f182ff4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

scripts/ingest_processor.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,26 @@ def trigger_auto_send_if_enabled(self, book_title: str | None = None, book_path:
11761176
""")
11771177
auto_send_users = cur.fetchall()
11781178

1179+
# Subfolder routing: if the file was ingested from a subfolder,
1180+
# only send to the user whose name matches that subfolder.
1181+
target_username = None
1182+
try:
1183+
relative = os.path.relpath(self.filepath, self.ingest_folder)
1184+
parts = relative.split(os.sep)
1185+
if len(parts) > 1:
1186+
target_username = parts[0]
1187+
except (ValueError, TypeError):
1188+
pass
1189+
1190+
if target_username:
1191+
auto_send_users = [
1192+
u for u in auto_send_users
1193+
if u[1].lower() == target_username.lower()
1194+
]
1195+
if not auto_send_users:
1196+
print(f"[ingest-processor] No CWA user matches subfolder '{target_username}', skipping auto-send", flush=True)
1197+
return
1198+
11791199
if not auto_send_users:
11801200
print(f"[ingest-processor] No users with auto-send enabled found", flush=True)
11811201
return

0 commit comments

Comments
 (0)