import * as express from 'express'
import 'multer'
import { getFormattedObjects } from '../../../helpers/utils'
-import { CONFIG, sequelizeTypescript } from '../../../initializers'
+import { WEBSERVER } from '../../../initializers/constants'
import {
asyncMiddleware,
asyncRetryTransactionMiddleware,
userSubscriptionGetValidator
} from '../../../middlewares'
import { areSubscriptionsExistValidator, userSubscriptionsSortValidator, videosSortValidator } from '../../../middlewares/validators'
-import { UserModel } from '../../../models/account/user'
import { VideoModel } from '../../../models/video/video'
import { buildNSFWFilter } from '../../../helpers/express-utils'
import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { JobQueue } from '../../../lib/job-queue'
import { logger } from '../../../helpers/logger'
+import { sequelizeTypescript } from '../../../initializers/database'
const mySubscriptionsRouter = express.Router()
async function areSubscriptionsExist (req: express.Request, res: express.Response) {
const uris = req.query.uris as string[]
- const user = res.locals.oauth.token.User as UserModel
+ const user = res.locals.oauth.token.User
const handles = uris.map(u => {
let [ name, host ] = u.split('@')
- if (host === CONFIG.WEBSERVER.HOST) host = null
+ if (host === WEBSERVER.HOST) host = null
return { name, host, uri: u }
})
}
async function addUserSubscription (req: express.Request, res: express.Response) {
- const user = res.locals.oauth.token.User as UserModel
+ const user = res.locals.oauth.token.User
const [ name, host ] = req.body.uri.split('@')
const payload = {
}
function getUserSubscription (req: express.Request, res: express.Response) {
- const subscription: ActorFollowModel = res.locals.subscription
+ const subscription = res.locals.subscription
return res.json(subscription.ActorFollowing.VideoChannel.toFormattedJSON())
}
async function deleteUserSubscription (req: express.Request, res: express.Response) {
- const subscription: ActorFollowModel = res.locals.subscription
+ const subscription = res.locals.subscription
await sequelizeTypescript.transaction(async t => {
return subscription.destroy({ transaction: t })
}
async function getUserSubscriptions (req: express.Request, res: express.Response) {
- const user = res.locals.oauth.token.User as UserModel
+ const user = res.locals.oauth.token.User
const actorId = user.Account.Actor.id
const resultList = await ActorFollowModel.listSubscriptionsForApi(actorId, req.query.start, req.query.count, req.query.sort)
return res.json(getFormattedObjects(resultList.data, resultList.total))
}
-async function getUserSubscriptionVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
- const user = res.locals.oauth.token.User as UserModel
+async function getUserSubscriptionVideos (req: express.Request, res: express.Response) {
+ const user = res.locals.oauth.token.User
const resultList = await VideoModel.listForApi({
start: req.query.start,
count: req.query.count,