Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

introduce new email template and change notifier code to use it (#7395)

Markus Schlichting2d1266f54803
diff --git a/server/core/assets/email-templates/video-published-for-subscribers/html.hbs b/server/core/assets/email-templates/video-published-for-subscribers/html.hbs
new file mode 100644
index 0000000000..594d0d09ad
--- /dev/null
+++ b/server/core/assets/email-templates/video-published-for-subscribers/html.hbs
@@ -0,0 +1,9 @@
+{{#> base title=(t "{channelName} just published a new video" channelName=channelName)}}
+ <p>
+ {{#if isLive}}
+ {{{t "Your subscription <a href=\"{channelUrl}\">{channelName}</a> is live streaming <strong>{videoName}</strong>" channelUrl=channelUrl channelName=channelName videoName=videoName}}}
+ {{else}}
+ {{{t "Your subscription <a href=\"{channelUrl}\">{channelName}</a> just published a new video: <strong>{videoName}</strong>" channelUrl=channelUrl channelName=channelName videoName=videoName}}}
+ {{/if}}
+ </p>
+{{/base}}
diff --git a/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts b/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts
index 74a99c76a0..823bb7719e 100644
--- a/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts
+++ b/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts
@@ -1,4 +1,4 @@
-import { To, UserNotificationType, VideoPrivacy, VideoState } from '@peertube/peertube-models'
+import { UserNotificationType, VideoPrivacy, VideoState } from '@peertube/peertube-models'
import { logger } from '@server/helpers/logger.js'
import { WEBSERVER } from '@server/initializers/constants.js'
import { UserNotificationModel } from '@server/models/user/user-notification.js'
@@ -55,37 +55,25 @@ export class NewVideoOrLiveForSubscribers extends AbstractNotification<MVideoAcc
const to = { email: user.email, language: user.getLanguage() }
const channelName = this.payload.VideoChannel.getDisplayName()
+ const channelUrl = WEBSERVER.URL + this.payload.VideoChannel.getClientUrl()
const videoUrl = WEBSERVER.URL + this.payload.getWatchStaticPath()
+ const videoName = this.payload.name
+ const isLive = this.payload.isLive
- if (this.payload.isLive) return this.createLiveEmail(to, channelName, videoUrl)
+ const subject = isLive
+ ? t('{channelName} is live streaming', to.language, { channelName })
+ : t('{channelName} just published a new video: { videoName }', to.language, { channelName, videoName })
- return this.createVideoEmail(to, channelName, videoUrl)
- }
-
- private createVideoEmail (to: To, channelName: string, videoUrl: string) {
return {
+ template: 'video-published-for-subscribers',
to,
- subject: t('{channelName} just published a new video', to.language, { channelName }),
- text: t('Your subscription {channelName} just published a new video: {videoName}.', to.language, {
- channelName,
- videoName: this.payload.name
- }),
- locals: {
- title: t('{channelName} just published a new video', to.language, { channelName }),
- action: {
- text: t('View video', to.language),
- url: videoUrl
- }
- }
- }
- }
-
- private createLiveEmail (to: To, channelName: string, videoUrl: string) {
- return {
- to,
- subject: t('{channelName} is live streaming', to.language, { channelName }),
- text: t('Your subscription {channelName} is live streaming {videoName}', to.language, { channelName, videoName: this.payload.name }),
+ subject,
locals: {
+ channelName,
+ channelUrl,
+ videoName,
+ videoUrl,
+ isLive,
action: {
text: t('View video', to.language),
url: videoUrl