Add ability to search video channels
This commit is contained in:
parent
240085d005
commit
f37dc0dd14
35 changed files with 670 additions and 145 deletions
|
@ -1,12 +1,13 @@
|
|||
import * as express from 'express'
|
||||
import 'express-validator'
|
||||
import { body, param } from 'express-validator/check'
|
||||
import { body, param, query } from 'express-validator/check'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { areValidationErrors } from './utils'
|
||||
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
|
||||
import { isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { areValidActorHandles, isValidActorHandle } from '../../helpers/custom-validators/activitypub/actor'
|
||||
import { UserModel } from '../../models/account/user'
|
||||
import { CONFIG } from '../../initializers'
|
||||
import { toArray } from '../../helpers/custom-validators/misc'
|
||||
|
||||
const userSubscriptionAddValidator = [
|
||||
body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
|
||||
|
@ -20,6 +21,20 @@ const userSubscriptionAddValidator = [
|
|||
}
|
||||
]
|
||||
|
||||
const areSubscriptionsExistValidator = [
|
||||
query('uris')
|
||||
.customSanitizer(toArray)
|
||||
.custom(areValidActorHandles).withMessage('Should have a valid uri array'),
|
||||
|
||||
(req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||
logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })
|
||||
|
||||
if (areValidationErrors(req, res)) return
|
||||
|
||||
return next()
|
||||
}
|
||||
]
|
||||
|
||||
const userSubscriptionGetValidator = [
|
||||
param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'),
|
||||
|
||||
|
@ -32,7 +47,7 @@ const userSubscriptionGetValidator = [
|
|||
if (host === CONFIG.WEBSERVER.HOST) host = null
|
||||
|
||||
const user: UserModel = res.locals.oauth.token.User
|
||||
const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHost(user.Account.Actor.id, name, host)
|
||||
const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host)
|
||||
|
||||
if (!subscription || !subscription.ActorFollowing.VideoChannel) {
|
||||
return res
|
||||
|
@ -51,8 +66,7 @@ const userSubscriptionGetValidator = [
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
areSubscriptionsExistValidator,
|
||||
userSubscriptionAddValidator,
|
||||
userSubscriptionGetValidator
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue