endAt: number
transaction: Transaction
reporterAccount: MAccountDefault
+ skipNotification: boolean
}) {
- const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount } = options
+ const { baseAbuse, videoInstance, startAt, endAt, transaction, reporterAccount, skipNotification } = options
const associateFun = async (abuseInstance: MAbuseFull) => {
const videoAbuseInstance: MVideoAbuseVideoFull = await VideoAbuseModel.create({
reporterAccount,
flaggedAccount: videoInstance.VideoChannel.Account,
transaction,
+ skipNotification,
associateFun
})
}
commentInstance: MCommentOwnerVideo
transaction: Transaction
reporterAccount: MAccountDefault
+ skipNotification: boolean
}) {
- const { baseAbuse, commentInstance, transaction, reporterAccount } = options
+ const { baseAbuse, commentInstance, transaction, reporterAccount, skipNotification } = options
const associateFun = async (abuseInstance: MAbuseFull) => {
const commentAbuseInstance: MCommentAbuseAccountVideo = await VideoCommentAbuseModel.create({
reporterAccount,
flaggedAccount: commentInstance.Account,
transaction,
+ skipNotification,
associateFun
})
}
accountInstance: MAccountDefault
transaction: Transaction
reporterAccount: MAccountDefault
+ skipNotification: boolean
}) {
- const { baseAbuse, accountInstance, transaction, reporterAccount } = options
+ const { baseAbuse, accountInstance, transaction, reporterAccount, skipNotification } = options
- const associateFun = async () => {
- return { isOwned: accountInstance.isOwned() }
+ const associateFun = () => {
+ return Promise.resolve({ isOwned: accountInstance.isOwned() })
}
return createAbuse({
reporterAccount,
flaggedAccount: accountInstance,
transaction,
+ skipNotification,
associateFun
})
}
reporterAccount: MAccountDefault
flaggedAccount: MAccountLight
associateFun: (abuseInstance: MAbuseFull) => Promise<{ isOwned: boolean} >
+ skipNotification: boolean
transaction: Transaction
}) {
- const { base, reporterAccount, flaggedAccount, associateFun, transaction } = options
+ const { base, reporterAccount, flaggedAccount, associateFun, transaction, skipNotification } = options
const auditLogger = auditLoggerFactory('abuse')
const abuseAttributes = Object.assign({}, base, { flaggedAccountId: flaggedAccount.id })
const abuseJSON = abuseInstance.toFormattedAdminJSON()
auditLogger.create(reporterAccount.Actor.getIdentifier(), new AbuseAuditView(abuseJSON))
- afterCommitIfTransaction(transaction, () => {
- Notifier.Instance.notifyOnNewAbuse({
- abuse: abuseJSON,
- abuseInstance,
- reporter: reporterAccount.Actor.getIdentifier()
+ if (!skipNotification) {
+ afterCommitIfTransaction(transaction, () => {
+ Notifier.Instance.notifyOnNewAbuse({
+ abuse: abuseJSON,
+ abuseInstance,
+ reporter: reporterAccount.Actor.getIdentifier()
+ })
})
- })
+ }
logger.info('Abuse report %d created.', abuseInstance.id)