+ if (!video) videoComment = await VideoCommentModel.loadByUrlAndPopulateAccountAndVideo(uri, t)
+ if (!videoComment) flaggedAccount = await AccountModel.loadByUrl(uri, t)
+
+ if (!video && !videoComment && !flaggedAccount) {
+ logger.warn('Cannot flag unknown entity %s.', object)
+ return
+ }
+
+ const baseAbuse = {
+ reporterAccountId: reporterAccount.id,
+ reason: flag.content,
+ state: AbuseState.PENDING,
+ predefinedReasons
+ }
+
+ if (video) {
+ return createVideoAbuse({
+ baseAbuse,
+ startAt,
+ endAt,
+ reporterAccount,
+ transaction: t,
+ videoInstance: video,
+ skipNotification: false
+ })
+ }
+
+ if (videoComment) {
+ return createVideoCommentAbuse({
+ baseAbuse,
+ reporterAccount,
+ transaction: t,
+ commentInstance: videoComment,
+ skipNotification: false
+ })
+ }
+
+ return await createAccountAbuse({
+ baseAbuse,
+ reporterAccount,
+ transaction: t,
+ accountInstance: flaggedAccount,
+ skipNotification: false
+ })
+ })
+ } catch (err) {
+ logger.debug('Cannot process report of %s', getAPId(object), { err })
+ }
+ }