X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Futils.ts;h=70bfbdb8bfa4748dc770186c7a95b913454df570;hb=4b3145a7f8f5f1e24f9ea7874dee387204e65fcb;hp=83b2b8f03cba2ac31607088073e5e449cacbd910;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/utils.ts b/server/models/utils.ts index 83b2b8f03..70bfbdb8b 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts @@ -1,5 +1,4 @@ import { literal, Op, OrderItem, Sequelize } from 'sequelize' -import { Col } from 'sequelize/types/lib/utils' import validator from 'validator' type SortType = { sortModel: string, sortValue: string } @@ -8,7 +7,7 @@ type SortType = { sortModel: string, sortValue: string } function getSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): OrderItem[] { const { direction, field } = buildDirectionAndField(value) - let finalField: string | Col + let finalField: string | ReturnType if (field.toLowerCase() === 'match') { // Search finalField = Sequelize.col('similarity') @@ -65,7 +64,7 @@ function getVideoSort (value: string, lastSort: OrderItem = [ 'id', 'ASC' ]): Or ] } - let finalField: string | Col + let finalField: string | ReturnType // Alias if (field.toLowerCase() === 'match') { // Search @@ -74,8 +73,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 +83,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 ] } @@ -182,7 +181,7 @@ function buildServerIdsFollowedBy (actorId: any) { 'SELECT "actor"."serverId" FROM "actorFollow" ' + 'INNER JOIN "actor" ON actor.id = "actorFollow"."targetActorId" ' + 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + - ')' + ')' } function buildWhereIdOrUUID (id: number | string) { @@ -238,7 +237,8 @@ function searchAttribute (sourceField?: string, targetField?: string) { return { [targetField]: { - [Op.iLike]: `%${sourceField}%` + // FIXME: ts error + [Op.iLike as any]: `%${sourceField}%` } } }