X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Futils.ts;h=6a109056ff964c621d2694edb961c8380e1a126b;hb=21d68e68039a1eefbe6213fbde46e737e520ee7d;hp=e27625bc862c8a20504b0e12c0224d9539c598b3;hpb=1e4d2cb5aef11898585fae4053da4ebd0a69b480;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/utils.ts b/server/models/utils.ts index e27625bc8..6a109056f 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -74,8 +74,8 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or finalField = field } - const firstSort = typeof finalField === 'string' - ? finalField.split('.').concat([ direction ]) as any // FIXME: sequelize typings + const firstSort: OrderItem = typeof finalField === 'string' + ? finalField.split('.').concat([ direction ]) as OrderItem : [ finalField, direction ] return [ firstSort, lastSort ] @@ -84,7 +84,7 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or function getBlacklistSort (model: any, value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { const [ firstSort ] = getSort(value) - if (model) return [ [ literal(`"${model}.${firstSort[0]}" ${firstSort[1]}`) ], lastSort ] as any[] // FIXME: typings + if (model) return [ [ literal(`"${model}.${firstSort[0]}" ${firstSort[1]}`) ], lastSort ] as OrderItem[] return [ firstSort, lastSort ] } @@ -102,6 +102,10 @@ function getFollowsSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): } function isOutdated (model: { createdAt: Date, updatedAt: Date }, refreshInterval: number) { + if (!model.createdAt || !model.updatedAt) { + throw new Error('Miss createdAt & updatedAt attribuets to model') + } + const now = Date.now() const createdAtTime = model.createdAt.getTime() const updatedAtTime = model.updatedAt.getTime()