3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

automod: make match_attachment_type case-insensitive

This commit is contained in:
Dragory 2020-09-15 01:02:28 +03:00
parent f916e8c156
commit a5c40a58bf
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -37,9 +37,16 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
const attachments: any[] = context.message.data.attachments;
for (const attachment of attachments) {
const attachmentType = attachment.filename.split(`.`).pop();
const attachmentType = attachment.filename
.split(".")
.pop()
.toLowerCase();
if (trigger.blacklist_enabled && trigger.filetype_blacklist.includes(attachmentType)) {
const blacklist = trigger.blacklist_enabled
? (trigger.filetype_blacklist || []).map(_t => _t.toLowerCase())
: null;
if (blacklist && blacklist.includes(attachmentType)) {
return {
extra: {
matchedType: attachmentType,
@ -48,7 +55,11 @@ export const MatchAttachmentTypeTrigger = automodTrigger<MatchResultType>()({
};
}
if (trigger.whitelist_enabled && !trigger.filetype_whitelist.includes(attachmentType)) {
const whitelist = trigger.whitelist_enabled
? (trigger.filetype_whitelist || []).map(_t => _t.toLowerCase())
: null;
if (whitelist && !whitelist.includes(attachmentType)) {
return {
extra: {
matchedType: attachmentType,