Fix sitemap endpoint

pull/2567/head
Chocobozzz 2020-03-11 08:40:13 +01:00
parent cd7ec86f5c
commit fab6746354
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 14 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import { buildDirectionAndField, createSafeIn } from '@server/models/utils'
import { Model } from 'sequelize-typescript'
import { MUserAccountId, MUserId } from '@server/typings/models'
import validator from 'validator'
import { exists } from '@server/helpers/custom-validators/misc'
export type BuildVideosQueryOptions = {
attributes?: string[]
@ -312,14 +313,21 @@ function buildListQuery (model: typeof Model, options: BuildVideosQueryOptions)
let suffix = ''
let order = ''
if (options.isCount !== true) {
const count = parseInt(options.count + '', 10)
const start = parseInt(options.start + '', 10)
order = buildOrder(model, options.sort)
if (exists(options.sort)) {
order = buildOrder(model, options.sort)
suffix += `${order} `
}
suffix = order + ' ' +
'LIMIT ' + count + ' ' +
'OFFSET ' + start
if (exists(options.count)) {
const count = parseInt(options.count + '', 10)
suffix += `LIMIT ${count} `
}
if (exists(options.start)) {
const start = parseInt(options.start + '', 10)
suffix += `OFFSET ${start} `
}
}
const cteString = cte.length !== 0