diff --git a/server.js b/server.js index 5590abb..0f6c15a 100644 --- a/server.js +++ b/server.js @@ -1389,6 +1389,19 @@ initializeDatabase().then(() => { attNames.push(a.dateiname); } + // Selected static attachments (Zeugnisse etc.), e.g. from a reply form. + // Default: none selected. + let basisAnlageIds = req.body.basis_anlage || []; + if (!Array.isArray(basisAnlageIds)) basisAnlageIds = [basisAnlageIds]; + for (const bid of basisAnlageIds) { + const ba = await dbGet('SELECT * FROM basis_anhaenge WHERE id = ?', [bid]); + if (!ba) continue; + const p = path.join(basisAnhaengeDir, ba.pfad); + if (!fs.existsSync(p)) continue; + attachments.push({ filename: ba.dateiname, path: p, contentType: ba.mime || undefined }); + attNames.push(ba.dateiname); + } + // Threading headers when this is a reply to a stored message. let inReplyTo = null, references = null; if (req.body.reply_to) { diff --git a/views/bewerbung.ejs b/views/bewerbung.ejs index 6ce0f60..54f6b59 100644 --- a/views/bewerbung.ejs +++ b/views/bewerbung.ejs @@ -385,6 +385,21 @@ + <% if (basisAnhaenge && basisAnhaenge.length) { %> +

Anlagen

+
+ <% basisAnhaenge.forEach(function(ba){ %> + + <% }); %> +
+ <% } %>