import 'multer'
import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
import { getFormattedObjects } from '../../../helpers/utils'
import 'multer'
import { UserUpdateMe, UserVideoRate as FormattedUserVideoRate } from '../../../../shared'
import { getFormattedObjects } from '../../../helpers/utils'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { VideoImportModel } from '../../../models/video/video-import'
import { AccountModel } from '../../../models/account/account'
import { auditLoggerFactory, getAuditIdFromRes, UserAuditView } from '../../../helpers/audit-logger'
import { VideoImportModel } from '../../../models/video/video-import'
import { AccountModel } from '../../../models/account/account'
-async function getUserVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
- const user = res.locals.oauth.token.User as UserModel
+async function getUserVideos (req: express.Request, res: express.Response) {
+ const user = res.locals.oauth.token.User
const resultList = await VideoModel.listUserVideosForApi(
user.Account.id,
req.query.start as number,
const resultList = await VideoModel.listUserVideosForApi(
user.Account.id,
req.query.start as number,
-async function getUserVideoImports (req: express.Request, res: express.Response, next: express.NextFunction) {
- const user = res.locals.oauth.token.User as UserModel
+async function getUserVideoImports (req: express.Request, res: express.Response) {
+ const user = res.locals.oauth.token.User
const resultList = await VideoImportModel.listUserVideoImportsForApi(
user.id,
req.query.start as number,
const resultList = await VideoImportModel.listUserVideoImportsForApi(
user.id,
req.query.start as number,
// We did not load channels in res.locals.user
const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
return res.json(user.toFormattedJSON())
}
// We did not load channels in res.locals.user
const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
return res.json(user.toFormattedJSON())
}
// We did not load channels in res.locals.user
const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
// We did not load channels in res.locals.user
const user = await UserModel.loadByUsernameAndPopulateChannels(res.locals.oauth.token.user.username)
const videoQuotaUsed = await UserModel.getOriginalVideoFileTotalFromUser(user)
async function updateMe (req: express.Request, res: express.Response) {
const body: UserUpdateMe = req.body
async function updateMe (req: express.Request, res: express.Response) {
const body: UserUpdateMe = req.body
const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
if (body.password !== undefined) user.password = body.password
const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
if (body.password !== undefined) user.password = body.password
async function updateMyAvatar (req: express.Request, res: express.Response) {
const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
async function updateMyAvatar (req: express.Request, res: express.Response) {
const avatarPhysicalFile = req.files[ 'avatarfile' ][ 0 ]
const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
const userAccount = await AccountModel.load(user.Account.id)
const oldUserAuditView = new UserAuditView(user.toFormattedJSON())
const userAccount = await AccountModel.load(user.Account.id)