You've already forked obsidian-visualiser
Fix Campaign log DB and rendering. Migrate mail rendering to virtual DOM API.
This commit is contained in:
@@ -2,16 +2,20 @@ import nodemailer from 'nodemailer';
|
||||
import { createSSRApp, h } from 'vue';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
|
||||
import base from '../components/mail/base.vue';
|
||||
import base from '../components/mail/base';
|
||||
import registration from '../components/mail/registration';
|
||||
import reset_password from '../components/mail/reset-password';
|
||||
|
||||
/* import base from '../components/mail/base.vue';
|
||||
import Registration from '../components/mail/registration.vue';
|
||||
import ResetPassword from '../components/mail/reset-password.vue';
|
||||
import ResetPassword from '../components/mail/reset-password.vue'; */
|
||||
|
||||
const config = useRuntimeConfig();
|
||||
const [domain, selector, dkim] = config.mail.dkim.split(":");
|
||||
|
||||
export const templates: Record<string, { component: any, subject: string }> = {
|
||||
"registration": { component: Registration, subject: 'Bienvenue sur d[any] 😎' },
|
||||
"reset-password": { component: ResetPassword, subject: 'Réinitialisation de votre mot de passe' },
|
||||
export const templates: Record<string, { component: (data: any) => string[], subject: string }> = {
|
||||
"registration": { component: registration, subject: 'Bienvenue sur d[any] 😎' },
|
||||
"reset-password": { component: reset_password, subject: 'Réinitialisation de votre mot de passe' },
|
||||
};
|
||||
|
||||
import type Mail from 'nodemailer/lib/mailer';
|
||||
@@ -76,11 +80,13 @@ export default defineTask({
|
||||
throw new Error(`Modèle de mail ${mailPayload.template} inconnu`);
|
||||
}
|
||||
|
||||
console.log(`<html><body>${base(template.component(mailPayload.data))}</body></html>`);
|
||||
|
||||
console.time('Generating HTML');
|
||||
const mail: Mail.Options = {
|
||||
from: 'd[any] - Ne pas répondre <no-reply@peaceultime.com>',
|
||||
to: mailPayload.to,
|
||||
html: await render(template.component, mailPayload.data),
|
||||
html: `<html><body>${base(template.component(mailPayload.data))}</body></html>`,
|
||||
subject: template.subject,
|
||||
textEncoding: 'quoted-printable',
|
||||
};
|
||||
@@ -106,17 +112,4 @@ export default defineTask({
|
||||
return { result: false, error: e };
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
async function render(component: any, data: Record<string, any>): Promise<string>
|
||||
{
|
||||
const app = createSSRApp({
|
||||
render(){
|
||||
return h(base, null, { default: () => h(component, data, { default: () => null }) });
|
||||
}
|
||||
});
|
||||
|
||||
const html = await renderToString(app);
|
||||
|
||||
return (`<html><body><div>${html}</div></body></html>`);
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user