aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/emailer.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-30 16:50:12 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-09-04 16:24:58 +0200
commit8424c4026afd7304880a4ce8138a04ffb3d8c938 (patch)
tree5b42625a59307b03333aa7d293b40b4c90da8f73 /server/lib/emailer.ts
parentf69ec5f340638ef577e8f5b9b1fb844778656a1f (diff)
downloadPeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.tar.gz
PeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.tar.zst
PeerTube-8424c4026afd7304880a4ce8138a04ffb3d8c938.zip
Add auto follow back support for instances
Diffstat (limited to 'server/lib/emailer.ts')
-rw-r--r--server/lib/emailer.ts33
1 files changed, 28 insertions, 5 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 76349ef8f..bd3d4f252 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -6,8 +6,15 @@ import { JobQueue } from './job-queue'
6import { EmailPayload } from './job-queue/handlers/email' 6import { EmailPayload } from './job-queue/handlers/email'
7import { readFileSync } from 'fs-extra' 7import { readFileSync } from 'fs-extra'
8import { WEBSERVER } from '../initializers/constants' 8import { WEBSERVER } from '../initializers/constants'
9import { MCommentOwnerVideo, MVideo, MVideoAbuseVideo, MVideoAccountLight, MVideoBlacklistVideo } from '../typings/models/video' 9import {
10import { MActorFollowActors, MActorFollowFollowingFullFollowerAccount, MUser } from '../typings/models' 10 MCommentOwnerVideo,
11 MVideo,
12 MVideoAbuseVideo,
13 MVideoAccountLight,
14 MVideoBlacklistLightVideo,
15 MVideoBlacklistVideo
16} from '../typings/models/video'
17import { MActorFollowActors, MActorFollowFull, MUser } from '../typings/models'
11import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import' 18import { MVideoImport, MVideoImportVideo } from '@server/typings/models/video/video-import'
12 19
13type SendEmailOptions = { 20type SendEmailOptions = {
@@ -107,7 +114,7 @@ class Emailer {
107 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 114 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
108 } 115 }
109 116
110 addNewFollowNotification (to: string[], actorFollow: MActorFollowFollowingFullFollowerAccount, followType: 'account' | 'channel') { 117 addNewFollowNotification (to: string[], actorFollow: MActorFollowFull, followType: 'account' | 'channel') {
111 const followerName = actorFollow.ActorFollower.Account.getDisplayName() 118 const followerName = actorFollow.ActorFollower.Account.getDisplayName()
112 const followingName = (actorFollow.ActorFollowing.VideoChannel || actorFollow.ActorFollowing.Account).getDisplayName() 119 const followingName = (actorFollow.ActorFollowing.VideoChannel || actorFollow.ActorFollowing.Account).getDisplayName()
113 120
@@ -144,6 +151,22 @@ class Emailer {
144 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 151 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
145 } 152 }
146 153
154 addAutoInstanceFollowingNotification (to: string[], actorFollow: MActorFollowActors) {
155 const text = `Hi dear admin,\n\n` +
156 `Your instance automatically followed a new instance: ${actorFollow.ActorFollowing.url}` +
157 `\n\n` +
158 `Cheers,\n` +
159 `${CONFIG.EMAIL.BODY.SIGNATURE}`
160
161 const emailPayload: EmailPayload = {
162 to,
163 subject: CONFIG.EMAIL.SUBJECT.PREFIX + 'Auto instance following',
164 text
165 }
166
167 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
168 }
169
147 myVideoPublishedNotification (to: string[], video: MVideo) { 170 myVideoPublishedNotification (to: string[], video: MVideo) {
148 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() 171 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
149 172
@@ -265,9 +288,9 @@ class Emailer {
265 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 288 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
266 } 289 }
267 290
268 addVideoAutoBlacklistModeratorsNotification (to: string[], video: MVideo) { 291 addVideoAutoBlacklistModeratorsNotification (to: string[], videoBlacklist: MVideoBlacklistLightVideo) {
269 const VIDEO_AUTO_BLACKLIST_URL = WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list' 292 const VIDEO_AUTO_BLACKLIST_URL = WEBSERVER.URL + '/admin/moderation/video-auto-blacklist/list'
270 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() 293 const videoUrl = WEBSERVER.URL + videoBlacklist.Video.getWatchStaticPath()
271 294
272 const text = `Hi,\n\n` + 295 const text = `Hi,\n\n` +
273 `A recently added video was auto-blacklisted and requires moderator review before publishing.` + 296 `A recently added video was auto-blacklisted and requires moderator review before publishing.` +