diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-04-19 14:11:40 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-05-01 16:41:02 +0200 |
commit | e0a929179a9dc76e035ca7fda2b61d5ff46afbc5 (patch) | |
tree | 1e6615c612ad6995dcb1c3619342dbbc7db35034 /server/models/utils.ts | |
parent | aeb1bed9835b3b092832160245080d4023c14d91 (diff) | |
download | PeerTube-e0a929179a9dc76e035ca7fda2b61d5ff46afbc5.tar.gz PeerTube-e0a929179a9dc76e035ca7fda2b61d5ff46afbc5.tar.zst PeerTube-e0a929179a9dc76e035ca7fda2b61d5ff46afbc5.zip |
Add filter inputs for blacklisted videos and muted accounts/servers
Diffstat (limited to 'server/models/utils.ts')
-rw-r--r-- | server/models/utils.ts | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/models/utils.ts b/server/models/utils.ts index 06ff05864..7137419a2 100644 --- a/server/models/utils.ts +++ b/server/models/utils.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Model, Sequelize } from 'sequelize-typescript' | 1 | import { Model, Sequelize } from 'sequelize-typescript' |
2 | import validator from 'validator' | 2 | import validator from 'validator' |
3 | import { Col } from 'sequelize/types/lib/utils' | 3 | import { Col } from 'sequelize/types/lib/utils' |
4 | import { literal, OrderItem } from 'sequelize' | 4 | import { literal, OrderItem, Op } from 'sequelize' |
5 | 5 | ||
6 | type Primitive = string | Function | number | boolean | Symbol | undefined | null | 6 | type Primitive = string | Function | number | boolean | Symbol | undefined | null |
7 | type DeepOmitHelper<T, K extends keyof T> = { | 7 | type DeepOmitHelper<T, K extends keyof T> = { |
@@ -207,6 +207,16 @@ function buildDirectionAndField (value: string) { | |||
207 | return { direction, field } | 207 | return { direction, field } |
208 | } | 208 | } |
209 | 209 | ||
210 | function searchAttribute (sourceField, targetField) { | ||
211 | return sourceField | ||
212 | ? { | ||
213 | [targetField]: { | ||
214 | [Op.iLike]: `%${sourceField}%` | ||
215 | } | ||
216 | } | ||
217 | : {} | ||
218 | } | ||
219 | |||
210 | // --------------------------------------------------------------------------- | 220 | // --------------------------------------------------------------------------- |
211 | 221 | ||
212 | export { | 222 | export { |
@@ -228,7 +238,8 @@ export { | |||
228 | parseAggregateResult, | 238 | parseAggregateResult, |
229 | getFollowsSort, | 239 | getFollowsSort, |
230 | buildDirectionAndField, | 240 | buildDirectionAndField, |
231 | createSafeIn | 241 | createSafeIn, |
242 | searchAttribute | ||
232 | } | 243 | } |
233 | 244 | ||
234 | // --------------------------------------------------------------------------- | 245 | // --------------------------------------------------------------------------- |