7 Commits

Author SHA1 Message Date
s4luorth
a882bf37f5 C4-Kuvert (quer) als Render-Format
All checks were successful
Build & Deploy / deploy (push) Successful in 11s
Neues Umschlag-Format c4 (324x229 mm, Querformat-Beschriftung, maschinenseitig
quer eingelegt) in den Backend-Defaults + ENVELOPE_FORMAT-Map. Absender oben
links, Empfaenger unten rechts (bestehende Kuvert-Logik, proportional).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-30 11:31:25 +02:00
s4luorth
7930c177ee A6-Greifrand an die lange Seite + A5/DIN-lang (Volltext)
All checks were successful
Build & Deploy / deploy (push) Successful in 15s
A6: Greifrand liegt jetzt IMMER an der langen (148mm) Seite - A6 quer (a6l)
unten (neuer margin_bottom-Mechanismus haelt untere Zeilen frei, 11->10),
A6 hoch (a6p) rechts. Neue Funktion getEffectiveLineLimit() deckelt das
Zeilenlimit zusaetzlich geometrisch; A4/A5 unberuehrt.

A5 (a5p 148x210, a5l 210x148) und DIN lang komplett beschrieben
(dinlang_karte 210x105) als Brief-Fallback-Formate ergaenzt.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-30 10:53:19 +02:00
s4luorth
c73109b8ca FTP: Passwort base64-sicher via SKRIFT_FTP_PASSWORD_B64
All checks were successful
Build & Deploy / deploy (push) Successful in 9s
Passwoerter mit Sonderzeichen ($ # @) werden in .env-Dateien verstuemmelt
(bestaetigt durch falsche pw_len -> 530 Login incorrect). Neue Variable
SKRIFT_FTP_PASSWORD_B64 nimmt den base64-kodierten Wert (env-sicher) und
wird dekodiert; hat Vorrang vor SKRIFT_FTP_PASSWORD.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-28 11:33:33 +02:00
s4luorth
2c2282e05a FTP-Diagnose: user + Passwort-Laenge beim Login loggen (kein Leak)
All checks were successful
Build & Deploy / deploy (push) Successful in 11s
Bei "530 Login incorrect" trotz FileZilla-OK zeigt pw_len im Backend-Log,
ob das Passwort im .env die falsche Laenge hat (Quotes/CRLF/Leerzeichen).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-28 10:59:50 +02:00
s4luorth
3bef26b332 FTP: Zugangsdaten robust einlesen (Quotes/CRLF entfernen)
All checks were successful
Build & Deploy / deploy (push) Successful in 12s
Gegen "530 Login incorrect" trotz korrekter Daten (FileZilla ok): host/
user/password werden von versehentlich umschliessenden Anfuehrungszeichen
und CR/LF bereinigt (haeufige .env-/docker-env_file-Fallen unter Windows).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-28 10:54:07 +02:00
s4luorth
94751c12ff Batch-Buendelung: gezielte Auswahl per ids (FTP-Upload aus dem Board)
All checks were successful
Build & Deploy / deploy (push) Successful in 11s
/api/batch/build akzeptiert jetzt ids:[...] und buendelt genau diese
Uebermittlungen (je Zugang, xlsx + Sammel-PDF + FTP). Der Board-Knopf
"Per FTP hochladen" wirkt damit auf die Auswahl.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-28 10:23:58 +02:00
s4luorth
a6eb41f996 Batch: FTP-Cron standardmaessig aus (Standardweg = Uebernahme in Produktion)
All checks were successful
Build & Deploy / deploy (push) Successful in 16s
Der taegliche 03:00-FTP-Buendel-Lauf laeuft nur noch, wenn
SKRIFT_BATCH_FTP_CRON=true gesetzt ist. Ohne Flag kein automatischer
FTP-Upload; Uebermittlungen laufen ueber die Uebernahme ins Board.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-28 10:15:01 +02:00
7 changed files with 85 additions and 35 deletions

View File

@@ -69,6 +69,9 @@ async function buildMergedPdf(subs) {
async function ftpUpload(dateien) { async function ftpUpload(dateien) {
const { host, port, user, password, secure, rejectUnauthorized } = config.ftp; const { host, port, user, password, secure, rejectUnauthorized } = config.ftp;
if (!host || !user) throw new Error('FTP nicht konfiguriert (SKRIFT_FTP_HOST/USER fehlen).'); if (!host || !user) throw new Error('FTP nicht konfiguriert (SKRIFT_FTP_HOST/USER fehlen).');
// Diagnose ohne Passwort-Leak: bei „530 Login incorrect" trotz korrekter Daten
// ist meist die Passwort-Laenge im .env falsch (Quotes/CRLF/Leerzeichen).
console.log(`[batch] FTP-Login: host=${host}:${port} user="${user}" pw_len=${(password || '').length} secure=${secure}`);
const client = new ftp.Client(30000); const client = new ftp.Client(30000);
// client.ftp.verbose = true; // client.ftp.verbose = true;
try { try {
@@ -96,8 +99,8 @@ async function buendleZugang(clientId, subs, label, zeitSuffix) {
} }
/** Bündelt alle offenen Datensätze (optional nur ein Zugang), gruppiert je Zugang. */ /** Bündelt alle offenen Datensätze (optional nur ein Zugang), gruppiert je Zugang. */
async function buendleAlle({ clientId = null, label, zeitSuffix = '' }) { async function buendleAlle({ clientId = null, ids = null, label, zeitSuffix = '' }) {
const alle = await fetchBatchPending(clientId); const alle = await fetchBatchPending(clientId, ids);
const proZugang = new Map(); const proZugang = new Map();
for (const s of alle) { for (const s of alle) {
const k = String(s.api_client); const k = String(s.api_client);
@@ -117,12 +120,13 @@ async function buendleAlle({ clientId = null, label, zeitSuffix = '' }) {
async function buildBundles(req, res) { async function buildBundles(req, res) {
try { try {
const clientId = (req.body && req.body.client_id != null && String(req.body.client_id).trim()) ? String(req.body.client_id).trim() : null; const clientId = (req.body && req.body.client_id != null && String(req.body.client_id).trim()) ? String(req.body.client_id).trim() : null;
const ids = (req.body && Array.isArray(req.body.ids) && req.body.ids.length) ? req.body.ids : null;
const label = (req.body && req.body.label) ? String(req.body.label) : berlinParts().date; const label = (req.body && req.body.label) ? String(req.body.label) : berlinParts().date;
// Manuelle Bündelung mit Uhrzeit-Suffix, damit sie den Cron-Tageslauf (nur Datum) nicht überschreibt. // Manuelle Bündelung mit Uhrzeit-Suffix, damit sie den Cron-Tageslauf (nur Datum) nicht überschreibt.
const zeitSuffix = (req.body && req.body.time_suffix !== undefined) const zeitSuffix = (req.body && req.body.time_suffix !== undefined)
? String(req.body.time_suffix) ? String(req.body.time_suffix)
: `${String(berlinParts().hour).padStart(2, '0')}${String(berlinParts().minute).padStart(2, '0')}`; : `${String(berlinParts().hour).padStart(2, '0')}${String(berlinParts().minute).padStart(2, '0')}`;
const ergebnis = await buendleAlle({ clientId, label, zeitSuffix }); const ergebnis = await buendleAlle({ clientId, ids, label, zeitSuffix });
return res.json({ ok: true, bundles: ergebnis }); return res.json({ ok: true, bundles: ergebnis });
} catch (err) { } catch (err) {
console.error('[batch] build fehlgeschlagen:', err); console.error('[batch] build fehlgeschlagen:', err);

View File

@@ -17,7 +17,7 @@ const { replacePlaceholders } = require('../../services/placeholder-service');
// Directus-Formatschlüssel → Backend-Formate // Directus-Formatschlüssel → Backend-Formate
const LETTER_FORMAT = { a4: 'a4', a6_hoch: 'a6p', a6_quer: 'a6l' }; const LETTER_FORMAT = { a4: 'a4', a6_hoch: 'a6p', a6_quer: 'a6l' };
const ENVELOPE_FORMAT = { c6: 'c6', dinlang: 'din_lang' }; const ENVELOPE_FORMAT = { c6: 'c6', dinlang: 'din_lang', c4: 'c4' };
/** Baut den Adressblock für einen Umschlag aus einer Empfängerzeile. */ /** Baut den Adressblock für einen Umschlag aus einer Empfängerzeile. */
function addressText(entry) { function addressText(entry) {

View File

@@ -59,14 +59,25 @@ module.exports = {
// Alternativer Übermittlungsweg (batch_submissions): Ziel-FTP für die täglichen // Alternativer Übermittlungsweg (batch_submissions): Ziel-FTP für die täglichen
// Bündel (xlsx + Sammel-Druck-PDF). Passwort NUR über ENV. // Bündel (xlsx + Sammel-Druck-PDF). Passwort NUR über ENV.
ftp: { // envClean entfernt versehentliche umschließende Anführungszeichen und CR/LF
host: process.env.SKRIFT_FTP_HOST || '', // (häufige .env-Fallen unter Windows/docker env_file), die sonst zu „530
// Login incorrect" führen, obwohl die Daten korrekt sind.
ftp: (() => {
const envClean = (v) => String(v || '').replace(/[\r\n]+/g, '').replace(/^(['"])([\s\S]*)\1$/, '$2');
// Passwoerter mit Sonderzeichen ($ # @ …) werden in .env-Dateien oft
// verstuemmelt ($ = Variable, # = Kommentar). Deshalb bevorzugt base64:
// SKRIFT_FTP_PASSWORD_B64 wird dekodiert und ist damit env-sicher.
const pwB64 = envClean(process.env.SKRIFT_FTP_PASSWORD_B64);
const password = pwB64 ? Buffer.from(pwB64, 'base64').toString('utf8') : envClean(process.env.SKRIFT_FTP_PASSWORD);
return {
host: envClean(process.env.SKRIFT_FTP_HOST),
port: parseInt(process.env.SKRIFT_FTP_PORT, 10) || 21, port: parseInt(process.env.SKRIFT_FTP_PORT, 10) || 21,
user: process.env.SKRIFT_FTP_USER || '', user: envClean(process.env.SKRIFT_FTP_USER),
password: process.env.SKRIFT_FTP_PASSWORD || '', password,
// explizites FTP über TLS (wie im FTP-Client eingestellt). 'false' schaltet ab. // explizites FTP über TLS (wie im FTP-Client eingestellt). 'false' schaltet ab.
secure: String(process.env.SKRIFT_FTP_SECURE || 'true').toLowerCase() !== 'false', secure: String(process.env.SKRIFT_FTP_SECURE || 'true').toLowerCase() !== 'false',
// Selbstsigniertes Zertifikat zulassen (viele FTP-Server) – auf 'false' setzen für strikte Prüfung. // Selbstsigniertes Zertifikat zulassen (viele FTP-Server) – auf 'false' setzen für strikte Prüfung.
rejectUnauthorized: String(process.env.SKRIFT_FTP_REJECT_UNAUTHORIZED || 'false').toLowerCase() === 'true', rejectUnauthorized: String(process.env.SKRIFT_FTP_REJECT_UNAUTHORIZED || 'false').toLowerCase() === 'true',
}, };
})(),
}; };

View File

@@ -6,23 +6,35 @@ const FONT_SIZE_PX = 26;
// im Speicher gehalten (stündlich / manuell aufgefrischt via applyRenderFormats). // im Speicher gehalten (stündlich / manuell aufgefrischt via applyRenderFormats).
// Ist Directus nicht erreichbar oder ein Format nicht hinterlegt, greifen die // Ist Directus nicht erreichbar oder ein Format nicht hinterlegt, greifen die
// eingebauten Defaults – die Generierung läuft also immer. // eingebauten Defaults – die Generierung läuft also immer.
const DEFAULT_LINE_LIMITS = { a4: 27, a6p: 14, a6l: 11 }; const DEFAULT_LINE_LIMITS = { a4: 27, a5p: 19, a5l: 13, a6p: 14, a6l: 11, dinlang_karte: 11 };
const DEFAULT_FORMAT_LAYOUTS = { const DEFAULT_FORMAT_LAYOUTS = {
a4: { marginTopMm: 25, marginLeftMm: 20, lineHeightFactor: 1.35 }, a4: { marginTopMm: 25, marginLeftMm: 20, lineHeightFactor: 1.35 },
a6p: { marginTopMm: 8, marginLeftMm: 8, lineHeightFactor: 1.3 }, a5p: { marginTopMm: 20, marginLeftMm: 15, lineHeightFactor: 1.35 },
a6l: { marginTopMm: 8, marginLeftMm: 8, marginRightMm: 14, lineHeightFactor: 1.2 }, a5l: { marginTopMm: 20, marginLeftMm: 15, lineHeightFactor: 1.35 },
dinlang_karte: { marginTopMm: 8, marginLeftMm: 10, lineHeightFactor: 1.2 },
// A6-Greifrand IMMER an der langen (148 mm) Seite:
// • a6p (hoch, 105×148): lange Seite = rechts → marginRightMm (Breite)
// • a6l (quer, 148×105): lange Seite = unten → marginBottomMm (Zeilen)
a6p: { marginTopMm: 8, marginLeftMm: 8, marginRightMm: 14, lineHeightFactor: 1.3 },
a6l: { marginTopMm: 8, marginLeftMm: 8, marginBottomMm: 14, lineHeightFactor: 1.2 },
din_lang: { marginTopMm: 50, marginLeftMm: 10, lineHeightFactor: 1.2 }, din_lang: { marginTopMm: 50, marginLeftMm: 10, lineHeightFactor: 1.2 },
c6: { marginTopMm: 60, marginLeftMm: 10, lineHeightFactor: 1.2 }, c6: { marginTopMm: 60, marginLeftMm: 10, lineHeightFactor: 1.2 },
// C4 quer (Querformat-Beschriftung, maschinenseitig quer eingelegt).
c4: { marginTopMm: 70, marginLeftMm: 20, lineHeightFactor: 1.2 },
}; };
const DEFAULT_PAGE_FORMATS = { const DEFAULT_PAGE_FORMATS = {
a4: { widthMm: 210, heightMm: 297 }, a4: { widthMm: 210, heightMm: 297 },
a5p: { widthMm: 148, heightMm: 210 },
a5l: { widthMm: 210, heightMm: 148 },
dinlang_karte: { widthMm: 210, heightMm: 105 },
a6p: { widthMm: 105, heightMm: 148 }, a6p: { widthMm: 105, heightMm: 148 },
a6l: { widthMm: 148, heightMm: 105 }, a6l: { widthMm: 148, heightMm: 105 },
din_lang: { widthMm: 220, heightMm: 110 }, din_lang: { widthMm: 220, heightMm: 110 },
c6: { widthMm: 162, heightMm: 114 }, c6: { widthMm: 162, heightMm: 114 },
c4: { widthMm: 324, heightMm: 229 },
}; };
// Art des Formats (brief/umschlag/postkarte) – steuert, WAS generiert wird. // Art des Formats (brief/umschlag/postkarte) – steuert, WAS generiert wird.
const DEFAULT_KINDS = { a4: 'brief', a6p: 'brief', a6l: 'brief', din_lang: 'umschlag', c6: 'umschlag' }; const DEFAULT_KINDS = { a4: 'brief', a5p: 'brief', a5l: 'brief', a6p: 'brief', a6l: 'brief', dinlang_karte: 'brief', din_lang: 'umschlag', c6: 'umschlag', c4: 'umschlag' };
// Live-Cache (wird von applyRenderFormats ersetzt). Start = Defaults. // Live-Cache (wird von applyRenderFormats ersetzt). Start = Defaults.
let LINE_LIMITS = { ...DEFAULT_LINE_LIMITS }; let LINE_LIMITS = { ...DEFAULT_LINE_LIMITS };
@@ -56,6 +68,8 @@ function applyRenderFormats(rows) {
}; };
const mr = r.margin_right_mm ?? alt.marginRightMm; const mr = r.margin_right_mm ?? alt.marginRightMm;
if (mr != null && mr !== '') layout.marginRightMm = Number(mr); if (mr != null && mr !== '') layout.marginRightMm = Number(mr);
const mb = r.margin_bottom_mm ?? alt.marginBottomMm;
if (mb != null && mb !== '') layout.marginBottomMm = Number(mb);
fl[k] = layout; fl[k] = layout;
if (r.line_limit != null && r.line_limit !== '') ll[k] = Number(r.line_limit); if (r.line_limit != null && r.line_limit !== '') ll[k] = Number(r.line_limit);
} }
@@ -110,6 +124,7 @@ function getLayoutForFormat(format) {
marginTopPx: mmToPx(layoutConfig.marginTopMm), marginTopPx: mmToPx(layoutConfig.marginTopMm),
marginLeftPx: mmToPx(layoutConfig.marginLeftMm), marginLeftPx: mmToPx(layoutConfig.marginLeftMm),
marginRightPx: layoutConfig.marginRightMm ? mmToPx(layoutConfig.marginRightMm) : null, marginRightPx: layoutConfig.marginRightMm ? mmToPx(layoutConfig.marginRightMm) : null,
marginBottomPx: layoutConfig.marginBottomMm ? mmToPx(layoutConfig.marginBottomMm) : 0,
lineHeightPx: FONT_SIZE_PX * layoutConfig.lineHeightFactor, lineHeightPx: FONT_SIZE_PX * layoutConfig.lineHeightFactor,
}; };
} }
@@ -143,6 +158,21 @@ function getLineLimit(format) {
return LINE_LIMITS[normalizedFormat] || LINE_LIMITS.a4; return LINE_LIMITS[normalizedFormat] || LINE_LIMITS.a4;
} }
// Effektives Zeilenlimit: das kleinere aus (a) konfiguriertem line_limit,
// gegenläufig zur Schriftgröße skaliert, und (b) geometrischer Kapazität, die
// einen unteren Greifrand (marginBottomMm) frei hält. Dadurch reserviert A6 quer
// (marginBottomMm=14) unten Freiraum für den rollengeführten Plotter, ohne dass
// die anderen Formate (ohne Bottom-Rand) berührt werden.
function getEffectiveLineLimit(format, fontScale = 1) {
const fs = Math.max(0.8, Math.min(1.5, Number(fontScale) || 1));
const konfiguriert = Math.max(1, Math.round(getLineLimit(format) / fs));
const { heightPx } = getPageDimensions(format);
const { marginTopPx, marginBottomPx, lineHeightPx } = getLayoutForFormat(format);
const nutzbarPx = heightPx - marginTopPx - (marginBottomPx || 0);
const geo = Math.max(1, Math.floor(nutzbarPx / (lineHeightPx * fs)));
return Math.min(konfiguriert, geo);
}
module.exports = { module.exports = {
PX_PER_MM, PX_PER_MM,
FONT_SIZE_PX, FONT_SIZE_PX,
@@ -150,6 +180,7 @@ module.exports = {
getLayoutForFormat, getLayoutForFormat,
getPageDimensions, getPageDimensions,
getLineLimit, getLineLimit,
getEffectiveLineLimit,
getFormatKind, getFormatKind,
escapeXml, escapeXml,
applyRenderFormats, applyRenderFormats,

View File

@@ -2,7 +2,7 @@ const {
FONT_SIZE_PX, FONT_SIZE_PX,
getLayoutForFormat, getLayoutForFormat,
getPageDimensions, getPageDimensions,
getLineLimit, getEffectiveLineLimit,
escapeXml, escapeXml,
mmToPx mmToPx
} = require('./page-layout'); } = require('./page-layout');
@@ -140,7 +140,7 @@ function generateLetterSVG(text, format, options = {}) {
.join('\n '); .join('\n ');
// Größere Schrift → weniger Zeilen passen aufs Blatt (Limit gegenläufig skalieren). // Größere Schrift → weniger Zeilen passen aufs Blatt (Limit gegenläufig skalieren).
const lineLimit = Math.max(1, Math.round(getLineLimit(format) / fontScale)); const lineLimit = getEffectiveLineLimit(format, fontScale);
return { return {
svg: `<svg xmlns="http://www.w3.org/2000/svg" svg: `<svg xmlns="http://www.w3.org/2000/svg"
width="${widthMm}mm" height="${heightMm}mm" width="${widthMm}mm" height="${heightMm}mm"
@@ -182,7 +182,7 @@ function generateLetterSVG(text, format, options = {}) {
const allSvgElements = []; const allSvgElements = [];
let currentY = marginTopPx + fontSizePx; let currentY = marginTopPx + fontSizePx;
let totalLineCount = 0; let totalLineCount = 0;
const lineLimit = Math.max(1, Math.round(getLineLimit(format) / fontScale)); const lineLimit = getEffectiveLineLimit(format, fontScale);
let si = 0; let si = 0;
while (si < segments.length) { while (si < segments.length) {
@@ -606,7 +606,7 @@ function generateLetterPages(text, format, options = {}) {
const fontScale = Math.max(0.8, Math.min(1.5, Number(options.fontScale) || 1)); const fontScale = Math.max(0.8, Math.min(1.5, Number(options.fontScale) || 1));
const fontSizePx = FONT_SIZE_PX * fontScale; const fontSizePx = FONT_SIZE_PX * fontScale;
const lineHeightPx = baseLineHeightPx * fontScale; const lineHeightPx = baseLineHeightPx * fontScale;
const linesPerPage = Math.max(1, Math.round(getLineLimit(format) / fontScale)); const linesPerPage = getEffectiveLineLimit(format, fontScale);
// Erzwungene Seitenumbrüche zuerst; danach jeden Block nach Zeilen auto-fließen. // Erzwungene Seitenumbrüche zuerst; danach jeden Block nach Zeilen auto-fließen.
const bloecke = String(text || '').split(/\[\[seitenumbruch\]\]/gi); const bloecke = String(text || '').split(/\[\[seitenumbruch\]\]/gi);
@@ -666,7 +666,7 @@ function countLetterPages(text, format, options = {}) {
const maxWidthPx = widthPx - marginLeftPx - (marginRightPx ?? marginLeftPx); const maxWidthPx = widthPx - marginLeftPx - (marginRightPx ?? marginLeftPx);
const fontScale = Math.max(0.8, Math.min(1.5, Number(options.fontScale) || 1)); const fontScale = Math.max(0.8, Math.min(1.5, Number(options.fontScale) || 1));
const fontSizePx = FONT_SIZE_PX * fontScale; const fontSizePx = FONT_SIZE_PX * fontScale;
const linesPerPage = Math.max(1, Math.round(getLineLimit(format) / fontScale)); const linesPerPage = getEffectiveLineLimit(format, fontScale);
const seitenZeilen = []; const seitenZeilen = [];
for (const block of String(text || '').split(/\[\[seitenumbruch\]\]/gi)) { for (const block of String(text || '').split(/\[\[seitenumbruch\]\]/gi)) {

View File

@@ -84,18 +84,21 @@ app.listen(config.port, () => {
refreshRenderFormats(); refreshRenderFormats();
setInterval(refreshRenderFormats, 60 * 60 * 1000); setInterval(refreshRenderFormats, 60 * 60 * 1000);
// Batch-Bündelung: täglich um 03:00 (Europe/Berlin) den Vortag bündeln + FTP. // Batch-FTP-Bündelung nur, wenn ausdrücklich aktiviert (Standardweg ist die
// Sa+So werden gemeinsam am Montag verarbeitet (Sonntag-Lauf wird übersprungen). // Übernahme in die Produktion, nicht FTP). SKRIFT_BATCH_FTP_CRON=true schaltet
// Minuten-Tick; einmal pro Tag im 3-Uhr-Fenster (idempotent über letzterBatchTag). // den täglichen 03:00-Lauf (Europe/Berlin) wieder ein; Sa+So am Montag.
if (String(process.env.SKRIFT_BATCH_FTP_CRON || '').toLowerCase() === 'true') {
let letzterBatchTag = null; let letzterBatchTag = null;
setInterval(() => { setInterval(() => {
try { try {
const { date, hour } = berlinParts(); const { date, hour } = berlinParts();
if (hour !== 3 || letzterBatchTag === date) return; if (hour !== 3 || letzterBatchTag === date) return;
letzterBatchTag = date; // markiert den Lauf für heute – auch bei Fehler kein Doppel-Lauf. letzterBatchTag = date;
runScheduledBatch().catch((e) => console.error('[batch-cron] Fehler:', e.message)); runScheduledBatch().catch((e) => console.error('[batch-cron] Fehler:', e.message));
} catch (e) { console.error('[batch-cron] Tick-Fehler:', e.message); } } catch (e) { console.error('[batch-cron] Tick-Fehler:', e.message); }
}, 60 * 1000); }, 60 * 1000);
console.log('Batch-FTP-Cron: aktiv (03:00 Europe/Berlin)');
}
}); });
// Graceful shutdown // Graceful shutdown

View File

@@ -112,9 +112,10 @@ async function fetchRenderFormats() {
/** Offene (pending) Batch-Übermittlungen MIT Druck-PDF, optional je Zugang. /** Offene (pending) Batch-Übermittlungen MIT Druck-PDF, optional je Zugang.
* Text-only-Datensätze (ohne PDF) werden bewusst NICHT gebündelt. */ * Text-only-Datensätze (ohne PDF) werden bewusst NICHT gebündelt. */
async function fetchBatchPending(clientId) { async function fetchBatchPending(clientId, ids) {
const filter = 'filter[status][_eq]=pending&filter[pdf_file][_nnull]=true' let filter = 'filter[status][_eq]=pending&filter[pdf_file][_nnull]=true';
+ (clientId != null ? `&filter[api_client][_eq]=${encodeURIComponent(clientId)}` : ''); if (clientId != null) filter += `&filter[api_client][_eq]=${encodeURIComponent(clientId)}`;
if (Array.isArray(ids) && ids.length) filter += `&filter[id][_in]=${ids.map(encodeURIComponent).join(',')}`;
const fields = 'id,api_client,firma,vorname,nachname,zeile1,zeile2,zeile3,plz,stadt,land,pdf_file'; const fields = 'id,api_client,firma,vorname,nachname,zeile1,zeile2,zeile3,plz,stadt,land,pdf_file';
return (await directusFetch(`/items/batch_submissions?${filter}&sort=date_created&limit=-1&fields=${fields}`)) || []; return (await directusFetch(`/items/batch_submissions?${filter}&sort=date_created&limit=-1&fields=${fields}`)) || [];
} }