mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-12 23:46:22 +00:00
feat: filter uploads by mime types
This commit is contained in:
parent
30db27e524
commit
10c2618ef6
@ -1232,6 +1232,7 @@ self.list = async (req, res) => {
|
||||
// Columns with which to use SQLite's NULLS LAST option
|
||||
nullsLast: [
|
||||
'userid',
|
||||
'type',
|
||||
'albumid',
|
||||
'expirydate',
|
||||
'ip'
|
||||
@ -1266,7 +1267,7 @@ self.list = async (req, res) => {
|
||||
}
|
||||
|
||||
if (filters) {
|
||||
const keywords = []
|
||||
const keywords = ['type']
|
||||
|
||||
// Only allow filtering by 'albumid' when not listing a specific album's uploads
|
||||
if (isNaN(albumid)) {
|
||||
@ -1708,6 +1709,23 @@ self.list = async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Then, refine using 'type' keys
|
||||
this.andWhere(function () {
|
||||
if (filterObj.queries.exclude.type) {
|
||||
this.whereNotIn('type', filterObj.queries.exclude.type)
|
||||
} else if (filterObj.queries.type) {
|
||||
this.orWhereIn('type', filterObj.queries.type)
|
||||
}
|
||||
// ...
|
||||
if ((filterObj.queries.exclude.type && filterObj.flags.typeNull !== false) ||
|
||||
(filterObj.queries.type && filterObj.flags.typeNull) ||
|
||||
(!filterObj.queries.exclude.type && !filterObj.queries.type && filterObj.flags.typeNull)) {
|
||||
this.orWhereNull('type')
|
||||
} else if (filterObj.flags.typeNull === false) {
|
||||
this.whereNotNull('type')
|
||||
}
|
||||
})
|
||||
|
||||
// Then, refine using the supplied keywords against their file names
|
||||
this.andWhere(function () {
|
||||
if (!filterObj.queries.text) return
|
||||
|
@ -1191,6 +1191,10 @@ page.uploadFiltersHelp = element => {
|
||||
Negation sign works for this key as well.
|
||||
Mixing inclusion and exclusion is not allowed (i.e. <code>is:image -is:video</code>), since the second key will be redundant.
|
||||
|
||||
Alternatively, you can filter by their actual mime types using <b>type</b> keys.
|
||||
For example, <code>type:image/jpeg</code>, <code>type:video/mp4</code>.
|
||||
Negation sign works for this key as well.
|
||||
|
||||
Any leftover keywords which do not use keys (non-keyed keywords) will be matched against the matches' randomly generated and original names.
|
||||
Excluding certain keywords is also supported by adding negation sign before the keywords.
|
||||
|
||||
@ -1201,6 +1205,7 @@ page.uploadFiltersHelp = element => {
|
||||
: '- Filter uploads'} using <b>date</b> key, if any.
|
||||
- Refine matches using <b>expiry</b> key, if any.
|
||||
- Refine matches using type-<b>is</b> keys, if any.
|
||||
- Refine matches using <b>type</b> keys, if any.
|
||||
- Refine matches using ANY non-keyed keywords, if any.
|
||||
- Filter matches using ALL exclusion non-keyed keywords, if any.
|
||||
- Sort matches using <b>sort</b> keys, if any.
|
||||
|
Loading…
Reference in New Issue
Block a user