import { UserAdminFlag } from '../../shared/models/users/user-flag.model'
import { Hooks } from './plugins/hooks'
import { Notifier } from './notifier'
-import { MUser, MVideoBlacklist, MVideoWithBlacklistLight } from '@server/typings/models'
+import { MUser, MVideoBlacklistVideo, MVideoWithBlacklistLight } from '@server/typings/models'
async function autoBlacklistVideoIfNeeded (parameters: {
- video: MVideoWithBlacklistLight,
- user?: MUser,
- isRemote: boolean,
- isNew: boolean,
- notify?: boolean,
+ video: MVideoWithBlacklistLight
+ user?: MUser
+ isRemote: boolean
+ isNew: boolean
+ notify?: boolean
transaction?: Transaction
}) {
const { video, user, isRemote, isNew, notify = true, transaction } = parameters
- const doAutoBlacklist = await Hooks.wrapPromiseFun(
+ const doAutoBlacklist = await Hooks.wrapFun(
autoBlacklistNeeded,
{ video, user, isRemote, isNew },
'filter:video.auto-blacklist.result'
reason: 'Auto-blacklisted. Moderator review required.',
type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
}
- const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate<MVideoBlacklist>({
+ const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate<MVideoBlacklistVideo>({
where: {
videoId: video.id
},
})
video.VideoBlacklist = videoBlacklist
- if (notify) Notifier.Instance.notifyOnVideoAutoBlacklist(video)
+ videoBlacklist.Video = video
+
+ if (notify) Notifier.Instance.notifyOnVideoAutoBlacklist(videoBlacklist)
logger.info('Video %s auto-blacklisted.', video.uuid)
return true
}
-async function autoBlacklistNeeded (parameters: {
- video: MVideoWithBlacklistLight,
- isRemote: boolean,
- isNew: boolean,
+function autoBlacklistNeeded (parameters: {
+ video: MVideoWithBlacklistLight
+ isRemote: boolean
+ isNew: boolean
user?: MUser
}) {
const { user, video, isRemote, isNew } = parameters