From be19d9be34c42a18c4db3a0852735353014e7a9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Mar 2024 09:15:07 +0100 Subject: [PATCH] Move email templates in assets directory --- scripts/build/server.sh | 1 - scripts/dev/server.sh | 1 - .../email-templates}/abuse-new-message/html.pug | 0 .../email-templates}/abuse-state-change/html.pug | 0 .../email-templates}/account-abuse-new/html.pug | 0 .../core/{lib/emails => assets/email-templates}/common/base.pug | 0 .../{lib/emails => assets/email-templates}/common/greetings.pug | 0 .../core/{lib/emails => assets/email-templates}/common/html.pug | 0 .../{lib/emails => assets/email-templates}/common/mixins.pug | 0 .../emails => assets/email-templates}/contact-form/html.pug | 0 .../email-templates}/follower-on-channel/html.pug | 0 .../emails => assets/email-templates}/password-create/html.pug | 0 .../emails => assets/email-templates}/password-reset/html.pug | 0 .../email-templates}/peertube-version-new/html.pug | 0 .../email-templates}/plugin-version-new/html.pug | 0 .../email-templates}/user-export-completed/html.pug | 0 .../email-templates}/user-export-errored/html.pug | 0 .../email-templates}/user-import-completed/html.pug | 0 .../email-templates}/user-import-errored/html.pug | 0 .../emails => assets/email-templates}/user-registered/html.pug | 0 .../user-registration-request-accepted/html.pug | 0 .../user-registration-request-rejected/html.pug | 0 .../email-templates}/user-registration-request/html.pug | 0 .../emails => assets/email-templates}/verify-email/html.pug | 0 .../emails => assets/email-templates}/video-abuse-new/html.pug | 0 .../email-templates}/video-auto-blacklist-new/html.pug | 0 .../email-templates}/video-comment-abuse-new/html.pug | 0 .../email-templates}/video-comment-mention/html.pug | 0 .../email-templates}/video-comment-new/html.pug | 0 server/core/lib/emailer.ts | 2 +- support/doc/development/server.md | 2 +- 31 files changed, 2 insertions(+), 4 deletions(-) rename server/core/{lib/emails => assets/email-templates}/abuse-new-message/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/abuse-state-change/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/account-abuse-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/common/base.pug (100%) rename server/core/{lib/emails => assets/email-templates}/common/greetings.pug (100%) rename server/core/{lib/emails => assets/email-templates}/common/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/common/mixins.pug (100%) rename server/core/{lib/emails => assets/email-templates}/contact-form/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/follower-on-channel/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/password-create/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/password-reset/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/peertube-version-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/plugin-version-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-export-completed/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-export-errored/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-import-completed/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-import-errored/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-registered/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-registration-request-accepted/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-registration-request-rejected/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/user-registration-request/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/verify-email/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/video-abuse-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/video-auto-blacklist-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/video-comment-abuse-new/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/video-comment-mention/html.pug (100%) rename server/core/{lib/emails => assets/email-templates}/video-comment-new/html.pug (100%) diff --git a/scripts/build/server.sh b/scripts/build/server.sh index bdefc378f..88dec1e0f 100755 --- a/scripts/build/server.sh +++ b/scripts/build/server.sh @@ -8,5 +8,4 @@ npm run tsc -- -b --verbose server/tsconfig.json npm run resolve-tspaths:server cp -r "./server/core/static" "./server/core/assets" ./dist/core -cp -r "./server/core/lib/emails" "./dist/core/lib" cp "./server/scripts/upgrade.sh" "./dist/scripts" diff --git a/scripts/dev/server.sh b/scripts/dev/server.sh index fd3f42d90..569f3c4c9 100755 --- a/scripts/dev/server.sh +++ b/scripts/dev/server.sh @@ -20,6 +20,5 @@ npm run tsc -- -b -v --incremental server/tsconfig.json npm run resolve-tspaths:server cp -r ./server/core/static ./server/core/assets ./dist/core -cp -r "./server/core/lib/emails" "./dist/core/lib" ./node_modules/.bin/tsc-watch --build --preserveWatchOutput --verbose --onSuccess 'sh -c "npm run resolve-tspaths:server && NODE_ENV=dev node dist/server"' server/tsconfig.json diff --git a/server/core/lib/emails/abuse-new-message/html.pug b/server/core/assets/email-templates/abuse-new-message/html.pug similarity index 100% rename from server/core/lib/emails/abuse-new-message/html.pug rename to server/core/assets/email-templates/abuse-new-message/html.pug diff --git a/server/core/lib/emails/abuse-state-change/html.pug b/server/core/assets/email-templates/abuse-state-change/html.pug similarity index 100% rename from server/core/lib/emails/abuse-state-change/html.pug rename to server/core/assets/email-templates/abuse-state-change/html.pug diff --git a/server/core/lib/emails/account-abuse-new/html.pug b/server/core/assets/email-templates/account-abuse-new/html.pug similarity index 100% rename from server/core/lib/emails/account-abuse-new/html.pug rename to server/core/assets/email-templates/account-abuse-new/html.pug diff --git a/server/core/lib/emails/common/base.pug b/server/core/assets/email-templates/common/base.pug similarity index 100% rename from server/core/lib/emails/common/base.pug rename to server/core/assets/email-templates/common/base.pug diff --git a/server/core/lib/emails/common/greetings.pug b/server/core/assets/email-templates/common/greetings.pug similarity index 100% rename from server/core/lib/emails/common/greetings.pug rename to server/core/assets/email-templates/common/greetings.pug diff --git a/server/core/lib/emails/common/html.pug b/server/core/assets/email-templates/common/html.pug similarity index 100% rename from server/core/lib/emails/common/html.pug rename to server/core/assets/email-templates/common/html.pug diff --git a/server/core/lib/emails/common/mixins.pug b/server/core/assets/email-templates/common/mixins.pug similarity index 100% rename from server/core/lib/emails/common/mixins.pug rename to server/core/assets/email-templates/common/mixins.pug diff --git a/server/core/lib/emails/contact-form/html.pug b/server/core/assets/email-templates/contact-form/html.pug similarity index 100% rename from server/core/lib/emails/contact-form/html.pug rename to server/core/assets/email-templates/contact-form/html.pug diff --git a/server/core/lib/emails/follower-on-channel/html.pug b/server/core/assets/email-templates/follower-on-channel/html.pug similarity index 100% rename from server/core/lib/emails/follower-on-channel/html.pug rename to server/core/assets/email-templates/follower-on-channel/html.pug diff --git a/server/core/lib/emails/password-create/html.pug b/server/core/assets/email-templates/password-create/html.pug similarity index 100% rename from server/core/lib/emails/password-create/html.pug rename to server/core/assets/email-templates/password-create/html.pug diff --git a/server/core/lib/emails/password-reset/html.pug b/server/core/assets/email-templates/password-reset/html.pug similarity index 100% rename from server/core/lib/emails/password-reset/html.pug rename to server/core/assets/email-templates/password-reset/html.pug diff --git a/server/core/lib/emails/peertube-version-new/html.pug b/server/core/assets/email-templates/peertube-version-new/html.pug similarity index 100% rename from server/core/lib/emails/peertube-version-new/html.pug rename to server/core/assets/email-templates/peertube-version-new/html.pug diff --git a/server/core/lib/emails/plugin-version-new/html.pug b/server/core/assets/email-templates/plugin-version-new/html.pug similarity index 100% rename from server/core/lib/emails/plugin-version-new/html.pug rename to server/core/assets/email-templates/plugin-version-new/html.pug diff --git a/server/core/lib/emails/user-export-completed/html.pug b/server/core/assets/email-templates/user-export-completed/html.pug similarity index 100% rename from server/core/lib/emails/user-export-completed/html.pug rename to server/core/assets/email-templates/user-export-completed/html.pug diff --git a/server/core/lib/emails/user-export-errored/html.pug b/server/core/assets/email-templates/user-export-errored/html.pug similarity index 100% rename from server/core/lib/emails/user-export-errored/html.pug rename to server/core/assets/email-templates/user-export-errored/html.pug diff --git a/server/core/lib/emails/user-import-completed/html.pug b/server/core/assets/email-templates/user-import-completed/html.pug similarity index 100% rename from server/core/lib/emails/user-import-completed/html.pug rename to server/core/assets/email-templates/user-import-completed/html.pug diff --git a/server/core/lib/emails/user-import-errored/html.pug b/server/core/assets/email-templates/user-import-errored/html.pug similarity index 100% rename from server/core/lib/emails/user-import-errored/html.pug rename to server/core/assets/email-templates/user-import-errored/html.pug diff --git a/server/core/lib/emails/user-registered/html.pug b/server/core/assets/email-templates/user-registered/html.pug similarity index 100% rename from server/core/lib/emails/user-registered/html.pug rename to server/core/assets/email-templates/user-registered/html.pug diff --git a/server/core/lib/emails/user-registration-request-accepted/html.pug b/server/core/assets/email-templates/user-registration-request-accepted/html.pug similarity index 100% rename from server/core/lib/emails/user-registration-request-accepted/html.pug rename to server/core/assets/email-templates/user-registration-request-accepted/html.pug diff --git a/server/core/lib/emails/user-registration-request-rejected/html.pug b/server/core/assets/email-templates/user-registration-request-rejected/html.pug similarity index 100% rename from server/core/lib/emails/user-registration-request-rejected/html.pug rename to server/core/assets/email-templates/user-registration-request-rejected/html.pug diff --git a/server/core/lib/emails/user-registration-request/html.pug b/server/core/assets/email-templates/user-registration-request/html.pug similarity index 100% rename from server/core/lib/emails/user-registration-request/html.pug rename to server/core/assets/email-templates/user-registration-request/html.pug diff --git a/server/core/lib/emails/verify-email/html.pug b/server/core/assets/email-templates/verify-email/html.pug similarity index 100% rename from server/core/lib/emails/verify-email/html.pug rename to server/core/assets/email-templates/verify-email/html.pug diff --git a/server/core/lib/emails/video-abuse-new/html.pug b/server/core/assets/email-templates/video-abuse-new/html.pug similarity index 100% rename from server/core/lib/emails/video-abuse-new/html.pug rename to server/core/assets/email-templates/video-abuse-new/html.pug diff --git a/server/core/lib/emails/video-auto-blacklist-new/html.pug b/server/core/assets/email-templates/video-auto-blacklist-new/html.pug similarity index 100% rename from server/core/lib/emails/video-auto-blacklist-new/html.pug rename to server/core/assets/email-templates/video-auto-blacklist-new/html.pug diff --git a/server/core/lib/emails/video-comment-abuse-new/html.pug b/server/core/assets/email-templates/video-comment-abuse-new/html.pug similarity index 100% rename from server/core/lib/emails/video-comment-abuse-new/html.pug rename to server/core/assets/email-templates/video-comment-abuse-new/html.pug diff --git a/server/core/lib/emails/video-comment-mention/html.pug b/server/core/assets/email-templates/video-comment-mention/html.pug similarity index 100% rename from server/core/lib/emails/video-comment-mention/html.pug rename to server/core/assets/email-templates/video-comment-mention/html.pug diff --git a/server/core/lib/emails/video-comment-new/html.pug b/server/core/assets/email-templates/video-comment-new/html.pug similarity index 100% rename from server/core/lib/emails/video-comment-new/html.pug rename to server/core/assets/email-templates/video-comment-new/html.pug diff --git a/server/core/lib/emailer.ts b/server/core/lib/emailer.ts index 846b5d984..63bf44046 100644 --- a/server/core/lib/emailer.ts +++ b/server/core/lib/emailer.ts @@ -264,7 +264,7 @@ class Emailer { }, transport: this.transporter, views: { - root: join(root(), 'dist', 'core', 'lib', 'emails') + root: join(root(), 'dist', 'core', 'assets', 'email-templates') }, subjectPrefix: CONFIG.EMAIL.SUBJECT.PREFIX }) diff --git a/support/doc/development/server.md b/support/doc/development/server.md index c489812d4..0d9bf4fe9 100644 --- a/support/doc/development/server.md +++ b/support/doc/development/server.md @@ -61,7 +61,7 @@ Some of these may be optional (for example your new endpoint may not need to sen - Create the notification logic in `server/core/lib/notifier/shared`: + Email subject has a common prefix (defined by the admin in PeerTube configuration) - Add your notification to `server/core/lib/notifier/notifier.ts` - - Create the email template in `server/core/lib/emails`: + - Create the email template in `server/core/assets/email-templates`: + A text version is automatically generated from the HTML + The template usually extends `../common/grettings` that already says "Hi" and "Cheers". You just have to write the title and the content blocks that will be inserted in the appropriate places in the HTML template - If you need to associate a new table with `userNotification`: