aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/emailer.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index 3faeffd77..a1212878f 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -108,6 +108,55 @@ class Emailer {
108 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload }) 108 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
109 } 109 }
110 110
111 async addVideoBlacklistReportJob (videoId: number, reason?: string) {
112 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
113 if (!video) throw new Error('Unknown Video id during Blacklist report.')
114 // It's not our user
115 if (video.remote === true) return
116
117 const user = await UserModel.loadById(video.VideoChannel.Account.userId)
118
119 const reasonString = reason ? ` for the following reason: ${reason}` : ''
120 const blockedString = `Your video ${video.name} on ${CONFIG.WEBSERVER.HOST} has been blacklisted${reasonString}.`
121
122 const text = 'Hi,\n\n' +
123 blockedString +
124 '\n\n' +
125 'Cheers,\n' +
126 `PeerTube.`
127
128 const to = user.email
129 const emailPayload: EmailPayload = {
130 to: [ to ],
131 subject: `[PeerTube] Video ${video.name} blacklisted`,
132 text
133 }
134
135 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
136 }
137
138 async addVideoUnblacklistReportJob (videoId: number) {
139 const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
140 if (!video) throw new Error('Unknown Video id during Blacklist report.')
141
142 const user = await UserModel.loadById(video.VideoChannel.Account.userId)
143
144 const text = 'Hi,\n\n' +
145 `Your video ${video.name} on ${CONFIG.WEBSERVER.HOST} has been unblacklisted.` +
146 '\n\n' +
147 'Cheers,\n' +
148 `PeerTube.`
149
150 const to = user.email
151 const emailPayload: EmailPayload = {
152 to: [ to ],
153 subject: `[PeerTube] Video ${video.name} unblacklisted`,
154 text
155 }
156
157 return JobQueue.Instance.createJob({ type: 'email', payload: emailPayload })
158 }
159
111 addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) { 160 addUserBlockJob (user: UserModel, blocked: boolean, reason?: string) {
112 const reasonString = reason ? ` for the following reason: ${reason}` : '' 161 const reasonString = reason ? ` for the following reason: ${reason}` : ''
113 const blockedWord = blocked ? 'blocked' : 'unblocked' 162 const blockedWord = blocked ? 'blocked' : 'unblocked'