302 lines
15 KiB
TypeScript
302 lines
15 KiB
TypeScript
/* Metro module 15882; source: modules/guild_automod/AutomodRuleUtils.tsx; dependencies: [1226, 15883, 11454, 15885, 15886, 1244, 7246, 5065, 2] */
|
|
function _fun122517(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#122517, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:6, offset: 0x0256ab85, size: 464 bytes, params: 8, frame: 21
|
|
const env0_0 = require;
|
|
const closure = validateKeywordsOrThrow;
|
|
const closure2 = validateRegexPatternsOrThrow;
|
|
const closure3 = isBackendPersistedRule;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
|
|
const env0_3 = (require(15883) /* metro dependency 15883: AutomodStore */).getRuleCountByTriggerType;
|
|
const constantsModule = require(11454) /* metro dependency 11454: Constants */;
|
|
const env0_4 = constantsModule.AutomodTriggerType;
|
|
const env0_5 = constantsModule.MAX_KEYWORDS_PER_KEYWORD_FILTER;
|
|
const env0_6 = constantsModule.MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER;
|
|
const env0_7 = constantsModule.MAX_CHARACTERS_PER_KEYWORD;
|
|
const env0_8 = constantsModule.MIN_CHARACTERS_PER_KEYWORD;
|
|
const env0_9 = constantsModule.MIN_REGEX_PATTERN_LENGTH;
|
|
const env0_10 = constantsModule.MAX_REGEX_PATTERN_LENGTH;
|
|
const env0_11 = constantsModule.AutomodActionType;
|
|
const env0_12 = constantsModule.AutomodEventType;
|
|
const closure4 = function(a0, a1) {
|
|
return '' + a0 + '-' + a1 + '-new-rule';
|
|
};
|
|
const closure5 = isRuleKeywordFilter;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/guild_automod/AutomodRuleUtils.tsx');
|
|
exports.getNewAutomodRuleMockId = closure4;
|
|
exports.isRuleKeywordFilter = closure5;
|
|
exports.isRuleMLSpamFilter = isRuleMLSpamFilter;
|
|
exports.isRuleDefaultKeywordListFilter = isRuleDefaultKeywordListFilter;
|
|
exports.isRuleMentionSpamFilter = isRuleMentionSpamFilter;
|
|
exports.isRuleServerPolicyFilter = isRuleServerPolicyFilter;
|
|
exports.isRuleUserProfileFilter = isRuleUserProfileFilter;
|
|
exports.createDefaultRule = createDefaultRule;
|
|
exports.validateKeywordsOrThrow = closure;
|
|
exports.validateRegexPatternsOrThrow = closure2;
|
|
exports.validateRuleBeforeSaveOrThrow = validateRuleBeforeSaveOrThrow;
|
|
exports.isBackendPersistedRule = closure3;
|
|
exports.eventTypeToName = eventTypeToName;
|
|
exports.actionTypeToName = actionTypeToName;
|
|
exports.triggerTypeToName = triggerTypeToName;
|
|
}
|
|
|
|
function validateKeywordsOrThrow(a0, a1) { // fn#122518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:534, offset: 0x0256ad55, size: 137 bytes, params: 3, frame: 17
|
|
var Error;
|
|
var value;
|
|
var intl;
|
|
if (a0.length > a1) {
|
|
Error = global.Error;
|
|
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
value = intl.formatToPlainString((require(1244) /* metro dependency 1244: indexNative */).t.mee4qd,
|
|
{limit: a1});
|
|
throw new Error();
|
|
}
|
|
a0.forEach(_fun122519);
|
|
}
|
|
|
|
function validateRegexPatternsOrThrow(a0) { // fn#122520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:823, offset: 0x0256ae7d, size: 142 bytes, params: 2, frame: 17
|
|
var Error;
|
|
var intl;
|
|
const length = a0.length;
|
|
var value;
|
|
if (length > MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER) {
|
|
Error = global.Error;
|
|
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
value = intl.formatToPlainString((require(1244) /* metro dependency 1244: indexNative */).t.tDjhF1,
|
|
{limit: MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER});
|
|
throw new Error();
|
|
}
|
|
a0.forEach(_fun122521);
|
|
}
|
|
|
|
function isBackendPersistedRule(a0) { // fn#122522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1118, offset: 0x0256afaa, size: 71 bytes, params: 2, frame: 14
|
|
const value = undefined;
|
|
const applicationCommandUtilsModule = require(5065) /* metro dependency 5065: ApplicationCommandUtils */;
|
|
return applicationCommandUtilsModule.isSnowflake((a0 == null ? value : a0.id) ?? 'INVALID_SNOWFLAKE');
|
|
}
|
|
|
|
function isRuleKeywordFilter(a0) { // fn#122524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:488, offset: 0x0256b018, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const KEYWORD = AutomodTriggerType.KEYWORD;
|
|
return triggerType === KEYWORD;
|
|
}
|
|
|
|
function isRuleMLSpamFilter(a0) { // fn#122525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1428, offset: 0x0256b03f, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const ML_SPAM = AutomodTriggerType.ML_SPAM;
|
|
return triggerType === ML_SPAM;
|
|
}
|
|
|
|
function isRuleDefaultKeywordListFilter(a0) { // fn#122526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1507, offset: 0x0256b066, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const DEFAULT_KEYWORD_LIST = AutomodTriggerType.DEFAULT_KEYWORD_LIST;
|
|
return triggerType === DEFAULT_KEYWORD_LIST;
|
|
}
|
|
|
|
function isRuleMentionSpamFilter(a0) { // fn#122527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1592, offset: 0x0256b08d, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const MENTION_SPAM = AutomodTriggerType.MENTION_SPAM;
|
|
return triggerType === MENTION_SPAM;
|
|
}
|
|
|
|
function isRuleServerPolicyFilter(a0) { // fn#122528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1670, offset: 0x0256b0b4, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const SERVER_POLICY = AutomodTriggerType.SERVER_POLICY;
|
|
return triggerType === SERVER_POLICY;
|
|
}
|
|
|
|
function isRuleUserProfileFilter(a0) { // fn#122529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1748, offset: 0x0256b0db, size: 39 bytes, params: 2, frame: 3
|
|
const triggerType = a0?.triggerType;
|
|
const USER_PROFILE = AutomodTriggerType.USER_PROFILE;
|
|
return triggerType === USER_PROFILE;
|
|
}
|
|
|
|
function createDefaultRule(a0, a1) { // fn#122530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:1819, offset: 0x0256b102, size: 397 bytes, params: 3, frame: 19
|
|
var name;
|
|
var Error;
|
|
var intl;
|
|
var value;
|
|
const property = (require(15885) /* metro dependency 15885: AutomodTriggerConfigs */).triggerConfigs[a1];
|
|
const defaultTriggerMetadataForTriggerType = (require(15885) /* metro dependency 15885: AutomodTriggerConfigs */).getDefaultTriggerMetadataForTriggerType(a1,
|
|
a0);
|
|
const object2 = {};
|
|
object2.id = getNewAutomodRuleMockId(a0, a1);
|
|
object2.name = property.getDefaultRuleName();
|
|
object2.guildId = a0;
|
|
object2.eventType = property.eventType;
|
|
object2.triggerType = a1;
|
|
object2.triggerMetadata = defaultTriggerMetadataForTriggerType;
|
|
object2.enabled = true;
|
|
object2.creatorId = AuthenticationStore.getId();
|
|
object2.actions = (require(15886) /* metro dependency 15886: AutomodActionUtils */).getRuleDefaultActionsFromConfig(property);
|
|
object2.position = 0;
|
|
let Set = global.Set;
|
|
const value3 = Object.create(Set.prototype, {constructor: {value: Set}});
|
|
let set = new Set();
|
|
object2.exemptChannels = set instanceof Object ? set : value3;
|
|
Set = global.Set;
|
|
const value5 = Object.create(Set.prototype, {constructor: {value: Set}});
|
|
set = new Set();
|
|
object2.exemptRoles = set instanceof Object ? set : value5;
|
|
if (isBackendPersistedRule(object2)) {
|
|
Error = global.Error;
|
|
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
value = intl.string((require(1244) /* metro dependency 1244: indexNative */).t['A/nX8D']);
|
|
throw new Error();
|
|
}
|
|
value = getRuleCountByTriggerType(a0, a1);
|
|
if (value > 0) {
|
|
name = object2.name;
|
|
value += 1;
|
|
object2.name = name + (' ' + value);
|
|
}
|
|
return object2;
|
|
}
|
|
|
|
function validateRuleBeforeSaveOrThrow(a0) { // fn#122531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:2479, offset: 0x0256b28f, size: 301 bytes, params: 2, frame: 17
|
|
var r6;
|
|
var r3;
|
|
var triggerMetadata;
|
|
var length;
|
|
var Error;
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
var value;
|
|
if (isRuleKeywordFilter(a0)) {
|
|
triggerMetadata = a0.triggerMetadata;
|
|
r6 = triggerMetadata.keywordFilter ?? [];
|
|
triggerMetadata = a0.triggerMetadata;
|
|
r3 = triggerMetadata.regexPatterns ?? [];
|
|
length = r6.length;
|
|
if (length !== 0) {
|
|
validateKeywordsOrThrow(r6, MAX_KEYWORDS_PER_KEYWORD_FILTER);
|
|
validateRegexPatternsOrThrow(r3);
|
|
if (a0.actions.length === 0) {
|
|
Error = global.Error;
|
|
value = intl.string(t['t+gj5V']);
|
|
throw new Error();
|
|
}
|
|
return undefined;
|
|
}
|
|
length = r3.length;
|
|
if (length === 0) {
|
|
Error = global.Error;
|
|
value = intl.string(t.kz2Av3);
|
|
throw new Error();
|
|
}
|
|
validateKeywordsOrThrow(r6, MAX_KEYWORDS_PER_KEYWORD_FILTER);
|
|
validateRegexPatternsOrThrow(r3);
|
|
length = a0.actions.length;
|
|
if (length === 0) {
|
|
Error = global.Error;
|
|
value = intl.string(t['t+gj5V']);
|
|
throw new Error();
|
|
}
|
|
} else if (a0.actions.length === 0) {
|
|
Error = global.Error;
|
|
value = intl.string(t['t+gj5V']);
|
|
throw new Error();
|
|
}
|
|
}
|
|
|
|
function eventTypeToName(a0) { // fn#122532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:2949, offset: 0x0256b3bc, size: 218 bytes, params: 2, frame: 15
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const MESSAGE_SEND = AutomodEventType.MESSAGE_SEND;
|
|
if (MESSAGE_SEND === a0) {
|
|
return intl.string(t.NlQW4P);
|
|
}
|
|
const GUILD_MEMBER_JOIN_OR_UPDATE = AutomodEventType.GUILD_MEMBER_JOIN_OR_UPDATE;
|
|
if (GUILD_MEMBER_JOIN_OR_UPDATE === a0) {
|
|
return intl.string(t['Q+68IX']);
|
|
}
|
|
const string = intl.string;
|
|
const SP9BBx = t.SP9BBx;
|
|
return Reflect.apply(string, intl, [SP9BBx]);
|
|
}
|
|
|
|
function actionTypeToName(a0) { // fn#122533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:3209, offset: 0x0256b496, size: 374 bytes, params: 2, frame: 15
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const BLOCK_MESSAGE = AutomodActionType.BLOCK_MESSAGE;
|
|
if (BLOCK_MESSAGE === a0) {
|
|
return intl.string(t.d1ab8n);
|
|
}
|
|
const FLAG_TO_CHANNEL = AutomodActionType.FLAG_TO_CHANNEL;
|
|
if (FLAG_TO_CHANNEL === a0) {
|
|
return intl.string(t['Y+VmvU']);
|
|
}
|
|
const USER_COMMUNICATION_DISABLED = AutomodActionType.USER_COMMUNICATION_DISABLED;
|
|
if (USER_COMMUNICATION_DISABLED === a0) {
|
|
return intl.string(t['6WPxY2']);
|
|
}
|
|
const QUARANTINE_USER = AutomodActionType.QUARANTINE_USER;
|
|
if (QUARANTINE_USER === a0) {
|
|
return intl.string(t.NPO8ee);
|
|
}
|
|
const string = intl.string;
|
|
const SP9BBx = t.SP9BBx;
|
|
return Reflect.apply(string, intl, [SP9BBx]);
|
|
}
|
|
|
|
function triggerTypeToName(a0) { // fn#122534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:3611, offset: 0x0256b60c, size: 442 bytes, params: 2, frame: 15
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const KEYWORD = AutomodTriggerType.KEYWORD;
|
|
if (KEYWORD === a0) {
|
|
return intl.string(t.ffR2cM);
|
|
}
|
|
const ML_SPAM = AutomodTriggerType.ML_SPAM;
|
|
if (ML_SPAM === a0) {
|
|
return intl.string(t['puF/Os']);
|
|
}
|
|
const DEFAULT_KEYWORD_LIST = AutomodTriggerType.DEFAULT_KEYWORD_LIST;
|
|
if (DEFAULT_KEYWORD_LIST === a0) {
|
|
return intl.string(t.LnGhZv);
|
|
}
|
|
const MENTION_SPAM = AutomodTriggerType.MENTION_SPAM;
|
|
if (MENTION_SPAM === a0) {
|
|
return intl.string(t.pX7i6n);
|
|
}
|
|
const USER_PROFILE = AutomodTriggerType.USER_PROFILE;
|
|
if (USER_PROFILE === a0) {
|
|
return intl.string(t.q1L2v8);
|
|
}
|
|
const string = intl.string;
|
|
const SP9BBx = t.SP9BBx;
|
|
return Reflect.apply(string, intl, [SP9BBx]);
|
|
}
|
|
|
|
function _fun122519(a0) { // fn#122519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:675, offset: 0x0256adde, size: 159 bytes, params: 2, frame: 18
|
|
const InvalidKeywordError = (require(7246) /* metro dependency 7246: AutomodErrorUtils */).InvalidKeywordError;
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const length = a0.length;
|
|
const value = environment.__proto__;
|
|
if (length > MAX_CHARACTERS_PER_KEYWORD) {
|
|
throw new InvalidKeywordError(intl.formatToPlainString(t.rbRvGe, {keyword: a0, max: MAX_CHARACTERS_PER_KEYWORD,
|
|
min: MIN_CHARACTERS_PER_KEYWORD}));
|
|
}
|
|
if (a0.length < MIN_CHARACTERS_PER_KEYWORD) {
|
|
throw new InvalidKeywordError(intl.formatToPlainString(t.rbRvGe, {keyword: a0, max: MAX_CHARACTERS_PER_KEYWORD,
|
|
min: MIN_CHARACTERS_PER_KEYWORD}));
|
|
}
|
|
}
|
|
|
|
function _fun122521(a0) { // fn#122521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16090:967, offset: 0x0256af0b, size: 159 bytes, params: 2, frame: 18
|
|
const InvalidRegexPatternError = (require(7246) /* metro dependency 7246: AutomodErrorUtils */).InvalidRegexPatternError;
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const length = a0.length;
|
|
const value = environment.__proto__;
|
|
if (length > MAX_REGEX_PATTERN_LENGTH) {
|
|
throw new InvalidRegexPatternError(intl.formatToPlainString(t.WR0m9w, {regex: a0, max: MAX_REGEX_PATTERN_LENGTH,
|
|
min: MIN_REGEX_PATTERN_LENGTH}));
|
|
}
|
|
if (a0.length < MIN_REGEX_PATTERN_LENGTH) {
|
|
throw new InvalidRegexPatternError(intl.formatToPlainString(t.WR0m9w, {regex: a0, max: MAX_REGEX_PATTERN_LENGTH,
|
|
min: MIN_REGEX_PATTERN_LENGTH}));
|
|
}
|
|
}
|
|
|