import { areValidationErrors } from './shared'
const userSubscriptionListValidator = [
- query('search').optional().not().isEmpty().withMessage('Should have a valid search'),
+ query('search')
+ .optional()
+ .not().isEmpty(),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionListValidator parameters', { parameters: req.query })
]
const userSubscriptionAddValidator = [
- body('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
+ body('uri')
+ .custom(isValidActorHandle).withMessage('Should have a valid URI to follow (username@domain)'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionAddValidator parameters', { parameters: req.body })
const areSubscriptionsExistValidator = [
query('uris')
.customSanitizer(toArray)
- .custom(areValidActorHandles).withMessage('Should have a valid uri array'),
+ .custom(areValidActorHandles).withMessage('Should have a valid array of URIs'),
(req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking areSubscriptionsExistValidator parameters', { parameters: req.query })
]
const userSubscriptionGetValidator = [
- param('uri').custom(isValidActorHandle).withMessage('Should have a valid URI to unfollow'),
+ param('uri')
+ .custom(isValidActorHandle),
async (req: express.Request, res: express.Response, next: express.NextFunction) => {
logger.debug('Checking userSubscriptionGetValidator parameters', { parameters: req.params })
if (host === WEBSERVER.HOST) host = null
const user = res.locals.oauth.token.User
- const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI(user.Account.Actor.id, name, host)
+ const subscription = await ActorFollowModel.loadByActorAndTargetNameAndHostForAPI({
+ actorId: user.Account.Actor.id,
+ targetName: name,
+ targetHost: host,
+ state: 'accepted'
+ })
if (!subscription || !subscription.ActorFollowing.VideoChannel) {
return res.fail({