aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/utils.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-04-19 14:11:40 +0200
committerRigel Kent <par@rigelk.eu>2020-05-01 16:41:02 +0200
commite0a929179a9dc76e035ca7fda2b61d5ff46afbc5 (patch)
tree1e6615c612ad6995dcb1c3619342dbbc7db35034 /server/models/utils.ts
parentaeb1bed9835b3b092832160245080d4023c14d91 (diff)
downloadPeerTube-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.ts15
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 @@
1import { Model, Sequelize } from 'sequelize-typescript' 1import { Model, Sequelize } from 'sequelize-typescript'
2import validator from 'validator' 2import validator from 'validator'
3import { Col } from 'sequelize/types/lib/utils' 3import { Col } from 'sequelize/types/lib/utils'
4import { literal, OrderItem } from 'sequelize' 4import { literal, OrderItem, Op } from 'sequelize'
5 5
6type Primitive = string | Function | number | boolean | Symbol | undefined | null 6type Primitive = string | Function | number | boolean | Symbol | undefined | null
7type DeepOmitHelper<T, K extends keyof T> = { 7type 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
210function searchAttribute (sourceField, targetField) {
211 return sourceField
212 ? {
213 [targetField]: {
214 [Op.iLike]: `%${sourceField}%`
215 }
216 }
217 : {}
218}
219
210// --------------------------------------------------------------------------- 220// ---------------------------------------------------------------------------
211 221
212export { 222export {
@@ -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// ---------------------------------------------------------------------------