feat: batched auto-rules emails, thumbnail fallback, and approve form
This commit is contained in:
1 parent
4667615ed0
commit
9fdd76645c
8 files changed
+196
-61
No files matched your search
@@ -71,13 +71,33 @@ export const emailService = {
|
||||
});
|
||||
},
|
||||
|
||||
async sendNewAlbumNotification(toEmail: string, albumName: string) {
|
||||
async sendNewAlbumNotification(toEmail: string, albumNames: string | string[]) {
|
||||
const albums = Array.isArray(albumNames) ? albumNames : [albumNames];
|
||||
|
||||
if (albums.length === 0) return;
|
||||
|
||||
const isMultiple = albums.length > 1;
|
||||
const subject = isMultiple
|
||||
? `Neue Fotoalben verfügbar (${albums.length})`
|
||||
: `Neues Fotoalbum verfügbar: ${albums[0]}`;
|
||||
|
||||
const textList = albums.map(a => `- ${a}`).join("\n");
|
||||
const htmlList = albums.map(a => `<li><strong>${a}</strong></li>`).join("");
|
||||
|
||||
const textBody = isMultiple
|
||||
? `Hallo,\n\nes wurden ${albums.length} neue Fotoalben für Ihre Redaktion freigegeben:\n\n${textList}\n\nSie können die Bilder ab sofort im Redaktionsportal ansehen und lizenzieren.\n\nViele Grüße,\nIhr Redaktions-Team`
|
||||
: `Hallo,\n\nein neues Fotoalbum "${albums[0]}" wurde für Ihre Redaktion freigegeben. Sie können die Bilder ab sofort im Redaktionsportal ansehen und lizenzieren.\n\nViele Grüße,\nIhr Redaktions-Team`;
|
||||
|
||||
const htmlBody = isMultiple
|
||||
? `Hallo,\n\nes wurden soeben **${albums.length} neue Fotoalben** für Ihre Redaktion freigegeben:\n\n<ul>${htmlList}</ul>\n\nSie können die Bilder ab sofort im Redaktionsportal ansehen und herunterladen.\n\nViele Grüße,\nIhr Redaktions-Team`
|
||||
: `Hallo,\n\nein neues Fotoalbum **"${albums[0]}"** wurde soeben für Ihre Redaktion freigegeben.\n\nSie können die Bilder ab sofort im Redaktionsportal ansehen und herunterladen.\n\nViele Grüße,\nIhr Redaktions-Team`;
|
||||
|
||||
await transporter.sendMail({
|
||||
from: env.SMTP_FROM,
|
||||
to: toEmail,
|
||||
subject: `Neues Fotoalbum verfügbar: ${albumName}`,
|
||||
text: `Hallo,\n\nein neues Fotoalbum "${albumName}" wurde für Ihre Redaktion freigegeben. Sie können die Bilder ab sofort im Redaktionsportal ansehen und lizenzieren.\n\nViele Grüße,\nIhr Redaktions-Team`,
|
||||
html: buildHtml("Neues Album verfügbar", `Hallo,\n\nein neues Fotoalbum **"${albumName}"** wurde soeben für Ihre Redaktion freigegeben.\n\nSie können die Bilder ab sofort im Redaktionsportal ansehen und herunterladen.\n\nViele Grüße,\nIhr Redaktions-Team`, { text: "Zum Portal", url: `${env.BETTER_AUTH_URL}/login` }),
|
||||
subject,
|
||||
text: textBody,
|
||||
html: buildHtml(isMultiple ? "Neue Alben verfügbar" : "Neues Album verfügbar", htmlBody, { text: "Zum Portal", url: `${env.BETTER_AUTH_URL}/login` }),
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user