import { AbuseMessageModel } from '@server/models/abuse/abuse-message'
import { getServerActor } from '@server/models/application/application'
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
-import { HttpStatusCode } from '@shared/models'
-import { AbuseCreate, AbuseState, UserRight } from '../../../shared'
+import { AbuseCreate, AbuseState, HttpStatusCode, UserRight } from '@shared/models'
import { getFormattedObjects } from '../../helpers/utils'
import { sequelizeTypescript } from '../../initializers/database'
import {
const body: AbuseCreate = req.body
const { id } = await sequelizeTypescript.transaction(async t => {
- const reporterAccount = await AccountModel.load(res.locals.oauth.token.User.Account.id, t)
+ const user = res.locals.oauth.token.User
+ // Don't send abuse notification if reporter is an admin/moderator
+ const skipNotification = user.hasRight(UserRight.MANAGE_ABUSES)
+
+ const reporterAccount = await AccountModel.load(user.Account.id, t)
const predefinedReasons = body.predefinedReasons?.map(r => abusePredefinedReasonsMap[r])
const baseAbuse = {
reporterAccount,
transaction: t,
startAt: body.video.startAt,
- endAt: body.video.endAt
+ endAt: body.video.endAt,
+ skipNotification
})
}
baseAbuse,
commentInstance,
reporterAccount,
- transaction: t
+ transaction: t,
+ skipNotification
})
}
baseAbuse,
accountInstance,
reporterAccount,
- transaction: t
+ transaction: t,
+ skipNotification
})
})