aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/emailer.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-02 16:37:43 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commitdc13348070d808d0ba3feb56a435b835c2e7e791 (patch)
tree887202a33f1aa680fd8ece6ee465381f3931c64e /server/lib/emailer.ts
parent6e7e63b83f08ba68edc2bb9f72ff03d1802e45df (diff)
downloadPeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.gz
PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.tar.zst
PeerTube-dc13348070d808d0ba3feb56a435b835c2e7e791.zip
Add import finished and video published notifs
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r--server/lib/emailer.ts61
1 files changed, 61 insertions, 0 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index d766e655b..6dc8f2adf 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -10,6 +10,7 @@ import { readFileSync } from 'fs-extra'
10import { VideoCommentModel } from '../models/video/video-comment' 10import { VideoCommentModel } from '../models/video/video-comment'
11import { VideoAbuseModel } from '../models/video/video-abuse' 11import { VideoAbuseModel } from '../models/video/video-abuse'
12import { VideoBlacklistModel } from '../models/video/video-blacklist' 12import { VideoBlacklistModel } from '../models/video/video-blacklist'
13import { VideoImportModel } from '../models/video/video-import'
13 14
14class Emailer { 15class Emailer {
15 16
@@ -102,6 +103,66 @@ class Emailer {
102 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 103 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
103 } 104 }
104 105
106 myVideoPublishedNotification (to: string[], video: VideoModel) {
107 const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
108
109 const text = `Hi dear user,\n\n` +
110 `Your video ${video.name} has been published.` +
111 `\n\n` +
112 `You can view it on ${videoUrl} ` +
113 `\n\n` +
114 `Cheers,\n` +
115 `PeerTube.`
116
117 const emailPayload: EmailPayload = {
118 to,
119 subject: `Your video ${video.name} is published`,
120 text
121 }
122
123 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
124 }
125
126 myVideoImportSuccessNotification (to: string[], videoImport: VideoImportModel) {
127 const videoUrl = CONFIG.WEBSERVER.URL + videoImport.Video.getWatchStaticPath()
128
129 const text = `Hi dear user,\n\n` +
130 `Your video import ${videoImport.getTargetIdentifier()} is finished.` +
131 `\n\n` +
132 `You can view the imported video on ${videoUrl} ` +
133 `\n\n` +
134 `Cheers,\n` +
135 `PeerTube.`
136
137 const emailPayload: EmailPayload = {
138 to,
139 subject: `Your video import ${videoImport.getTargetIdentifier()} is finished`,
140 text
141 }
142
143 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
144 }
145
146 myVideoImportErrorNotification (to: string[], videoImport: VideoImportModel) {
147 const importUrl = CONFIG.WEBSERVER.URL + '/my-account/video-imports'
148
149 const text = `Hi dear user,\n\n` +
150 `Your video import ${videoImport.getTargetIdentifier()} encountered an error.` +
151 `\n\n` +
152 `See your videos import dashboard for more information: ${importUrl}` +
153 `\n\n` +
154 `Cheers,\n` +
155 `PeerTube.`
156
157 const emailPayload: EmailPayload = {
158 to,
159 subject: `Your video import ${videoImport.getTargetIdentifier()} encountered an error`,
160 text
161 }
162
163 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
164 }
165
105 addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) { 166 addNewCommentOnMyVideoNotification (to: string[], comment: VideoCommentModel) {
106 const accountName = comment.Account.getDisplayName() 167 const accountName = comment.Account.getDisplayName()
107 const video = comment.Video 168 const video = comment.Video