X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Futils.ts;h=83b2b8f03cba2ac31607088073e5e449cacbd910;hb=d8a4c83b9f61791c2a2f4d8dd47fccde0e79d096;hp=ec51c66bfb81b9080f42963308c165af44c4a5fd;hpb=8e286cdca4ccfbd1ee5edc4b4446a6f81e7586a4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/utils.ts b/server/models/utils.ts index ec51c66bf..83b2b8f03 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -1,5 +1,4 @@ -import { literal, Op, OrderItem } from 'sequelize' -import { Model, Sequelize } from 'sequelize-typescript' +import { literal, Op, OrderItem, Sequelize } from 'sequelize' import { Col } from 'sequelize/types/lib/utils' import validator from 'validator' @@ -103,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() @@ -195,11 +198,11 @@ function parseAggregateResult (result: any) { return total } -const createSafeIn = (model: typeof Model, stringArr: (string | number)[]) => { +function createSafeIn (sequelize: Sequelize, stringArr: (string | number)[]) { return stringArr.map(t => { return t === null ? null - : model.sequelize.escape('' + t) + : sequelize.escape('' + t) }).join(', ') }