aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/activitypub/process/process-flag.ts9
-rw-r--r--server/lib/moderation.ts29
2 files changed, 25 insertions, 13 deletions
diff --git a/server/lib/activitypub/process/process-flag.ts b/server/lib/activitypub/process/process-flag.ts
index 7ed409d0e..fd3e46e2b 100644
--- a/server/lib/activitypub/process/process-flag.ts
+++ b/server/lib/activitypub/process/process-flag.ts
@@ -75,7 +75,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
75 endAt, 75 endAt,
76 reporterAccount, 76 reporterAccount,
77 transaction: t, 77 transaction: t,
78 videoInstance: video 78 videoInstance: video,
79 skipNotification: false
79 }) 80 })
80 } 81 }
81 82
@@ -84,7 +85,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
84 baseAbuse, 85 baseAbuse,
85 reporterAccount, 86 reporterAccount,
86 transaction: t, 87 transaction: t,
87 commentInstance: videoComment 88 commentInstance: videoComment,
89 skipNotification: false
88 }) 90 })
89 } 91 }
90 92
@@ -92,7 +94,8 @@ async function processCreateAbuse (activity: ActivityCreate | ActivityFlag, byAc
92 baseAbuse, 94 baseAbuse,
93 reporterAccount, 95 reporterAccount,
94 transaction: t, 96 transaction: t,
95 accountInstance: flaggedAccount 97 accountInstance: flaggedAccount,
98 skipNotification: false
96 }) 99 })
97 }) 100 })
98 } catch (err) { 101 } catch (err) {
diff --git a/server/lib/moderation.ts b/server/lib/moderation.ts
index 456b615b2..c2565f867 100644
--- a/server/lib/moderation.ts
+++ b/server/lib/moderation.ts
@@ -107,8 +107,9 @@ async function createVideoAbuse (options: {
107 endAt: number 107 endAt: number
108 transaction: Transaction 108 transaction: Transaction
109 reporterAccount: MAccountDefault 109 reporterAccount: MAccountDefault
110 skipNotification: boolean
110}) { 111}) {
111 const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount } = options 112 const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount, skipNotification } = options
112 113
113 const associateFun = async (abuseInstance: MAbuseFull) => { 114 const associateFun = async (abuseInstance: MAbuseFull) => {
114 const videoAbuseInstance: MVideoAbuseVideoFull = await VideoAbuseModel.create({ 115 const videoAbuseInstance: MVideoAbuseVideoFull = await VideoAbuseModel.create({
@@ -129,6 +130,7 @@ async function createVideoAbuse (options: {
129 reporterAccount, 130 reporterAccount,
130 flaggedAccount: videoInstance.VideoChannel.Account, 131 flaggedAccount: videoInstance.VideoChannel.Account,
131 transaction, 132 transaction,
133 skipNotification,
132 associateFun 134 associateFun
133 }) 135 })
134} 136}
@@ -138,8 +140,9 @@ function createVideoCommentAbuse (options: {
138 commentInstance: MCommentOwnerVideo 140 commentInstance: MCommentOwnerVideo
139 transaction: Transaction 141 transaction: Transaction
140 reporterAccount: MAccountDefault 142 reporterAccount: MAccountDefault
143 skipNotification: boolean
141}) { 144}) {
142 const { baseAbuse, commentInstance, transaction, reporterAccount } = options 145 const { baseAbuse, commentInstance, transaction, reporterAccount, skipNotification } = options
143 146
144 const associateFun = async (abuseInstance: MAbuseFull) => { 147 const associateFun = async (abuseInstance: MAbuseFull) => {
145 const commentAbuseInstance: MCommentAbuseAccountVideo = await VideoCommentAbuseModel.create({ 148 const commentAbuseInstance: MCommentAbuseAccountVideo = await VideoCommentAbuseModel.create({
@@ -158,6 +161,7 @@ function createVideoCommentAbuse (options: {
158 reporterAccount, 161 reporterAccount,
159 flaggedAccount: commentInstance.Account, 162 flaggedAccount: commentInstance.Account,
160 transaction, 163 transaction,
164 skipNotification,
161 associateFun 165 associateFun
162 }) 166 })
163} 167}
@@ -167,8 +171,9 @@ function createAccountAbuse (options: {
167 accountInstance: MAccountDefault 171 accountInstance: MAccountDefault
168 transaction: Transaction 172 transaction: Transaction
169 reporterAccount: MAccountDefault 173 reporterAccount: MAccountDefault
174 skipNotification: boolean
170}) { 175}) {
171 const { baseAbuse, accountInstance, transaction, reporterAccount } = options 176 const { baseAbuse, accountInstance, transaction, reporterAccount, skipNotification } = options
172 177
173 const associateFun = () => { 178 const associateFun = () => {
174 return Promise.resolve({ isOwned: accountInstance.isOwned() }) 179 return Promise.resolve({ isOwned: accountInstance.isOwned() })
@@ -179,6 +184,7 @@ function createAccountAbuse (options: {
179 reporterAccount, 184 reporterAccount,
180 flaggedAccount: accountInstance, 185 flaggedAccount: accountInstance,
181 transaction, 186 transaction,
187 skipNotification,
182 associateFun 188 associateFun
183 }) 189 })
184} 190}
@@ -207,9 +213,10 @@ async function createAbuse (options: {
207 reporterAccount: MAccountDefault 213 reporterAccount: MAccountDefault
208 flaggedAccount: MAccountLight 214 flaggedAccount: MAccountLight
209 associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} > 215 associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} >
216 skipNotification: boolean
210 transaction: Transaction 217 transaction: Transaction
211}) { 218}) {
212 const { base, reporterAccount, flaggedAccount, associateFun, transaction } = options 219 const { base, reporterAccount, flaggedAccount, associateFun, transaction, skipNotification } = options
213 const auditLogger = auditLoggerFactory('abuse') 220 const auditLogger = auditLoggerFactory('abuse')
214 221
215 const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id }) 222 const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id })
@@ -227,13 +234,15 @@ async function createAbuse (options: {
227 const abuseJSON = abuseInstance.toFormattedAdminJSON() 234 const abuseJSON = abuseInstance.toFormattedAdminJSON()
228 auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON)) 235 auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON))
229 236
230 afterCommitIfTransaction(transaction, () => { 237 if (!skipNotification) {
231 Notifier.Instance.notifyOnNewAbuse({ 238 afterCommitIfTransaction(transaction, () => {
232 abuse: abuseJSON, 239 Notifier.Instance.notifyOnNewAbuse({
233 abuseInstance, 240 abuse: abuseJSON,
234 reporter: reporterAccount.Actor.getIdentifier() 241 abuseInstance,
242 reporter: reporterAccount.Actor.getIdentifier()
243 })
235 }) 244 })
236 }) 245 }
237 246
238 logger.info('Abuse report %d created.', abuseInstance.id) 247 logger.info('Abuse report %d created.', abuseInstance.id)
239 248