diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/custom-validators/activitypub/activity.ts | 25 | ||||
-rw-r--r-- | server/initializers/config.ts | 8 | ||||
-rw-r--r-- | server/lib/emailer.ts | 66 |
3 files changed, 54 insertions, 45 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts index e0d170d9d..f68c76cdc 100644 --- a/server/helpers/custom-validators/activitypub/activity.ts +++ b/server/helpers/custom-validators/activitypub/activity.ts | |||
@@ -12,18 +12,19 @@ import { isFlagActivityValid } from './flag' | |||
12 | import { isPlaylistObjectValid } from './playlist' | 12 | import { isPlaylistObjectValid } from './playlist' |
13 | 13 | ||
14 | function isRootActivityValid (activity: any) { | 14 | function isRootActivityValid (activity: any) { |
15 | return Array.isArray(activity['@context']) && ( | 15 | return isCollection(activity) || isActivity(activity) |
16 | ( | 16 | } |
17 | (activity.type === 'Collection' || activity.type === 'OrderedCollection') && | 17 | |
18 | validator.isInt(activity.totalItems, { min: 0 }) && | 18 | function isCollection (activity: any) { |
19 | Array.isArray(activity.items) | 19 | return (activity.type === 'Collection' || activity.type === 'OrderedCollection') && |
20 | ) || | 20 | validator.isInt(activity.totalItems, { min: 0 }) && |
21 | ( | 21 | Array.isArray(activity.items) |
22 | isActivityPubUrlValid(activity.id) && | 22 | } |
23 | exists(activity.actor) && | 23 | |
24 | (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id)) | 24 | function isActivity (activity: any) { |
25 | ) | 25 | return isActivityPubUrlValid(activity.id) && |
26 | ) | 26 | exists(activity.actor) && |
27 | (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id)) | ||
27 | } | 28 | } |
28 | 29 | ||
29 | const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = { | 30 | const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = { |
diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 4515bc804..2be300a57 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts | |||
@@ -44,6 +44,14 @@ const CONFIG = { | |||
44 | CA_FILE: config.get<string>('smtp.ca_file'), | 44 | CA_FILE: config.get<string>('smtp.ca_file'), |
45 | FROM_ADDRESS: config.get<string>('smtp.from_address') | 45 | FROM_ADDRESS: config.get<string>('smtp.from_address') |
46 | }, | 46 | }, |
47 | EMAIL: { | ||
48 | BODY: { | ||
49 | SIGNATURE: config.get<string>('email.body.signature') | ||
50 | }, | ||
51 | OBJECT: { | ||
52 | PREFIX: config.get<string>('email.object.prefix') + ' ' | ||
53 | } | ||
54 | }, | ||
47 | STORAGE: { | 55 | STORAGE: { |
48 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), | 56 | TMP_DIR: buildPath(config.get<string>('storage.tmp')), |
49 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), | 57 | AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 8c06e9751..c4a5a5853 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -100,11 +100,11 @@ class Emailer { | |||
100 | `You can view it on ${videoUrl} ` + | 100 | `You can view it on ${videoUrl} ` + |
101 | `\n\n` + | 101 | `\n\n` + |
102 | `Cheers,\n` + | 102 | `Cheers,\n` + |
103 | `PeerTube.` | 103 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
104 | 104 | ||
105 | const emailPayload: EmailPayload = { | 105 | const emailPayload: EmailPayload = { |
106 | to, | 106 | to, |
107 | subject: channelName + ' just published a new video', | 107 | subject: CONFIG.EMAIL.OBJECT.PREFIX + channelName + ' just published a new video', |
108 | text | 108 | text |
109 | } | 109 | } |
110 | 110 | ||
@@ -119,11 +119,11 @@ class Emailer { | |||
119 | `Your ${followType} ${followingName} has a new subscriber: ${followerName}` + | 119 | `Your ${followType} ${followingName} has a new subscriber: ${followerName}` + |
120 | `\n\n` + | 120 | `\n\n` + |
121 | `Cheers,\n` + | 121 | `Cheers,\n` + |
122 | `PeerTube.` | 122 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
123 | 123 | ||
124 | const emailPayload: EmailPayload = { | 124 | const emailPayload: EmailPayload = { |
125 | to, | 125 | to, |
126 | subject: 'New follower on your channel ' + followingName, | 126 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New follower on your channel ' + followingName, |
127 | text | 127 | text |
128 | } | 128 | } |
129 | 129 | ||
@@ -137,11 +137,11 @@ class Emailer { | |||
137 | `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` + | 137 | `Your instance has a new follower: ${actorFollow.ActorFollower.url}${awaitingApproval}` + |
138 | `\n\n` + | 138 | `\n\n` + |
139 | `Cheers,\n` + | 139 | `Cheers,\n` + |
140 | `PeerTube.` | 140 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
141 | 141 | ||
142 | const emailPayload: EmailPayload = { | 142 | const emailPayload: EmailPayload = { |
143 | to, | 143 | to, |
144 | subject: 'New instance follower', | 144 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New instance follower', |
145 | text | 145 | text |
146 | } | 146 | } |
147 | 147 | ||
@@ -157,11 +157,11 @@ class Emailer { | |||
157 | `You can view it on ${videoUrl} ` + | 157 | `You can view it on ${videoUrl} ` + |
158 | `\n\n` + | 158 | `\n\n` + |
159 | `Cheers,\n` + | 159 | `Cheers,\n` + |
160 | `PeerTube.` | 160 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
161 | 161 | ||
162 | const emailPayload: EmailPayload = { | 162 | const emailPayload: EmailPayload = { |
163 | to, | 163 | to, |
164 | subject: `Your video ${video.name} is published`, | 164 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video ${video.name} is published`, |
165 | text | 165 | text |
166 | } | 166 | } |
167 | 167 | ||
@@ -177,11 +177,11 @@ class Emailer { | |||
177 | `You can view the imported video on ${videoUrl} ` + | 177 | `You can view the imported video on ${videoUrl} ` + |
178 | `\n\n` + | 178 | `\n\n` + |
179 | `Cheers,\n` + | 179 | `Cheers,\n` + |
180 | `PeerTube.` | 180 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
181 | 181 | ||
182 | const emailPayload: EmailPayload = { | 182 | const emailPayload: EmailPayload = { |
183 | to, | 183 | to, |
184 | subject: `Your video import ${videoImport.getTargetIdentifier()} is finished`, | 184 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} is finished`, |
185 | text | 185 | text |
186 | } | 186 | } |
187 | 187 | ||
@@ -197,11 +197,11 @@ class Emailer { | |||
197 | `See your videos import dashboard for more information: ${importUrl}` + | 197 | `See your videos import dashboard for more information: ${importUrl}` + |
198 | `\n\n` + | 198 | `\n\n` + |
199 | `Cheers,\n` + | 199 | `Cheers,\n` + |
200 | `PeerTube.` | 200 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
201 | 201 | ||
202 | const emailPayload: EmailPayload = { | 202 | const emailPayload: EmailPayload = { |
203 | to, | 203 | to, |
204 | subject: `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, | 204 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Your video import ${videoImport.getTargetIdentifier()} encountered an error`, |
205 | text | 205 | text |
206 | } | 206 | } |
207 | 207 | ||
@@ -219,11 +219,11 @@ class Emailer { | |||
219 | `You can view it on ${commentUrl} ` + | 219 | `You can view it on ${commentUrl} ` + |
220 | `\n\n` + | 220 | `\n\n` + |
221 | `Cheers,\n` + | 221 | `Cheers,\n` + |
222 | `PeerTube.` | 222 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
223 | 223 | ||
224 | const emailPayload: EmailPayload = { | 224 | const emailPayload: EmailPayload = { |
225 | to, | 225 | to, |
226 | subject: 'New comment on your video ' + video.name, | 226 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New comment on your video ' + video.name, |
227 | text | 227 | text |
228 | } | 228 | } |
229 | 229 | ||
@@ -241,11 +241,11 @@ class Emailer { | |||
241 | `You can view the comment on ${commentUrl} ` + | 241 | `You can view the comment on ${commentUrl} ` + |
242 | `\n\n` + | 242 | `\n\n` + |
243 | `Cheers,\n` + | 243 | `Cheers,\n` + |
244 | `PeerTube.` | 244 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
245 | 245 | ||
246 | const emailPayload: EmailPayload = { | 246 | const emailPayload: EmailPayload = { |
247 | to, | 247 | to, |
248 | subject: 'Mention on video ' + video.name, | 248 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Mention on video ' + video.name, |
249 | text | 249 | text |
250 | } | 250 | } |
251 | 251 | ||
@@ -258,11 +258,11 @@ class Emailer { | |||
258 | const text = `Hi,\n\n` + | 258 | const text = `Hi,\n\n` + |
259 | `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + | 259 | `${WEBSERVER.HOST} received an abuse for the following video ${videoUrl}\n\n` + |
260 | `Cheers,\n` + | 260 | `Cheers,\n` + |
261 | `PeerTube.` | 261 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
262 | 262 | ||
263 | const emailPayload: EmailPayload = { | 263 | const emailPayload: EmailPayload = { |
264 | to, | 264 | to, |
265 | subject: '[PeerTube] Received a video abuse', | 265 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Received a video abuse', |
266 | text | 266 | text |
267 | } | 267 | } |
268 | 268 | ||
@@ -281,11 +281,11 @@ class Emailer { | |||
281 | `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` + | 281 | `A full list of auto-blacklisted videos can be reviewed here: ${VIDEO_AUTO_BLACKLIST_URL}` + |
282 | `\n\n` + | 282 | `\n\n` + |
283 | `Cheers,\n` + | 283 | `Cheers,\n` + |
284 | `PeerTube.` | 284 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
285 | 285 | ||
286 | const emailPayload: EmailPayload = { | 286 | const emailPayload: EmailPayload = { |
287 | to, | 287 | to, |
288 | subject: '[PeerTube] An auto-blacklisted video is awaiting review', | 288 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'An auto-blacklisted video is awaiting review', |
289 | text | 289 | text |
290 | } | 290 | } |
291 | 291 | ||
@@ -296,11 +296,11 @@ class Emailer { | |||
296 | const text = `Hi,\n\n` + | 296 | const text = `Hi,\n\n` + |
297 | `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` + | 297 | `User ${user.username} just registered on ${WEBSERVER.HOST} PeerTube instance.\n\n` + |
298 | `Cheers,\n` + | 298 | `Cheers,\n` + |
299 | `PeerTube.` | 299 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
300 | 300 | ||
301 | const emailPayload: EmailPayload = { | 301 | const emailPayload: EmailPayload = { |
302 | to, | 302 | to, |
303 | subject: '[PeerTube] New user registration on ' + WEBSERVER.HOST, | 303 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'New user registration on ' + WEBSERVER.HOST, |
304 | text | 304 | text |
305 | } | 305 | } |
306 | 306 | ||
@@ -318,11 +318,11 @@ class Emailer { | |||
318 | blockedString + | 318 | blockedString + |
319 | '\n\n' + | 319 | '\n\n' + |
320 | 'Cheers,\n' + | 320 | 'Cheers,\n' + |
321 | `PeerTube.` | 321 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
322 | 322 | ||
323 | const emailPayload: EmailPayload = { | 323 | const emailPayload: EmailPayload = { |
324 | to, | 324 | to, |
325 | subject: `[PeerTube] Video ${videoName} blacklisted`, | 325 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${videoName} blacklisted`, |
326 | text | 326 | text |
327 | } | 327 | } |
328 | 328 | ||
@@ -336,11 +336,11 @@ class Emailer { | |||
336 | `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` + | 336 | `Your video ${video.name} (${videoUrl}) on ${WEBSERVER.HOST} has been unblacklisted.` + |
337 | '\n\n' + | 337 | '\n\n' + |
338 | 'Cheers,\n' + | 338 | 'Cheers,\n' + |
339 | `PeerTube.` | 339 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
340 | 340 | ||
341 | const emailPayload: EmailPayload = { | 341 | const emailPayload: EmailPayload = { |
342 | to, | 342 | to, |
343 | subject: `[PeerTube] Video ${video.name} unblacklisted`, | 343 | subject: CONFIG.EMAIL.OBJECT.PREFIX + `Video ${video.name} unblacklisted`, |
344 | text | 344 | text |
345 | } | 345 | } |
346 | 346 | ||
@@ -353,11 +353,11 @@ class Emailer { | |||
353 | `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + | 353 | `Please follow this link to reset it: ${resetPasswordUrl}\n\n` + |
354 | `If you are not the person who initiated this request, please ignore this email.\n\n` + | 354 | `If you are not the person who initiated this request, please ignore this email.\n\n` + |
355 | `Cheers,\n` + | 355 | `Cheers,\n` + |
356 | `PeerTube.` | 356 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
357 | 357 | ||
358 | const emailPayload: EmailPayload = { | 358 | const emailPayload: EmailPayload = { |
359 | to: [ to ], | 359 | to: [ to ], |
360 | subject: 'Reset your PeerTube password', | 360 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Reset your password', |
361 | text | 361 | text |
362 | } | 362 | } |
363 | 363 | ||
@@ -370,11 +370,11 @@ class Emailer { | |||
370 | `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + | 370 | `Please follow this link to verify this email belongs to you: ${verifyEmailUrl}\n\n` + |
371 | `If you are not the person who initiated this request, please ignore this email.\n\n` + | 371 | `If you are not the person who initiated this request, please ignore this email.\n\n` + |
372 | `Cheers,\n` + | 372 | `Cheers,\n` + |
373 | `PeerTube.` | 373 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
374 | 374 | ||
375 | const emailPayload: EmailPayload = { | 375 | const emailPayload: EmailPayload = { |
376 | to: [ to ], | 376 | to: [ to ], |
377 | subject: 'Verify your PeerTube email', | 377 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Verify your email', |
378 | text | 378 | text |
379 | } | 379 | } |
380 | 380 | ||
@@ -390,12 +390,12 @@ class Emailer { | |||
390 | blockedString + | 390 | blockedString + |
391 | '\n\n' + | 391 | '\n\n' + |
392 | 'Cheers,\n' + | 392 | 'Cheers,\n' + |
393 | `PeerTube.` | 393 | `${CONFIG.EMAIL.BODY.SIGNATURE}` |
394 | 394 | ||
395 | const to = user.email | 395 | const to = user.email |
396 | const emailPayload: EmailPayload = { | 396 | const emailPayload: EmailPayload = { |
397 | to: [ to ], | 397 | to: [ to ], |
398 | subject: '[PeerTube] Account ' + blockedWord, | 398 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Account ' + blockedWord, |
399 | text | 399 | text |
400 | } | 400 | } |
401 | 401 | ||
@@ -415,7 +415,7 @@ class Emailer { | |||
415 | fromDisplayName: fromEmail, | 415 | fromDisplayName: fromEmail, |
416 | replyTo: fromEmail, | 416 | replyTo: fromEmail, |
417 | to: [ CONFIG.ADMIN.EMAIL ], | 417 | to: [ CONFIG.ADMIN.EMAIL ], |
418 | subject: '[PeerTube] Contact form submitted', | 418 | subject: CONFIG.EMAIL.OBJECT.PREFIX + 'Contact form submitted', |
419 | text | 419 | text |
420 | } | 420 | } |
421 | 421 | ||