+ addNewUserRegistrationNotification (to: string[], user: UserModel) {
+ const text = `Hi,\n\n` +
+ `User ${user.username} just registered on ${CONFIG.WEBSERVER.HOST} PeerTube instance.\n\n` +
+ `Cheers,\n` +
+ `PeerTube.`
+
+ const emailPayload: EmailPayload = {
+ to,
+ subject: '[PeerTube] New user registration on ' + CONFIG.WEBSERVER.HOST,
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addVideoBlacklistNotification (to: string[], videoBlacklist: VideoBlacklistModel) {
+ const videoName = videoBlacklist.Video.name
+ const videoUrl = CONFIG.WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath()
+
+ const reasonString = videoBlacklist.reason ? ` for the following reason: ${videoBlacklist.reason}` : ''
+ const blockedString = `Your video ${videoName} (${videoUrl} on ${CONFIG.WEBSERVER.HOST} has been blacklisted${reasonString}.`
+
+ const text = 'Hi,\n\n' +
+ blockedString +
+ '\n\n' +
+ 'Cheers,\n' +
+ `PeerTube.`
+
+ const emailPayload: EmailPayload = {
+ to,
+ subject: `[PeerTube] Video ${videoName} blacklisted`,
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addVideoUnblacklistNotification (to: string[], video: VideoModel) {
+ const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+
+ const text = 'Hi,\n\n' +
+ `Your video ${video.name} (${videoUrl}) on ${CONFIG.WEBSERVER.HOST} has been unblacklisted.` +
+ '\n\n' +
+ 'Cheers,\n' +
+ `PeerTube.`
+
+ const emailPayload: EmailPayload = {
+ to,
+ subject: `[PeerTube] Video ${video.name} unblacklisted`,
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addForgetPasswordEmailJob (to: string, resetPasswordUrl: string) {
+ const text = `Hi dear user,\n\n` +
+ `It seems you forgot your password on ${CONFIG.WEBSERVER.HOST}! ` +
+ `Please follow this link to reset it: ${resetPasswordUrl}\n\n` +
+ `If you are not the person who initiated this request, please ignore this email.\n\n` +
+ `Cheers,\n` +
+ `PeerTube.`
+
+ const emailPayload: EmailPayload = {
+ to: [ to ],
+ subject: 'Reset your PeerTube password',
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addVerifyEmailJob (to: string, verifyEmailUrl: string) {
+ const text = `Welcome to PeerTube,\n\n` +
+ `To start using PeerTube on ${CONFIG.WEBSERVER.HOST} you must verify your email! ` +
+ `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` +
+ `If you are not the person who initiated this request, please ignore this email.\n\n` +
+ `Cheers,\n` +
+ `PeerTube.`
+
+ const emailPayload: EmailPayload = {
+ to: [ to ],
+ subject: 'Verify your PeerTube email',
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) {
+ const reasonString = reason ? ` for the following reason: ${reason}` : ''
+ const blockedWord = blocked ? 'blocked' : 'unblocked'
+ const blockedString = `Your account ${user.username} on ${CONFIG.WEBSERVER.HOST} has been ${blockedWord}${reasonString}.`
+
+ const text = 'Hi,\n\n' +
+ blockedString +
+ '\n\n' +
+ 'Cheers,\n' +
+ `PeerTube.`
+
+ const to = user.email
+ const emailPayload: EmailPayload = {
+ to: [ to ],
+ subject: '[PeerTube] Account ' + blockedWord,
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ addContactFormJob (fromEmail: string, fromName: string, body: string) {
+ const text = 'Hello dear admin,\n\n' +
+ fromName + ' sent you a message' +
+ '\n\n---------------------------------------\n\n' +
+ body +
+ '\n\n---------------------------------------\n\n' +
+ 'Cheers,\n' +
+ 'PeerTube.'
+
+ const emailPayload: EmailPayload = {
+ from: fromEmail,
+ to: [ CONFIG.ADMIN.EMAIL ],
+ subject: '[PeerTube] Contact form submitted',
+ text
+ }
+
+ return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
+ }
+
+ sendMail (to: string[], subject: string, text: string, from?: string) {
+ if (!Emailer.isEnabled()) {