server accounts/videos: trigger filter hook
This commit is contained in:
parent
05e85b59c7
commit
1bfc07e4cc
|
@ -2,6 +2,7 @@ import * as express from 'express'
|
||||||
import { getServerActor } from '@server/models/application/application'
|
import { getServerActor } from '@server/models/application/application'
|
||||||
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
import { buildNSFWFilter, getCountVideos, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
|
||||||
import { getFormattedObjects } from '../../helpers/utils'
|
import { getFormattedObjects } from '../../helpers/utils'
|
||||||
|
import { Hooks } from '../../lib/plugins/hooks'
|
||||||
import { JobQueue } from '../../lib/job-queue'
|
import { JobQueue } from '../../lib/job-queue'
|
||||||
import {
|
import {
|
||||||
asyncMiddleware,
|
asyncMiddleware,
|
||||||
|
@ -158,7 +159,7 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
|
||||||
const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
|
const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
|
||||||
const countVideos = getCountVideos(req)
|
const countVideos = getCountVideos(req)
|
||||||
|
|
||||||
const resultList = await VideoModel.listForApi({
|
const apiOptions = await Hooks.wrapObject({
|
||||||
followerActorId,
|
followerActorId,
|
||||||
start: req.query.start,
|
start: req.query.start,
|
||||||
count: req.query.count,
|
count: req.query.count,
|
||||||
|
@ -175,7 +176,13 @@ async function listAccountVideos (req: express.Request, res: express.Response) {
|
||||||
accountId: account.id,
|
accountId: account.id,
|
||||||
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
|
user: res.locals.oauth ? res.locals.oauth.token.User : undefined,
|
||||||
countVideos
|
countVideos
|
||||||
})
|
}, 'filter:api.videos.list.params')
|
||||||
|
|
||||||
|
const resultList = await Hooks.wrapPromiseFun(
|
||||||
|
VideoModel.listForApi,
|
||||||
|
apiOptions,
|
||||||
|
'filter:api.videos.list.result'
|
||||||
|
)
|
||||||
|
|
||||||
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
return res.json(getFormattedObjects(resultList.data, resultList.total))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue