Custom Filters [Backend] (#3105) (#3110)

* Added `ResultFilters` to types
Added customFilters field to user
This field is an optional array of `ResultFilters`
It will store a user's custom filters

* Added Add and Remove functions for `ResultFilters` in user DAL

Also added unit tests

* Added Custom Filter configuration

Can now enable/disable the custom filters feature
Can also set a cap on the number of filters per user

* Add and Remove functions for `ResultFilters` in user controller
This commit is contained in:
Malo Hamon 2022-06-12 12:38:09 +10:00 committed by GitHub
parent 9e0017bd43
commit b55419dfc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -2,7 +2,16 @@ import joi from "joi";
const FILTER_SCHEMA = {
_id: joi.string().required(),
name: joi.string().required(),
name: joi
.string()
.required()
.regex(/^[0-9a-zA-Z_.-]+$/)
.max(16)
.messages({
"string.pattern.base":
"Filter name invalid. Name cannot contain special characters or more than 16 characters. Can include _ . and -",
"string.max": "Filter name exceeds maximum of 16 characters",
}),
difficulty: joi
.object({
normal: joi.bool().required(),

View file

@ -43,7 +43,7 @@ export const BASE_CONFIGURATION: MonkeyTypes.Configuration = {
enabled: false,
},
customFilters: {
enabled: true,
enabled: false,
maxFiltersPerUser: 0,
},
};