From 774cfb321e2bfbb07764a70bbce8796391f91fad Mon Sep 17 00:00:00 2001 From: Hiroyuki Date: Fri, 30 Jul 2021 16:07:54 -0400 Subject: [PATCH] feat(automod): MIME type trigger validation --- backend/src/plugins/Automod/AutomodPlugin.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/src/plugins/Automod/AutomodPlugin.ts b/backend/src/plugins/Automod/AutomodPlugin.ts index eb2484dd..8c0b9355 100644 --- a/backend/src/plugins/Automod/AutomodPlugin.ts +++ b/backend/src/plugins/Automod/AutomodPlugin.ts @@ -110,6 +110,21 @@ const configPreprocessor: ConfigPreprocessorFn = options => { ]); } } + + if (triggerObj[triggerName].match_mime_type) { + const white = triggerObj[triggerName].match_mime_type.whitelist_enabled; + const black = triggerObj[triggerName].match_mime_type.blacklist_enabled; + + if (white && black) { + throw new StrictValidationError([ + `Cannot have both blacklist and whitelist enabled at rule <${rule.name}/match_mime_type>`, + ]); + } else if (!white && !black) { + throw new StrictValidationError([ + `Must have either blacklist or whitelist enabled at rule <${rule.name}/match_mime_type>`, + ]); + } + } } } }