Add filter inputs for blacklisted videos and muted accounts/servers

This commit is contained in:
Rigel Kent 2020-04-19 14:11:40 +02:00 committed by Rigel Kent
parent aeb1bed983
commit e0a929179a
19 changed files with 202 additions and 61 deletions

View file

@ -1,7 +1,7 @@
import { Model, Sequelize } from 'sequelize-typescript'
import validator from 'validator'
import { Col } from 'sequelize/types/lib/utils'
import { literal, OrderItem } from 'sequelize'
import { literal, OrderItem, Op } from 'sequelize'
type Primitive = string | Function | number | boolean | Symbol | undefined | null
type DeepOmitHelper<T, K extends keyof T> = {
@ -207,6 +207,16 @@ function buildDirectionAndField (value: string) {
return { direction, field }
}
function searchAttribute (sourceField, targetField) {
return sourceField
? {
[targetField]: {
[Op.iLike]: `%${sourceField}%`
}
}
: {}
}
// ---------------------------------------------------------------------------
export {
@ -228,7 +238,8 @@ export {
parseAggregateResult,
getFollowsSort,
buildDirectionAndField,
createSafeIn
createSafeIn,
searchAttribute
}
// ---------------------------------------------------------------------------