mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-18 17:21:33 +00:00
Fixed type-is and keyword exclusion logic
This commit is contained in:
parent
f189d86abc
commit
417adbde93
@ -1177,17 +1177,19 @@ self.list = async (req, res) => {
|
||||
// Then, refine using type-is flags
|
||||
this.andWhere(function () {
|
||||
for (const type of filterObj.typeIs) {
|
||||
const patterns = utils[`${type}Exts`].map(ext => `%${ext}`)
|
||||
|
||||
let func
|
||||
let operator
|
||||
if (filterObj.flags[`is${type}`] === true)
|
||||
if (filterObj.flags[`is${type}`] === true) {
|
||||
func = 'orWhere'
|
||||
operator = 'like'
|
||||
else if (filterObj.flags[`is${type}`] === false)
|
||||
} else if (filterObj.flags[`is${type}`] === false) {
|
||||
func = 'andWhere'
|
||||
operator = 'not like'
|
||||
}
|
||||
|
||||
if (operator)
|
||||
for (const pattern of patterns)
|
||||
this.orWhere('name', operator, pattern)
|
||||
if (func)
|
||||
for (const pattern of utils[`${type}Exts`].map(ext => `%${ext}`))
|
||||
this[func]('name', operator, pattern)
|
||||
}
|
||||
})
|
||||
|
||||
@ -1202,7 +1204,7 @@ self.list = async (req, res) => {
|
||||
this.andWhere(function () {
|
||||
if (!filterObj.queries.exclude.text) return
|
||||
for (const pattern of filterObj.queries.exclude.text)
|
||||
this.orWhere('name', 'not like', pattern)
|
||||
this.andWhere('name', 'not like', pattern)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user