feat: auto-assign new Immich albums via keyword rules

Auto-assignment rules were only applied when an admin clicked
"Regeln jetzt anwenden". New albums created in Immich therefore
never reached editorials automatically.

- applyAllRules() syncs every active editorial's keywords against the
  full album list in one pass and grants matches as system actor
- in-process scheduler (src/instrumentation.ts) runs the sync every
  AUTO_RULE_SYNC_INTERVAL_SECONDS (default 120s)
- POST /api/cron/album-sync allows external triggers via CRON_SECRET
- overlapping sync runs coalesce to avoid duplicate grants/emails
This commit is contained in:
Leon Tonhäuser committed 2026-08-25 01:05:04 +02:00
1 parent a3dc56778d
commit dd60fd6ee6
14 files changed
+613 -36

No files matched your search

+10
View File
@@ -20,8 +20,18 @@ const serverEnvSchema = z.object({
.url()
.default("https://leon-tonhaeuser.de/datenschutz"),
LEGAL_TERMS_URL: z.url().default("https://leon-tonhaeuser.de/agb"),
/** Bearer token for the /api/cron/album-sync endpoint; unset disables it. */
CRON_SECRET: emptyToUndefined(z.string().min(16)).optional(),
/** How often the album auto-rule sync runs, in seconds (min 30). */
AUTO_RULE_SYNC_INTERVAL_SECONDS: emptyToUndefined(z.coerce.number().int().min(30)).optional(),
});
// Docker Compose passes undeclared vars as empty strings; treat those as
// unset so optional settings stay optional.
function emptyToUndefined<T extends z.ZodType>(schema: T) {
return z.preprocess((value) => (value === "" ? undefined : value), schema);
}
export type ServerEnv = z.infer<typeof serverEnvSchema>;
export function parseServerEnv(input: NodeJS.ProcessEnv): ServerEnv;