This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,67 @@
// Metro module 16378 (f16379).
import { AutomodActionType } from "./Constants";
export function getRuleDefaultActionsFromConfig(a0) {
const r1 = {};
r1[AutomodActionType.BLOCK_MESSAGE] = {
type: AutomodActionType.BLOCK_MESSAGE,
metadata: {
customMessage: void 0
}
};
r1[AutomodActionType.FLAG_TO_CHANNEL] = {
type: AutomodActionType.FLAG_TO_CHANNEL,
metadata: {
channelId: void 0
}
};
r1[AutomodActionType.USER_COMMUNICATION_DISABLED] = {
type: AutomodActionType.USER_COMMUNICATION_DISABLED,
metadata: {
durationSeconds: 60
}
};
r1[AutomodActionType.QUARANTINE_USER] = {
type: AutomodActionType.QUARANTINE_USER,
metadata: {}
};
let c23119_0 = r1;
return Array.from(a0.defaultActionTypes).map((item) => c23119_0[item]);
}
export function isActionFlagToChannel(a0) {
return a0.type === AutomodActionType.FLAG_TO_CHANNEL;
}
export function isActionUserCommunicationDisabled(a0) {
return a0.type === AutomodActionType.USER_COMMUNICATION_DISABLED;
}
export function isActionBlockMessage(a0) {
return a0.type === AutomodActionType.BLOCK_MESSAGE;
}
export function isActionQuarantineUser(a0) {
return a0.type === AutomodActionType.QUARANTINE_USER;
}
export function getDefaultActions() {
const r0 = {};
r0[AutomodActionType.BLOCK_MESSAGE] = {
type: AutomodActionType.BLOCK_MESSAGE,
metadata: {
customMessage: void 0
}
};
r0[AutomodActionType.FLAG_TO_CHANNEL] = {
type: AutomodActionType.FLAG_TO_CHANNEL,
metadata: {
channelId: void 0
}
};
r0[AutomodActionType.USER_COMMUNICATION_DISABLED] = {
type: AutomodActionType.USER_COMMUNICATION_DISABLED,
metadata: {
durationSeconds: 60
}
};
r0[AutomodActionType.QUARANTINE_USER] = {
type: AutomodActionType.QUARANTINE_USER,
metadata: {}
};
return r0;
}
+44
View File
@@ -0,0 +1,44 @@
// Metro module 5773 (f5774).
const r9 = {
SET_COMPLETED: 1,
1: "SET_COMPLETED",
UNSET_COMPLETED: 2,
2: "UNSET_COMPLETED",
DELETE_USER_MESSAGE: 3,
3: "DELETE_USER_MESSAGE",
SUBMIT_FEEDBACK: 4,
4: "SUBMIT_FEEDBACK"
};
export { r9 as AutomodAlertActionType };
export function parseAlertActionsExecution(a0) {
if (a0 == null) {
return null;
}
let c15138_0;
const r9 = (function safeJsonParse(a0) {
let r5;
if (a0 == null) {
return null;
}
try {
r5 = JSON.parse(a0);
} catch ($e) {
return null;
}
return r5;
})(a0);
c15138_0 = r9;
const r10 = r9 == null;
let r11 = null;
if (!r10) {
const r12 = r9.actions == null;
r11 = null;
if (!r12) {
Object.keys(r9.actions).forEach((item) => {
c15138_0.actions[item].actionType = item;
});
r11 = r9;
}
}
return r11;
}
@@ -0,0 +1,69 @@
// Metro module 6178 (f6179).
import ChannelStore from "../../stores/ChannelStore";
import { AbortCodes } from "../../Constants";
import { intl, t } from "../../intl/index.native";
import { isMessageDataEdit } from "../../lib/MessageQueue";
let c3919_4, getAutomodErrorMessageFromMessageData, InvalidKeywordError;
const getAutomodErrorMessageFromErrorResponse = function getAutomodErrorMessageFromErrorResponse(a0, a1) {
if (a0 == null) {
return null;
}
const { code, message } = a0;
if (c3919_4.has(code)) {
if (message != null) {
return message;
}
if (a1 == null) {
return null;
}
const channel = ChannelStore.getChannel(a1);
if (channel == null ? void 0 : channel.isThread()) {
return intl.string(t.DVdG9E);
}
if (!(!(channel == null ? void 0 : channel.isForumPost()) && !(channel == null ? void 0 : channel.isForumLikeChannel()))) {
if (code === AbortCodes.AUTOMOD_TITLE_BLOCKED) {
return intl.string(t.ipgKDg);
}
if (code === AbortCodes.AUTOMOD_MESSAGE_BLOCKED) {
return intl.string(t.ipgKDg);
}
}
return null;
}
return null;
};
getAutomodErrorMessageFromMessageData = function getAutomodErrorMessageFromMessageData(a0) {
let r32;
L16: {
const channel = ChannelStore.getChannel(a0.message.channelId);
if (isMessageDataEdit(a0)) {
r32 = intl.string(t.bU6o0z);
} else if (channel == null ? void 0 : channel.isThread()) {
r32 = intl.string(t.DVdG9E);
} else {
if (!(channel == null ? void 0 : channel.isForumPost()) && !(channel == null ? void 0 : channel.isForumLikeChannel())) {
r32 = intl.string(t.zQ69pv);
break L16;
}
r32 = intl.string(t.ipgKDg);
}
}
return r32;
};
const InvalidKeywordError2 = class InvalidKeywordError extends Error {};
InvalidKeywordError2.prototype;
InvalidKeywordError = InvalidKeywordError2;
class InvalidRegexPatternError extends Error {}
c3919_4 = new Set([AbortCodes.AUTOMOD_MESSAGE_BLOCKED, AbortCodes.AUTOMOD_TITLE_BLOCKED, AbortCodes.AUTOMOD_INVALID_RUST_SERVICE_RESPONSE]);
export { InvalidKeywordError };
export { InvalidRegexPatternError };
export { c3919_4 as AUTOMOD_ERROR_CODES };
export { getAutomodErrorMessageFromErrorResponse };
export { getAutomodErrorMessageFromMessageData };
export function getAutomodErrorMessage(a0, a1) {
let r8 = getAutomodErrorMessageFromErrorResponse(a1);
if (r8 == null) {
r8 = a0 == null ? intl.string(t.zQ69pv) : getAutomodErrorMessageFromMessageData(a0);
}
return r8;
}
@@ -0,0 +1,18 @@
// Metro module 10267 (f10268).
import { createExperiment } from "../experiments/index";
const experiment = createExperiment({
kind: "guild",
id: "2022-12_mention_raid_limit",
label: "Automod Mention Raid Limit",
defaultConfig: {
enabled: false
},
treatments: [{
id: 1,
label: "Automod Mention Raid Limit",
config: {
enabled: true
}
}]
});
export { experiment as AutomodMentionRaidLimit };
+43
View File
@@ -0,0 +1,43 @@
// Metro module 5774 (f5775).
import { intl, t } from "../../intl/index.native";
let c3590_2 = {
BUG: "BUG",
ALLOWED: "ALLOWED",
MENTION_RAID_REMOVE_RESTRICTION: "MENTION_RAID_REMOVE_RESTRICTION"
};
const r17 = {
JOIN_RAID: "JOIN_RAID",
MENTION_RAID: "MENTION_RAID"
};
let c3590_3 = {
LEGITIMATE_ACTIVITY: "LEGITIMATE_ACTIVITY",
LEGITIMATE_ACCOUNTS: "LEGITIMATE_ACCOUNTS",
LEGITIMATE_DMS: "LEGITIMATE_DMS",
DM_SPAM: "DM_SPAM",
JOIN_RAID: "JOIN_RAID",
OTHER: "OTHER"
};
const r24 = {
DM_SPAM: "DM_SPAM",
MENTION_SPAM: "MENTION_SPAM",
CHANNEL_SPAM: "CHANNEL_SPAM",
SUS_NEW_MEMBERS: "SUS_NEW_MEMBERS",
CHANGING_SETTINGS: "CHANGING_SETTINGS",
OTHER: "OTHER"
};
export { c3590_2 as Feedback };
export function generateFeedbackOptions() {
return [{
name: intl.string(t["+MbOX4"]),
value: c3590_2.BUG
}, {
name: intl.string(t.CRsCRC),
value: c3590_2.ALLOWED
}];
}
export { r17 as RaidAlertType };
export { c3590_3 as RaidResolutionType };
export function getMostImportantRaidResolutionType(a0) {
return a0.includes(c3590_3.LEGITIMATE_ACTIVITY) ? c3590_3.LEGITIMATE_ACTIVITY : a0.includes(c3590_3.DM_SPAM) ? c3590_3.DM_SPAM : a0.includes(c3590_3.JOIN_RAID) ? c3590_3.JOIN_RAID : c3590_3.OTHER;
}
export { r24 as RaidLockdownFeedbackType };
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,82 @@
// Metro module 3823 (f3824).
import GuildMemberStore from "../../stores/GuildMemberStore";
import { GuildMemberFlags } from "../guild_member/GuildMemberConstants";
import { useStateFromStores } from "../../_bundle/Module589";
function $mk72778($env) {
return (a0, a1) => {
const r2 = $env.$parent;
const r6 = (0, r2[0])(r2[1][2]);
let r10 = $env[0];
if (r10 == null) {
r10 = 0;
}
if (r6.hasFlag(r10, a1)) {
a0.push(a1);
}
return a0;
};
}
function $mk72779($env) {
return (a0) => {
const r2 = $env.$parent;
const r5 = (0, r2[0])(r2[1][2]);
let flags = $env[0].flags;
if (flags == null) {
flags = 0;
}
return r5.hasFlag(flags, a0);
};
}
let env2160 = {};
const c2160_4 = [GuildMemberFlags.AUTOMOD_QUARANTINED_BIO, GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME, GuildMemberFlags.AUTOMOD_QUARANTINED_SERVER_TAG];
export { c2160_4 as AUTOMOD_QUARANTINED_PROFILE_FLAGS };
export function getAutomodQuarantinedProfileFlags(a0) {
let env13635;
const r1 = env13635 = {
$parent: env2160
};
env13635[0] = a0;
return a0 == null ? new Set() : new Set(c2160_4.reduce($mk72778(r1), []));
}
export function getAutomodQuarantinedGuildMemberFlags(a0) {
let r16;
if (a0 == null) {
r16 = new Set();
} else {
let env13637;
const flags = a0.flags;
const r9 = env13637 = {
$parent: env2160
};
env13637[0] = flags;
r16 = flags == null ? new Set() : new Set(c2160_4.reduce($mk72778(r9), []));
}
return r16;
}
export function getAutomodReason(a0) {
return a0.has.call(a0, GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME) ? GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME : a0.has(GuildMemberFlags.AUTOMOD_QUARANTINED_BIO) ? GuildMemberFlags.AUTOMOD_QUARANTINED_BIO : a0.has(GuildMemberFlags.AUTOMOD_QUARANTINED_SERVER_TAG) ? GuildMemberFlags.AUTOMOD_QUARANTINED_SERVER_TAG : null;
}
export function hasAutomodQuarantinedProfile(a0) {
let env13636;
const r3 = env13636 = {
$parent: env2160
};
env13636[0] = a0;
return a0 != null && (a0.flags != null && c2160_4.some($mk72779(r3)));
}
export function useCurrentUserAutomodQuaratinedProfile(a0) {
return useStateFromStores([GuildMemberStore], () => {
let r7 = a0 != null;
if (r7) {
let env24733;
const r5 = env2160;
const selfMember = GuildMemberStore.getSelfMember(a0);
const r9 = env24733 = {
$parent: r5
};
env24733[0] = selfMember;
r7 = selfMember != null && (selfMember.flags != null && c2160_4.some($mk72779(r9)));
}
return r7;
}, [a0]);
}
@@ -0,0 +1,92 @@
// Metro module 11062 (f11063).
import { useCallback } from "react";
import ProfileCustomizationNavigationStore from "../profile_customization/ProfileCustomizationNavigationStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import GuildMemberStore from "../../stores/GuildMemberStore";
import GuildStore from "../../stores/GuildStore";
import PermissionStore from "../../stores/PermissionStore";
import SelectedGuildStore from "../../stores/SelectedGuildStore";
import { Permissions, UserSettingsSections } from "../../Constants";
import { GuildMemberFlags } from "../guild_member/GuildMemberConstants";
import { ProfileCustomizationSubsection } from "../user_settings/UserSettingsConstants";
import { useStateFromStores, useStateFromStoresObject } from "../../_bundle/defaultAreStatesEqual";
import { hasAutomodQuarantinedProfile, getAutomodQuarantinedProfileFlags } from "./AutomodPermissionUtils";
import { t, intl } from "../../intl/index.native";
import { useIsEligibleForUserProfileWYSIWYGEditing } from "../user_profile/experiments/UserProfileWYSIWYGEditingExperiment";
import { initGuildIdentitySettings } from "../guild_identity/GuildIdentityActionCreators";
import { openUserSettings } from "../user_settings/core/native/openUserSettings";
export function useCurrentUserHasAutomodQuarantinedProfile(a0) {
return useStateFromStores([AuthenticationStore, GuildMemberStore], () => {
if (a0 == null) {
return false;
}
return hasAutomodQuarantinedProfile(GuildMemberStore.getMember(a0, AuthenticationStore.getId()));
}, [a0]);
}
export function useGuildAutomodProfileQuarantineErrors(a0) {
return useStateFromStoresObject([AuthenticationStore, GuildMemberStore, SelectedGuildStore, GuildStore], () => {
let nick;
const guildId2 = SelectedGuildStore.getGuildId();
let r17 = a0;
if (r17 == null) {
r17 = guildId2;
}
const r18 = {
nick: void 0,
bio: void 0
};
const guild = GuildStore.getGuild(r17);
const r11 = r17;
if (guild != null && r11 != null) {
const automodQuarantinedProfileFlags = getAutomodQuarantinedProfileFlags(GuildMemberStore.getMember(r11, AuthenticationStore.getId())?.flags);
if (automodQuarantinedProfileFlags.size !== 0) {
if (automodQuarantinedProfileFlags.has(GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME)) {
if (a0 == null) {
const WBUh3O = t.WBUh3O;
let name = guild.name;
if (name == null) {
name = "";
}
nick = [intl.formatToPlainString(WBUh3O, {
guildName: name
})];
} else {
nick = [intl.string(t.EPZCrM)];
}
r18.nick = nick;
}
if (automodQuarantinedProfileFlags.has(GuildMemberFlags.AUTOMOD_QUARANTINED_BIO)) {
r18.bio = [intl.string(t.dZh1vz)];
}
}
return r18;
}
return r18;
}, [a0]);
}
export function useOpenFixQuarantinedProfileModal({ guildId, scrollPosition, analyticsLocations }) {
let stateFromStores2;
stateFromStores2 = void 0;
const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(guildId), [guildId]);
stateFromStores2 = useStateFromStores([PermissionStore], () => stateFromStores != null && PermissionStore.can(Permissions.CHANGE_NICKNAME, stateFromStores), [stateFromStores]);
return [useCallback(() => {
let subsection;
if (stateFromStores != null) {
const PROFILE_CUSTOMIZATION = UserSettingsSections.PROFILE_CUSTOMIZATION;
const GUILD = ProfileCustomizationSubsection.GUILD;
if (stateFromStores2) {
initGuildIdentitySettings(stateFromStores.id);
subsection = GUILD;
} else {
subsection = ProfileCustomizationSubsection.USER_PROFILE;
}
ProfileCustomizationNavigationStore.setState({
subsection,
scrollPosition
});
openUserSettings({
screen: PROFILE_CUSTOMIZATION
});
}
}, [stateFromStores2, scrollPosition, analyticsLocations, stateFromStores, useIsEligibleForUserProfileWYSIWYGEditing("AutomodQuarantineUtils")]), stateFromStores2];
}
+179
View File
@@ -0,0 +1,179 @@
// Metro module 16374 (f16375).
import AuthenticationStore from "../../stores/AuthenticationStore";
import { getRuleCountByTriggerType } from "./AutomodStore";
import { AutomodActionType, AutomodEventType, AutomodTriggerType, MAX_CHARACTERS_PER_KEYWORD, MAX_KEYWORDS_PER_KEYWORD_FILTER, MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER, MAX_REGEX_PATTERN_LENGTH, MIN_CHARACTERS_PER_KEYWORD, MIN_REGEX_PATTERN_LENGTH } from "./Constants";
import { triggerConfigs, getDefaultTriggerMetadataForTriggerType } from "./AutomodTriggerConfigs";
import { getRuleDefaultActionsFromConfig } from "./AutomodActionUtils";
import * as _index_native from "../../intl/index.native";
import { intl } from "../../intl/index.native";
import { InvalidKeywordError, InvalidRegexPatternError } from "./AutomodErrorUtils";
import { isSnowflake } from "../application_commands/ApplicationCommandUtils";
let $mk99436 = function() {
return (a0) => {
if (!(a0.length > MAX_CHARACTERS_PER_KEYWORD) && !(a0.length < MIN_CHARACTERS_PER_KEYWORD)) {
return void 0;
}
throw new InvalidKeywordError(intl.formatToPlainString(_index_native.t.rbRvGe, {
keyword: a0,
max: MAX_CHARACTERS_PER_KEYWORD,
min: MIN_CHARACTERS_PER_KEYWORD
}));
};
}, $mk99437 = function() {
return (a0) => {
if (!(a0.length > MAX_REGEX_PATTERN_LENGTH) && !(a0.length < MIN_REGEX_PATTERN_LENGTH)) {
return void 0;
}
throw new InvalidRegexPatternError(intl.formatToPlainString(_index_native.t.WR0m9w, {
regex: a0,
max: MAX_REGEX_PATTERN_LENGTH,
min: MIN_REGEX_PATTERN_LENGTH
}));
};
};
export function getNewAutomodRuleMockId(a0, a1) {
return `${a0}-${a1}-new-rule`;
}
export function isRuleKeywordFilter(a0) {
return a0?.triggerType === AutomodTriggerType.KEYWORD;
}
export function isRuleMLSpamFilter(a0) {
return a0?.triggerType === AutomodTriggerType.ML_SPAM;
}
export function isRuleDefaultKeywordListFilter(a0) {
return a0?.triggerType === AutomodTriggerType.DEFAULT_KEYWORD_LIST;
}
export function isRuleMentionSpamFilter(a0) {
return a0?.triggerType === AutomodTriggerType.MENTION_SPAM;
}
export function isRuleServerPolicyFilter(a0) {
return a0?.triggerType === AutomodTriggerType.SERVER_POLICY;
}
export function isRuleUserProfileFilter(a0) {
return a0?.triggerType === AutomodTriggerType.USER_PROFILE;
}
export function createDefaultRule(a0, a1) {
const r12 = triggerConfigs[a1];
const defaultTriggerMetadataForTriggerType = getDefaultTriggerMetadataForTriggerType(a1, a0);
const r27 = {
id: `${a0}-${a1}-new-rule`,
name: r12.getDefaultRuleName(),
guildId: a0,
eventType: r12.eventType,
triggerType: a1,
triggerMetadata: defaultTriggerMetadataForTriggerType,
enabled: true,
creatorId: AuthenticationStore.getId(),
actions: getRuleDefaultActionsFromConfig(r12),
position: 0,
exemptChannels: new Set(),
exemptRoles: new Set()
};
let id = r27.id;
if (id == null) {
id = "INVALID_SNOWFLAKE";
}
if (isSnowflake(id)) {
throw new Error(intl.string(_index_native.t["A/nX8D"]));
}
const ruleCountByTriggerType = getRuleCountByTriggerType(a0, a1);
if (ruleCountByTriggerType > 0) {
r27.name = r27.name + ` ${ruleCountByTriggerType + 1}`;
}
return r27;
}
export function validateKeywordsOrThrow(a0, a1) {
if (a0.length > a1) {
throw new Error(intl.formatToPlainString(_index_native.t.mee4qd, {
limit: a1
}));
}
a0.forEach($mk99436());
}
export function validateRegexPatternsOrThrow(a0) {
if (a0.length > MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER) {
throw new Error(intl.formatToPlainString(_index_native.t.tDjhF1, {
limit: MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER
}));
}
a0.forEach($mk99437());
}
export function validateRuleBeforeSaveOrThrow(a0) {
if (a0?.triggerType === AutomodTriggerType.KEYWORD) {
let keywordFilter = a0.triggerMetadata.keywordFilter;
if (keywordFilter == null) {
keywordFilter = [];
}
let regexPatterns = a0.triggerMetadata.regexPatterns;
if (regexPatterns == null) {
regexPatterns = [];
}
if (keywordFilter.length === 0 && regexPatterns.length === 0) {
throw new Error(intl.string(_index_native.t.kz2Av3));
}
if (keywordFilter.length > MAX_KEYWORDS_PER_KEYWORD_FILTER) {
throw new Error(intl.formatToPlainString(_index_native.t.mee4qd, {
limit: MAX_KEYWORDS_PER_KEYWORD_FILTER
}));
}
keywordFilter.forEach($mk99436());
if (regexPatterns.length > MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER) {
throw new Error(intl.formatToPlainString(_index_native.t.tDjhF1, {
limit: MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER
}));
}
regexPatterns.forEach($mk99437());
}
if (a0.actions.length === 0) {
throw new Error(intl.string(_index_native.t["t+gj5V"]));
}
}
export function isBackendPersistedRule(a0) {
let r10 = a0?.id;
if (r10 == null) {
r10 = "INVALID_SNOWFLAKE";
}
return isSnowflake(r10);
}
export function eventTypeToName(a0) {
if (AutomodEventType.MESSAGE_SEND === a0) {
return intl.string(_index_native.t.NlQW4P);
}
if (AutomodEventType.GUILD_MEMBER_JOIN_OR_UPDATE === a0) {
return intl.string(_index_native.t["Q+68IX"]);
}
return intl.string(_index_native.t.SP9BBx);
}
export function actionTypeToName(a0) {
if (AutomodActionType.BLOCK_MESSAGE === a0) {
return intl.string(_index_native.t.d1ab8n);
}
if (AutomodActionType.FLAG_TO_CHANNEL === a0) {
return intl.string(_index_native.t["Y+VmvU"]);
}
if (AutomodActionType.USER_COMMUNICATION_DISABLED === a0) {
return intl.string(_index_native.t["6WPxY2"]);
}
if (AutomodActionType.QUARANTINE_USER === a0) {
return intl.string(_index_native.t.NPO8ee);
}
return intl.string(_index_native.t.SP9BBx);
}
export function triggerTypeToName(a0) {
if (AutomodTriggerType.KEYWORD === a0) {
return intl.string(_index_native.t.ffR2cM);
}
if (AutomodTriggerType.ML_SPAM === a0) {
return intl.string(_index_native.t["puF/Os"]);
}
if (AutomodTriggerType.DEFAULT_KEYWORD_LIST === a0) {
return intl.string(_index_native.t.LnGhZv);
}
if (AutomodTriggerType.MENTION_SPAM === a0) {
return intl.string(_index_native.t.pX7i6n);
}
if (AutomodTriggerType.USER_PROFILE === a0) {
return intl.string(_index_native.t.q1L2v8);
}
return intl.string(_index_native.t.SP9BBx);
}
+377
View File
@@ -0,0 +1,377 @@
// Metro module 16375 (f16376).
import _slicedToArray from "../../_bundle/_slicedToArray";
import _asyncToGenerator from "../../_bundle/_asyncToGenerator";
import { useState, useCallback, useEffect } from "react";
import { AutomodTriggerType } from "./Constants";
import { EMPTY_STRING_SNOWFLAKE_ID } from "../../Constants";
import { createWithEqualityFn } from "../../_bundle/identity_700";
import * as _SystemRulesUtils from "./SystemRulesUtils";
import { batchUpdates } from "../../_bundle/Module705";
import { fetchAutomodRules } from "./GuildAutomodActionCreators";
import { APIError } from "../../errors/index";
import { shallow } from "../../_bundle/Module3802";
import { HermesBuiltin, $createGenerator } from "../../_hermes/prelude";
function $mk99438() {
return (a0) => [a0.syncRules, a0.fetching];
}
function $mk99439($env) {
return function() {
let env28368 = {
$parent: $env
};
env28368[1] = 0;
env28368[4] = 0;
env28368[3] = 0;
return $createGenerator(function() {
let value2;
const r0 = env28368[4];
if (r0 === 2) {
env28368[4] = 3;
HermesBuiltin.throwTypeError("Generator functions may not be called on executing generators");
throw new Error("unreachable");
}
const value = arguments[1];
const r3 = arguments[0];
const r9 = env28368.$parent;
if (r0 === 3) {
if (r3 === 1) {
throw value;
}
if (r3 === 2) {
return {
value,
done: true
};
}
return {
value: void 0,
done: true
};
}
while (true) {
L20: {
L18: {
L16: {
L8: {
try {
env28368[4] = 2;
const r19 = env28368[1];
if (r19 === 0) {
if (r3 === 1) {
env28368[4] = 3;
throw value;
}
if (r3 === 2) {
env28368[4] = 3;
break L20;
}
env28368[0] = r9;
if (!r9[3]) {
const r33 = r9[0];
if (r33 != null) {
env28368[3] = 1;
(0, r9[1])(true);
value2 = (0, r9[2])(r33);
env28368[1] = 2;
env28368[4] = 1;
break L16;
}
}
} else {
if (r19 === 1) {
const r15 = env28368[0];
const r29 = env28368[2];
env28368[3] = 0;
(0, r15[1])(false);
throw r29;
}
if (r3 === 1) {
env28368[4] = 3;
throw value;
}
if (r3 === 2) {
env28368[3] = 0;
(0, env28368[0][1])(false);
env28368[4] = 3;
break L8;
}
env28368[3] = 0;
(0, env28368[0][1])(false);
}
env28368[4] = 3;
break L18;
} catch (r45) {
env28368[2] = r45;
if (env28368[3] === 0) {
env28368[4] = 3;
throw r45;
}
env28368[1] = 1;
continue;
}
}
return {
value,
done: true
};
}
return {
value: value2,
done: false
};
}
return {
value: void 0,
done: true
};
}
return {
value,
done: true
};
}
});
};
}
function $mk117374($env) {
return () => {
const r4 = $env;
const r2 = $env.$parent[0];
const rules3 = {
...r4[2]
};
rules3[r4[0]] = r4[1];
r2({
rules: rules3,
error: null
});
};
}
function $mk117375($env) {
return () => {
(0, $env.$parent[0])({
error: $env[3]
});
};
}
let c11782_8;
let env11782 = {};
const c11782_7 = {};
const withEqualityFn = createWithEqualityFn((a0, a1) => {
let env23113 = {
$parent: env11782
};
env23113[0] = a0;
env23113[1] = a1;
env23113[2] = async (c28371_0) => {
let convertToRulesByTriggerType2, c28371_2, c28371_3, c28371_5;
let c28371_4 = 0;
const r10 = env23113;
L13: {
try {
let env31042;
c28371_3 = r10;
const r28 = env31042 = {
$parent: r10
};
c28371_2 = r28;
env31042[0] = c28371_0;
env31042[1] = void 0;
env31042[2] = void 0;
env31042[3] = void 0;
if ((function isSyncNeeded(a0) {
const r6 = Date.now();
let r9 = c11782_7[a0];
if (r9 == null) {
r9 = 0;
}
return r6 - r9 > 20000;
})(c28371_0)) {
c11782_7[c28371_0] = Date.now();
c28371_4 = 1;
convertToRulesByTriggerType2 = function convertToRulesByTriggerType(a0) {
const r0 = {};
r0[AutomodTriggerType.KEYWORD] = [];
r0[AutomodTriggerType.ML_SPAM] = [];
r0[AutomodTriggerType.DEFAULT_KEYWORD_LIST] = [];
r0[AutomodTriggerType.MENTION_SPAM] = [];
r0[AutomodTriggerType.USER_PROFILE] = [];
r0[AutomodTriggerType.SERVER_POLICY] = [];
let c31825_0 = r0;
a0.forEach((item) => {
const r5 = c31825_0[item.triggerType];
if (r5 != null) {
r5.push(item);
}
});
return r0;
};
const automodRules = await fetchAutomodRules(c28371_0);
const r59 = c28371_2;
env31042[1] = convertToRulesByTriggerType2(automodRules);
env31042[2] = (0, env23113[1])().rules;
batchUpdates($mk117374(r59));
c28371_4 = 0;
break L13;
}
} catch ($e) {
const r26 = $e;
let r7 = r26;
c28371_5 = r26;
if (c28371_4 !== 0) {
while (true) {
try {
const r79 = c28371_2;
const r81 = c28371_5;
c28371_4 = 0;
env31042[4] = r81;
env31042[3] = new APIError(env31042[4]);
batchUpdates($mk117375(r79));
break L13;
} catch (r77) {
r7 = r77;
c28371_5 = r77;
if (c28371_4 === 0) {
break;
}
}
}
}
throw r7;
}
return void 0;
}
};
return {
rules: {},
fetching: false,
error: null,
updateRule: (a0) => {
let c28369_6;
const { guildId, id, triggerType } = a0;
const rules = (0, env23113[1])().rules;
let r16 = rules[guildId];
if (r16 == null) {
r16 = {};
}
let c28369_5 = r16;
let r8 = r16[triggerType];
if (r8 == null) {
r8 = [];
}
const r19 = r8.some((item) => item.id === id);
const r22 = r8.filter((item) => {
const isDefaultRuleId = _SystemRulesUtils.isDefaultRuleId(item.id);
return isDefaultRuleId ? item.triggerType !== triggerType : !isDefaultRuleId;
});
c28369_6 = r19 ? r22.map((item) => item.id === id ? a0 : item) : [...r22, a0];
batchUpdates(() => {
const r2 = env23113[0];
const rules3 = {
...rules
};
const r10 = {
...c28369_5
};
r10[triggerType] = c28369_6;
rules3[guildId] = r10;
r2({
rules: rules3,
error: null
});
});
},
removeRule: (c28370_0, a1) => {
let c28370_1 = a1;
const rules2 = (0, env23113[1])().rules;
const r4 = rules2[a1];
let c28370_3 = r4;
let c28370_4 = Object.keys(r4).reduce((acc, a1) => {
const r7 = Number(a1);
let r5 = c28370_3[r7];
if (r5 == null) {
r5 = [];
}
acc[r7] = r5.filter((item) => item.id !== c28370_0);
return acc;
}, {});
batchUpdates(() => {
const r2 = env23113[0];
const rules3 = {
...rules2
};
rules3[c28370_1] = c28370_4;
r2({
rules: rules3,
error: null
});
});
},
syncRules: function() {
return env23113[2].apply(this, arguments);
}
};
});
c11782_8 = withEqualityFn;
export { withEqualityFn as useAutomodStore };
export function getRuleCountByTriggerType(a0, a1) {
const r4 = c11782_8.getState().rules[a0];
let r9 = r4 == null ? void 0 : r4[a1];
if (r9 == null) {
r9 = [];
}
return r9.length;
}
export function useSyncAutomodRules(a0) {
let env23112;
const r3 = env23112 = {};
env23112[0] = a0;
const r13 = _slicedToArray(useState(false), 2);
const r5 = r13[0];
env23112[1] = r13[1];
const r21 = _slicedToArray(c11782_8($mk99438(), shallow), 2);
const r22 = r21[0];
env23112[2] = r22;
const r23 = r21[1];
env23112[3] = r23;
return [r5, useCallback(_asyncToGenerator($mk99439(r3)), [a0, r23, r22])];
}
export function useSyncAutomodRulesEffect(a0) {
let env23115;
const r5 = env23115 = {};
env23115[0] = a0;
const r14 = _slicedToArray(useState(false), 2);
const r9 = r14[0];
env23115[1] = r14[1];
const r22 = _slicedToArray(c11782_8($mk99438(), shallow), 2);
const r23 = r22[0];
env23115[2] = r23;
const r24 = r22[1];
env23115[3] = r24;
const [r33, r34] = [r9, useCallback(_asyncToGenerator($mk99439(r5)), [a0, r24, r23])];
let c23114_0 = r34;
useEffect(() => {
(async () => {
await c23114_0();
})();
}, [a0, r34]);
return [r33, r34];
}
export function useAutomodRulesList(c23116_0) {
return c11782_8((a0) => {
const rules3 = a0.rules;
let r5 = c23116_0;
if (r5 == null) {
r5 = EMPTY_STRING_SNOWFLAKE_ID;
}
let rulesByTriggerType = rules3[r5];
if (rulesByTriggerType == null) {
rulesByTriggerType = {};
}
return {
rulesByTriggerType,
updateRule: a0.updateRule,
removeRule: a0.removeRule
};
}, shallow);
}
@@ -0,0 +1,156 @@
// Metro module 16377 (f16378).
import { useMemo } from "react";
import * as _Constants from "./Constants";
import { AutomodTriggerType, MENTION_SPAM_LIMIT_DEFAULT } from "./Constants";
import { intl, t } from "../../intl/index.native";
import { useIsUserProfileRuleEnabled } from "./PermissionUtils";
import * as _ExperimentUtils from "./ExperimentUtils";
let c11784_5, c11784_6, c11784_7;
const { AutomodActionType, AutomodEventType } = _Constants;
const r27 = {
NEW: "new",
RECOMMENDED: "recommended",
BETA: "beta",
ALPHA: "alpha"
};
const r32 = {};
r32[AutomodTriggerType.SPAM_LINK] = {
getDefaultRuleName: () => intl.string(t.ffR2cM),
type: AutomodTriggerType.SPAM_LINK,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 0,
availableActionTypes: new Set(),
flags: new Set(),
defaultActionTypes: new Set()
};
r32[AutomodTriggerType.KEYWORD] = {
getDefaultRuleName: () => intl.string(t.ffR2cM),
type: AutomodTriggerType.KEYWORD,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 6,
availableActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE, AutomodActionType.FLAG_TO_CHANNEL, AutomodActionType.USER_COMMUNICATION_DISABLED]),
flags: new Set(),
defaultActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE])
};
r32[AutomodTriggerType.ML_SPAM] = {
getDefaultRuleName: () => intl.string(t["puF/Os"]),
type: AutomodTriggerType.ML_SPAM,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 1,
availableActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE, AutomodActionType.FLAG_TO_CHANNEL]),
flags: new Set([]),
defaultActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE])
};
r32[AutomodTriggerType.DEFAULT_KEYWORD_LIST] = {
getDefaultRuleName: () => intl.string(t.LnGhZv),
type: AutomodTriggerType.DEFAULT_KEYWORD_LIST,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 1,
availableActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE, AutomodActionType.FLAG_TO_CHANNEL]),
flags: new Set([]),
defaultActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE])
};
r32[AutomodTriggerType.MENTION_SPAM] = {
getDefaultRuleName: () => intl.string(t.pX7i6n),
type: AutomodTriggerType.MENTION_SPAM,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 1,
availableActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE, AutomodActionType.FLAG_TO_CHANNEL, AutomodActionType.USER_COMMUNICATION_DISABLED]),
flags: new Set([]),
defaultActionTypes: new Set([AutomodActionType.BLOCK_MESSAGE])
};
r32[AutomodTriggerType.USER_PROFILE] = {
getDefaultRuleName: () => intl.string(t.q1L2v8),
type: AutomodTriggerType.USER_PROFILE,
eventType: AutomodEventType.GUILD_MEMBER_JOIN_OR_UPDATE,
perGuildMaxCount: 1,
availableActionTypes: new Set([AutomodActionType.QUARANTINE_USER, AutomodActionType.FLAG_TO_CHANNEL]),
flags: new Set([]),
defaultActionTypes: new Set([AutomodActionType.QUARANTINE_USER])
};
r32[AutomodTriggerType.SERVER_POLICY] = {
getDefaultRuleName: () => intl.string(t.ZQr92M),
type: AutomodTriggerType.SERVER_POLICY,
eventType: AutomodEventType.MESSAGE_SEND,
perGuildMaxCount: 1,
availableActionTypes: new Set([AutomodActionType.FLAG_TO_CHANNEL]),
flags: new Set([r27.ALPHA]),
defaultActionTypes: new Set()
};
c11784_5 = r32;
c11784_6 = {
MEMBERS: "members",
CONTENT: "content"
};
const r218 = {};
r218[c11784_6.MEMBERS] = [c11784_5[AutomodTriggerType.USER_PROFILE]];
r218[c11784_6.CONTENT] = [c11784_5[AutomodTriggerType.SERVER_POLICY], c11784_5[AutomodTriggerType.MENTION_SPAM], c11784_5[AutomodTriggerType.ML_SPAM], c11784_5[AutomodTriggerType.DEFAULT_KEYWORD_LIST], c11784_5[AutomodTriggerType.KEYWORD]];
c11784_7 = r218;
export { r27 as AutomodTriggerConfigFlags };
export { c11784_5 as triggerConfigs };
export { c11784_6 as AutomodTriggerCategory };
export { c11784_7 as AUTOMOD_RULE_CONFIGS_BY_CATEGORY };
export function checkTriggerTypeForFlag(a0, a1) {
return c11784_5[a0].flags.has(a1);
}
export function getAvailableActionTypes(a0) {
return Array.from(c11784_5[a0].availableActionTypes);
}
export function validateRuleByTriggerConfigOrThrow({ id, eventType, triggerType, actions }, a1) {
const r14 = c11784_5[triggerType];
let c23117_2 = r14;
if (a1.filter((item) => id !== item.id && item.triggerType === triggerType).length > r14.perGuildMaxCount) {
throw new Error(`You have exceeded the maximum number of rules of type ${triggerType}`);
}
if (actions.some((action) => !c23117_2.availableActionTypes.has(action.type))) {
throw new Error("You have provided an action that is not available for this trigger type");
}
if (eventType !== r14.eventType) {
throw new Error("You have provided an event type that is not available for this trigger type");
}
}
export function useAvailableTriggerTypes(a0) {
const isUserProfileRuleEnabled = useIsUserProfileRuleEnabled(a0);
return useMemo(() => {
const r3 = {};
r3[c11784_6.MEMBERS] = [];
r3[c11784_6.CONTENT] = [];
return Object.keys(c11784_7).reduce((acc, a1) => {
acc[a1] = c11784_7[a1].filter((item) => {
let r2 = item.type !== AutomodTriggerType.SERVER_POLICY;
if (r2) {
const r1 = item.type === AutomodTriggerType.USER_PROFILE && !isUserProfileRuleEnabled;
r2 = r1 ? !r1 : item.perGuildMaxCount > 0;
}
return r2;
}).map((item) => item.type);
return acc;
}, r3);
}, [isUserProfileRuleEnabled]);
}
export function getDefaultTriggerMetadataForTriggerType(a0, a1) {
const isInMentionRaidExperiment = _ExperimentUtils.isInMentionRaidExperiment(a1);
if (AutomodTriggerType.DEFAULT_KEYWORD_LIST === a0) {
return {
allowList: [],
presets: []
};
}
if (AutomodTriggerType.USER_PROFILE !== a0 && AutomodTriggerType.KEYWORD !== a0) {
if (AutomodTriggerType.MENTION_SPAM === a0) {
return {
mentionTotalLimit: MENTION_SPAM_LIMIT_DEFAULT,
mentionRaidProtectionEnabled: isInMentionRaidExperiment
};
}
if (AutomodTriggerType.ML_SPAM !== a0) {
AutomodTriggerType.SERVER_POLICY;
}
return void 0;
}
return {
keywordFilter: [],
regexPatterns: [],
allowList: []
};
}
+33
View File
@@ -0,0 +1,33 @@
// Metro module 11053 (f11054).
import * as _Module11054 from "../../_bundle/Module11054";
import * as _Module11055 from "../../_bundle/Module11055";
import * as _Module11056 from "../../_bundle/Module11056";
const r14 = {
PROFANITY: 1,
1: "PROFANITY",
SEXUAL_CONTENT: 2,
2: "SEXUAL_CONTENT",
SLURS: 3,
3: "SLURS"
};
const r23 = [_Module11054.AutomodTriggerType.USER_PROFILE, _Module11054.AutomodTriggerType.SERVER_POLICY, _Module11054.AutomodTriggerType.MENTION_SPAM, _Module11054.AutomodTriggerType.ML_SPAM, _Module11054.AutomodTriggerType.DEFAULT_KEYWORD_LIST, _Module11054.AutomodTriggerType.KEYWORD];
export const AutomodEventType = _Module11055.AutomodEventType;
export const AutomodTriggerType = _Module11054.AutomodTriggerType;
export const AutomodActionType = _Module11056.AutomodActionType;
export { r14 as KeywordPreset };
export { r23 as AUTOMOD_TRIGGER_TYPES };
export const MAX_KEYWORDS_PER_KEYWORD_FILTER = 1000;
export const MAX_KEYWORDS_PER_ALLOWLIST_KEYWORD_FILTER_RULE = 100;
export const MAX_KEYWORDS_PER_ALLOWLIST_DEFAULT_KEYWORD_RULE = 1000;
export const MAX_REGEX_PATTERNS_PER_KEYWORD_FILTER = 10;
export const MAX_CHARACTERS_PER_KEYWORD = 60;
export const MIN_CHARACTERS_PER_KEYWORD = 1;
export const MIN_REGEX_PATTERN_LENGTH = 1;
export const MAX_REGEX_PATTERN_LENGTH = 260;
export const MAX_RULE_NAME_LENGTH = 100;
export const MIN_MENTION_SPAM_LIMIT = 1;
export const MAX_MENTION_SPAM_LIMIT = 50;
export const MENTION_SPAM_LIMIT_DEFAULT = 20;
export const MAX_BLOCK_ACTION_CUSTOM_MESSAGE_LENGTH = 300;
export const SUBMIT_FEEDBACK_MODAL_KEY = "automod-submit-feedback";
export const QUARANTINE_USER_ALERT_KEY = "automod-profile-quarantine-alert";
+65
View File
@@ -0,0 +1,65 @@
// Metro module 11059 (f11060).
function $mk86294($env) {
return (a0, a1) => {
const r5 = $env.$parent;
const r13 = (0, r5[0])(r5[1][0]).camelCase(a1);
const r15 = $env[0];
if (typeof r15[a1] === "object" && !Array.isArray(r15[a1])) {
let env26926;
const r18 = r15[a1];
const r19 = env26926 = {
$parent: r5
};
env26926[0] = r18;
let r21 = r18;
if (r21 != null) {
r21 = Object.keys(r18).reduce($mk86294(r19), {});
}
a0[r13] = r21;
} else {
a0[r13] = r15[a1];
}
return a0;
};
}
function $mk86295($env) {
return (a0, a1) => {
const r5 = $env.$parent;
const r13 = (0, r5[0])(r5[1][0]).snakeCase(a1);
const r15 = $env[0];
if (typeof r15[a1] === "object" && !Array.isArray(r15[a1])) {
let env26927;
const r18 = r15[a1];
const r19 = env26927 = {
$parent: r5
};
env26927[0] = r18;
let r21 = r18;
if (r21 != null) {
r21 = Object.keys(r18).reduce($mk86295(r19), {});
}
a0[r13] = r21;
} else {
a0[r13] = r15[a1];
}
a0[r13] = r15[a1];
return a0;
};
}
let env7458 = {};
export function _transformMetadataToCamelCase(a0) {
let env18505;
const r2 = env18505 = {
$parent: env7458
};
env18505[0] = a0;
return a0 != null ? Object.keys(a0).reduce($mk86294(r2), {}) : a0;
}
export function _transformMetadataToSnakeCase(a0) {
let env18506;
const r2 = env18506 = {
$parent: env7458
};
env18506[0] = a0;
return a0 != null ? Object.keys(a0).reduce($mk86295(r2), {}) : a0;
}
+16
View File
@@ -0,0 +1,16 @@
// Metro module 10266 (f10267).
import { AutomodMentionRaidLimit } from "./AutomodExperiment";
export function isInMentionRaidExperiment(a0) {
return AutomodMentionRaidLimit.getCurrentConfig({
guildId: a0,
location: "988d4e_3"
}).enabled;
}
export function useIsMentionRaidExperimentEnabled(a0, autoTrackExposure = true) {
return AutomodMentionRaidLimit.useExperiment({
guildId: a0,
location: "988d4e_4"
}, {
autoTrackExposure
}).enabled;
}
@@ -0,0 +1,31 @@
// Metro module 11052 (f11053).
import { AutomodActionType, SUBMIT_FEEDBACK_MODAL_KEY } from "./Constants";
import ModalActionCreators from "../../actions/ModalActionCreators";
import AlertActionCreators from "../../actions/native/AlertActionCreators";
export function getPromiseableActionHandlers() {
const r1 = {};
r1[AutomodActionType.BLOCK_MESSAGE] = null;
r1[AutomodActionType.FLAG_TO_CHANNEL] = null;
r1[AutomodActionType.USER_COMMUNICATION_DISABLED] = null;
return r1;
}
export function openSubmitFeedback(a0, a1, a2, a3) {
ModalActionCreators.pushLazy(import("./native/AutomodSubmitFeedbackModal"), {
onCloseModal: function onCloseModal() {
ModalActionCreators.popWithKey(SUBMIT_FEEDBACK_MODAL_KEY);
},
automodDecision: {
messageId: a0,
messageContent: a1,
decisionId: a2,
channel: a3
}
}, SUBMIT_FEEDBACK_MODAL_KEY);
}
export function openRaidResolveModal() {}
export function openConfirmRemoveMentionRaid() {}
export function openAutomodProfileQuarantineAlert(guildId) {
AlertActionCreators.openLazy({
importer: () => import("./native/AutomodUserProfileQuarantineAlert").then(({ default: Component }) => (a0) => <Component {...a0} guildId={guildId} />)
});
}
@@ -0,0 +1,179 @@
// Metro module 11058 (f11059).
import GuildStore from "../../stores/GuildStore";
import PermissionStore from "../../stores/PermissionStore";
import { AnalyticEvents, Endpoints, Permissions } from "../../Constants";
import { _transformMetadataToSnakeCase, _transformMetadataToCamelCase } from "./DataUtils";
import { isNotNullish } from "../../utils/GlobalUtils";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import { HTTP, rejectWithMigratedError } from "../../_bundle/sendRequest";
import { openConfirmRemoveMentionRaid } from "./GuildAutomodActionActionCreators.native";
import { trackWithMetadata } from "../app_analytics/AppAnalyticsUtils";
import { Feedback } from "./AutomodFeedback";
import Dispatcher from "../../Dispatcher";
let _transformClientRuleToApiRule, _transformApiActionToClientAction, _transformApiRuletoClientRule;
const _transformClientActionToApiAction = function _transformClientActionToApiAction(a0) {
return {
type: a0.type,
metadata: _transformMetadataToSnakeCase(a0.metadata)
};
};
_transformClientRuleToApiRule = function _transformClientRuleToApiRule(a0) {
const trigger_metadata = _transformMetadataToSnakeCase(a0.triggerMetadata);
if (trigger_metadata != null) {
delete trigger_metadata["keywordLists"];
}
const r14 = {
id: a0.id,
name: a0.name,
guild_id: a0.guildId,
event_type: a0.eventType,
trigger_type: a0.triggerType,
trigger_metadata,
actions: a0.actions.filter(isNotNullish).map(_transformClientActionToApiAction),
enabled: a0.enabled,
creator_id: a0.creatorId,
position: a0.position,
exempt_channels: null,
exempt_roles: null
};
const r32 = Array;
let exemptChannels = a0.exemptChannels;
if (exemptChannels == null) {
exemptChannels = [];
}
r14.exempt_channels = r32.from(exemptChannels);
const r36 = Array;
let exemptRoles = a0.exemptRoles;
if (exemptRoles == null) {
exemptRoles = [];
}
r14.exempt_roles = r36.from(exemptRoles);
return r14;
};
_transformApiActionToClientAction = function _transformApiActionToClientAction(a0) {
return {
type: a0.type,
metadata: _transformMetadataToCamelCase(a0.metadata)
};
};
_transformApiRuletoClientRule = function _transformApiRuletoClientRule(a0) {
let id = a0.id;
if (id == null) {
id = SnowflakeUtils.fromTimestamp(Date.now());
}
const r17 = {
id,
name: a0.name,
guildId: a0.guild_id,
eventType: a0.event_type,
triggerType: a0.trigger_type,
triggerMetadata: _transformMetadataToCamelCase(a0.trigger_metadata),
actions: a0.actions.filter(isNotNullish).map(_transformApiActionToClientAction),
enabled: a0.enabled,
creatorId: a0.creator_id,
position: a0.position,
exemptChannels: null,
exemptRoles: null
};
const r42 = Set;
let exempt_channels = a0.exempt_channels;
if (exempt_channels == null) {
exempt_channels = [];
}
r17.exemptChannels = new r42(exempt_channels);
const r47 = Set;
let exempt_roles = a0.exempt_roles;
if (exempt_roles == null) {
exempt_roles = [];
}
r17.exemptRoles = new r47(exempt_roles);
if (r17.triggerMetadata != null) {
delete r17.triggerMetadata["keywordLists"];
}
return r17;
};
export async function validateAutomodRule(c26920_0) {
let c26920_2;
c26920_2 = void 0;
const body = _transformClientRuleToApiRule(c26920_0);
let c30338_0 = await HTTP.post({
url: Endpoints.GUILD_AUTOMOD_VALIDATE_RULE(c26920_0.guildId),
body,
rejectWithError: rejectWithMigratedError()
});
return _transformMetadataToCamelCase(c30338_0.body);
}
export async function createAutomodRule(c26921_0) {
const body = _transformClientRuleToApiRule(c26921_0);
delete body["id"];
const _transformApiRuletoClientRule2 = _transformApiRuletoClientRule;
return _transformApiRuletoClientRule2((await HTTP.post({
url: Endpoints.GUILD_AUTOMOD_RULES(c26921_0.guildId),
body,
rejectWithError: rejectWithMigratedError()
})).body);
}
export async function updateAutomodRule(c26922_0) {
const body = _transformClientRuleToApiRule(c26922_0);
const _transformApiRuletoClientRule3 = _transformApiRuletoClientRule;
return _transformApiRuletoClientRule3((await HTTP.patch({
url: Endpoints.GUILD_AUTOMOD_RULE(c26922_0.guildId, c26922_0.id),
body,
rejectWithError: rejectWithMigratedError()
})).body);
}
export async function deleteAutomodRule(c26923_0, c26923_1) {
await HTTP.del({
url: Endpoints.GUILD_AUTOMOD_RULE(c26923_1, c26923_0),
rejectWithError: rejectWithMigratedError()
});
return true;
}
export async function fetchAutomodRules(c26924_0) {
let c26924_2;
c26924_2 = void 0;
let c30339_0 = await HTTP.get({
url: Endpoints.GUILD_AUTOMOD_RULES(c26924_0),
rejectWithError: rejectWithMigratedError()
});
return Array.isArray(c30339_0.body) ? c30339_0.body.map(_transformApiRuletoClientRule) : [];
}
export async function executeAlertAction(message_id, c26925_1, alert_action_type) {
L11: {
if (PermissionStore.can(Permissions.MANAGE_MESSAGES, c26925_1)) {
await HTTP.post({
url: Endpoints.GUILD_AUTOMOD_ALERT_ACTION(c26925_1.guild_id),
body: {
message_id,
channel_id: c26925_1.id,
alert_action_type
},
rejectWithError: rejectWithMigratedError()
});
break L11;
}
return void 0;
}
}
export function removeMentionRaidRestrictionWithFeedback(a0, decision_id, c18504_2) {
const guild = GuildStore.getGuild(a0);
if (guild != null && PermissionStore.can(Permissions.MANAGE_GUILD, guild)) {
openConfirmRemoveMentionRaid(function() {
trackWithMetadata(AnalyticEvents.GUILD_AUTOMOD_FEEDBACK, {
feedback_type: Feedback.MENTION_RAID_REMOVE_RESTRICTION,
decision_id
});
HTTP.post({
url: Endpoints.GUILD_AUTOMOD_CLEAR_MENTION_RAID(a0),
rejectWithError: true
});
c18504_2();
});
}
}
export function clearMentionRaidDetected(a0) {
Dispatcher.dispatch({
type: "AUTO_MODERATION_MENTION_RAID_NOTICE_DISMISS",
guildId: a0
});
}
@@ -0,0 +1,8 @@
// Metro module 9514 (f9515).
import Dispatcher from "../../Dispatcher";
export function removeAutomodMessageNotice(a0) {
Dispatcher.dispatch({
type: "REMOVE_AUTOMOD_MESSAGE_NOTICE",
messageId: a0
});
}
@@ -0,0 +1,165 @@
// Metro module 7719 (f7720).
import ChannelStore from "../../stores/ChannelStore";
import MessageStore from "../../stores/MessageStore";
import { AbortCodes, MessageEmbedTypes, MessageTypes } from "../../Constants";
import { getFailedMessageId, isMessageDataEdit } from "../../lib/MessageQueue";
import { getAutomodErrorMessage } from "./AutomodErrorUtils";
import { createMessageRecord } from "../messages/MessageRecordUtils";
import { isAutomodMessageRecord, isAutomodNotification } from "./AutomodMessageUtils";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let automodFailedMessages, c4852_9, mentionRaidDetectionByGuild, lastIncidentAlertMessage;
const handleMessageSendFailedAutomod = function handleMessageSendFailedAutomod({ messageData, errorResponseBody }) {
const failedMessageId = getFailedMessageId(messageData);
automodFailedMessages[failedMessageId] = {
id: failedMessageId,
isBlockedEdit: isMessageDataEdit(messageData),
messageData,
errorMessage: getAutomodErrorMessage(messageData, errorResponseBody)
};
c4852_9 = c4852_9 + 1;
return true;
};
const handleLoadMessages = function handleLoadMessages({ channelId, messages }) {
const channel = ChannelStore.getChannel(channelId);
const r10 = channel == null ? void 0 : channel.getGuildId();
if (r10 == null) {
return false;
}
const r15 = messages.reduce((acc, message) => {
if (message.type === MessageTypes.AUTO_MODERATION_ACTION) {
const embeds = message.embeds;
return (embeds == null ? void 0 : embeds.some((embed) => embed.type === MessageEmbedTypes.AUTO_MODERATION_NOTIFICATION)) ? acc != null ? SnowflakeUtils.compare(acc, message.id) === -1 ? message.id : void 0 : message.id : acc;
}
return acc;
}, lastIncidentAlertMessage[r10]);
let r16 = r15 != null && lastIncidentAlertMessage[r10] !== r15;
if (r16) {
lastIncidentAlertMessage[r10] = r15;
r16 = true;
}
return r16;
};
automodFailedMessages = {};
c4852_9 = 0;
mentionRaidDetectionByGuild = {};
lastIncidentAlertMessage = {};
class GuildAutomodMessageStore extends Module589.PersistedStore {
static displayName = "GuildAutomodMessageStore";
static persistKey = "GuildAutomodMessages";
initialize(a0) {
this.waitFor(ChannelStore, MessageStore);
if (a0 != null) {
automodFailedMessages = a0.automodFailedMessages;
mentionRaidDetectionByGuild = a0.mentionRaidDetectionByGuild;
}
}
getState() {
return {
automodFailedMessages,
mentionRaidDetectionByGuild,
lastIncidentAlertMessage
};
}
getMessage(a0) {
const r1 = a0 == null;
let r2 = null;
if (!r1) {
let r6 = automodFailedMessages[a0];
if (r6 == null) {
r6 = null;
}
r2 = r6;
}
return r2;
}
getMessagesVersion() {
return c4852_9;
}
getMentionRaidDetected(a0) {
let r4 = mentionRaidDetectionByGuild[a0];
if (r4 == null) {
r4 = null;
}
return r4;
}
getLastIncidentAlertMessage(a0) {
let r4 = lastIncidentAlertMessage[a0];
if (r4 == null) {
r4 = null;
}
return r4;
}
}
const guildAutomodMessageStore = new GuildAutomodMessageStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
let r1 = Object.keys(automodFailedMessages).length !== 0;
if (r1) {
automodFailedMessages = {};
c4852_9 = c4852_9 + 1;
r1 = true;
}
return r1;
},
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOCAL_MESSAGES_LOADED: handleLoadMessages,
MESSAGE_CREATE: function handleIncidentAlertMessageCreate({ guildId, message }) {
if (guildId == null) {
return false;
}
if (message.type !== MessageTypes.AUTO_MODERATION_ACTION) {
return false;
}
const messageRecord = createMessageRecord(message);
let r21 = !!isAutomodMessageRecord(messageRecord);
if (r21) {
let r27 = !!isAutomodNotification(messageRecord);
if (r27) {
lastIncidentAlertMessage[guildId] = messageRecord.id;
r27 = true;
}
r21 = r27;
}
return r21;
},
MESSAGE_SEND_FAILED_AUTOMOD: handleMessageSendFailedAutomod,
MESSAGE_EDIT_FAILED_AUTOMOD: handleMessageSendFailedAutomod,
REMOVE_AUTOMOD_MESSAGE_NOTICE: function handleMessageNoticeRemove({ messageId }) {
if (automodFailedMessages[messageId] != null) {
delete automodFailedMessages[messageId];
}
c4852_9 = c4852_9 + 1;
return true;
},
MESSAGE_END_EDIT: function handleMessageEndEdit({ response }) {
if (response?.body == null) {
return false;
}
if (response.body.code === AbortCodes.AUTOMOD_MESSAGE_BLOCKED) {
return false;
}
const id = response.body.id;
if (id == null) {
return false;
}
if (automodFailedMessages[id] != null) {
delete automodFailedMessages[id];
}
c4852_9 = c4852_9 + 1;
},
AUTO_MODERATION_MENTION_RAID_DETECTION: function handleMentionRaidDetection(a0) {
const guildId = a0.guildId;
mentionRaidDetectionByGuild[guildId] = {
guildId,
decisionId: a0.decisionId,
suspiciousMentionActivityUntil: a0.suspiciousMentionActivityUntil
};
return true;
},
AUTO_MODERATION_MENTION_RAID_NOTICE_DISMISS: function handleMentionRaidNoticeDismiss(a0) {
delete mentionRaidDetectionByGuild[a0.guildId];
return true;
}
});
export default guildAutomodMessageStore;
@@ -0,0 +1,5 @@
// Metro module 12820 (f12821).
import { MessageEmbedTypes } from "../../_bundle/Module693";
export function isNotAutomodEmbed({ type }) {
return type !== MessageEmbedTypes.AUTO_MODERATION_MESSAGE && type !== MessageEmbedTypes.AUTO_MODERATION_NOTIFICATION;
}
+31
View File
@@ -0,0 +1,31 @@
// Metro module 15660 (f15661).
import GuildStore from "../../stores/GuildStore";
import PermissionStore from "../../stores/PermissionStore";
import { GuildFeatures, Permissions } from "../../Constants";
import { useStateFromStores } from "../../_bundle/Module589";
export function canCurrentUserManageMessageFilters(a0) {
let r1 = a0 != null;
if (r1) {
const guild = GuildStore.getGuild(a0);
r1 = guild != null && PermissionStore.can(Permissions.MANAGE_GUILD, guild);
}
return r1;
}
export function canCurrentUserManageAutomod(a0) {
const guild = GuildStore.getGuild(a0);
return guild != null && PermissionStore.can(Permissions.MANAGE_GUILD, guild);
}
export function useCanCurrentUserManageAutomod(a0) {
return useStateFromStores([GuildStore, PermissionStore], () => {
if (GuildStore !== void 0 && PermissionStore !== void 0) {
const guild = GuildStore.getGuild(a0);
return guild != null && PermissionStore.can(Permissions.MANAGE_GUILD, guild);
}
}, [a0]);
}
export function useIsUserProfileRuleEnabled(a0) {
return useStateFromStores([GuildStore], () => {
const guild = GuildStore.getGuild(a0);
return (guild == null ? void 0 : guild.features.has(GuildFeatures.COMMUNITY)) || false;
}, [a0]);
}
@@ -0,0 +1,5 @@
// Metro module 16376 (f16377).
let c11783_0 = new Set(["1030554520465440818"]);
export function isDefaultRuleId(a0) {
return a0 != null && c11783_0.has(a0);
}
@@ -0,0 +1,138 @@
// Metro module 11057 (f11058).
import { Fragment, useState, useMemo } from "react";
import { View } from "react-native";
import { AnalyticEvents } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView";
import { HeaderActionButton } from "../../../design/components/Navigator/native/HeaderActionButton.native";
import { intl, t } from "../../../intl/index.native";
import Module7699 from "../../../_bundle/Module7699";
import { generateFeedbackOptions, Feedback } from "../AutomodFeedback";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import { Text } from "../../../design/components/Text/native/Text";
import { FormRow, FormDivider } from "../../../design/void/Form/native/index";
import { RadioIndicator } from "../../../design/void/native";
import { Button } from "../../../design/components/Button/native/Button.native";
import { trackWithMetadata } from "../../app_analytics/AppAnalyticsUtils";
import { executeAlertAction } from "../GuildAutomodActionCreators";
import { AutomodAlertActionType } from "../AutomodAlert";
import { presentFeedbackSent } from "../../toast/native/ToastUtils";
import { Navigator } from "../../../design/components/Navigator/native/Navigator.native";
let initialRouteName, useStyles, SubmitFeedbackScreen;
const Navbar = function Navbar(props) {
const onClose = props.onClose;
const styles2 = useStyles();
return <SafeAreaPaddingView top style={styles2.header}>
<View style={styles2.closeButtonContainer}>
<HeaderActionButton accessibilityLabel={intl.string(t.cpT0Cq)} onPress={onClose} source={Module7699} />
</View>
</SafeAreaPaddingView>;
};
SubmitFeedbackScreen = function SubmitFeedbackScreen(props) {
const { feedback, onChange: onChange2, onSubmit: onSubmit3 } = props;
const styles = useStyles();
const r15 = generateFeedbackOptions();
let c18502_3 = r15;
const bottom = useSafeAreaInsets_native().bottom;
return <View style={styles.container}>
<Text style={styles.headerTitle} variant="heading-xl/bold" color="mobile-text-heading-primary">
{intl.string(t["7bdzNo"])}
</Text>
<Text style={styles.headerSubtitle} variant="text-sm/medium" color="text-default">
{intl.string(t.Lbpk6m)}
</Text>
<View style={styles.formBody}>
{r15.map(({ name, value }, index) => <Fragment key={value}>
<FormRow onPress={() => onChange2(value)} trailing={<RadioIndicator active={feedback === value} style={styles.radioIndicator} />} label={<Text style={styles.formRow} variant="text-md/semibold" color="interactive-text-active">{name}</Text>} />
{index < c18502_3.length - 1 && <FormDivider />}
</Fragment>)}
</View>
<View style={[styles.submitButtonContainer, {
paddingBottom: bottom + 16
}]}>
<Button size="md" text={intl.string(t.Z6DZZ6)} onPress={onSubmit3} />
</View>
</View>;
};
initialRouteName = "SUBMIT_FEEDBACK";
useStyles = createStyles({
container: {
flex: 1,
paddingHorizontal: 16,
paddingVertical: 0,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
flexDirection: "column",
height: "100%",
paddingTop: 8
},
header: {
flexDirection: "row",
justifyContent: "flex-end",
paddingVertical: 8,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
},
headerTitle: {
textAlign: "center"
},
headerSubtitle: {
textAlign: "center",
marginTop: 8
},
closeButtonContainer: {
marginVertical: 14
},
formBody: {
marginTop: 24,
borderRadius: Module712.radii.sm,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH
},
formRow: {
paddingVertical: 2
},
radioIndicator: {
marginRight: 0
},
submitButtonContainer: {
position: "absolute",
bottom: 0,
left: 0,
right: 0,
paddingHorizontal: 16,
paddingVertical: 16,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
}
});
export default function AutomodSubmitFeedbackModal(props) {
const { onCloseModal, automodDecision } = props;
const top = useSafeAreaInsets_native().top;
const [state, setState] = useState(Feedback.BUG);
return <Navigator screens={useMemo(() => {
let onSubmit2;
const onCloseModal2 = onCloseModal;
const state2 = state;
const onChange3 = function onChange(a0) {
setState(a0);
};
onSubmit2 = function onSubmit() {
trackWithMetadata(AnalyticEvents.GUILD_AUTOMOD_FEEDBACK, {
feedback_type: state,
message_id: automodDecision.messageId,
content: automodDecision.messageContent,
decision_id: automodDecision.decisionId
});
executeAlertAction(automodDecision.messageId, automodDecision.channel, AutomodAlertActionType.SUBMIT_FEEDBACK);
presentFeedbackSent();
onCloseModal();
};
const r8 = {};
r8[initialRouteName] = {
ignoreKeyboard: true,
title: "",
customNavbar: () => <Navbar onClose={onCloseModal2} />,
headerLeft: () => null,
render: () => <SubmitFeedbackScreen feedback={state2} onChange={onChange3} onSubmit={onSubmit2} />
};
return r8;
}, [state, onCloseModal, automodDecision])} initialRouteName={initialRouteName} headerStatusBarHeight={top} />;
};
@@ -0,0 +1,119 @@
// Metro module 11060 (f11061).
import _objectWithoutProperties from "../../../_bundle/_objectWithoutProperties";
import { View } from "react-native";
import AuthenticationStore from "../../../stores/AuthenticationStore";
import GuildMemberStore from "../../../stores/GuildMemberStore";
import GuildStore from "../../../stores/GuildStore";
import { QUARANTINE_USER_ALERT_KEY } from "../Constants";
import { AnalyticEvents, UserSettingsSections } from "../../../Constants";
import { GuildMemberFlags } from "../../guild_member/GuildMemberConstants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import Alert from "../../../components_native/common/Alert";
import { intl, t } from "../../../intl/index.native";
import { Icon } from "../../../design/void/native";
import Module11061 from "../../../_bundle/Module11061";
import { Text } from "../../../design/components/Text/native/Text";
import { useOpenFixQuarantinedProfileModal } from "../AutomodQuarantineUtils";
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
import { useStateFromStores } from "../../../_bundle/defaultAreStatesEqual";
import { getAutomodReason, getAutomodQuarantinedGuildMemberFlags } from "../AutomodPermissionUtils";
import useMountEffect from "../../../hooks/useMountEffect";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
let _excluded, _excluded2, _excluded3, useStyles, PerServerProfileAlert, ServerTagAlert;
const ChatBlockedAlert = function ChatBlockedAlert(props) {
const { title, description, buttonCta, onConfirm: onConfirm2, ...rest } = props;
const styles = useStyles();
return <Alert {...rest} style={styles.wrapper} cancelText={intl.string(t["ETE/oC"])} onCancel={rest?.onClose} confirmText={buttonCta} onConfirm={onConfirm2}>
<View style={styles.body}>
<Icon source={Module11061} size={Icon.Sizes.CUSTOM} style={styles.mainIcon} />
<Text style={styles.title} accessibilityRole="header" variant="heading-md/medium" color="mobile-text-heading-primary">{title}</Text>
<Text style={styles.description} variant="text-sm/medium" color="text-default">{description}</Text>
</View>
</Alert>;
};
PerServerProfileAlert = function PerServerProfileAlert(props) {
const { guildId: guildId2, guildName, automodReason, ...rest } = props;
let description = automodReason === GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME ? intl.string(t.SpDXI7) : intl.string(t.TBeZmG);
let [c18507_0, r46] = useOpenFixQuarantinedProfileModal({
guildId: guildId2
});
if (!r46) {
description = intl.string(t.FFj5Dt);
}
const buttonCta = r46 ? intl.string(t["/PGQf0"]) : intl.string(t.WikgZ1);
return <ChatBlockedAlert {...rest} title={intl.format(t.kcYdTq, {
guildName
})} description={description} buttonCta={buttonCta} onConfirm={function onConfirm() {
c18507_0();
}} />;
};
ServerTagAlert = function ServerTagAlert(props) {
const guildName = props.guildName;
return <ChatBlockedAlert {..._objectWithoutProperties(props, _excluded3)} title={intl.format(t.c8TwbL, {
guildName
})} description={intl.string(t.EJJLHp)} buttonCta={intl.string(t.Viksoo)} onConfirm={function onConfirm() {
openUserSettings({
screen: UserSettingsSections.PROFILE_CUSTOMIZATION
});
}} />;
};
_excluded = ["title", "description", "buttonCta", "onConfirm"];
_excluded2 = ["guildId", "guildName", "automodReason"];
_excluded3 = ["guildName"];
useStyles = createStyles({
wrapper: {
padding: 16
},
body: {
flexDirection: "column",
alignItems: "center"
},
mainIcon: {
width: 48,
height: 48,
tintColor: Module712.colors.TEXT_FEEDBACK_CRITICAL,
marginBottom: 16
},
title: {
marginBottom: 16,
textAlign: "center"
},
description: {
textAlign: "center"
}
});
export default function AutomodUserProfileQuarantineAlert(props) {
let r49;
const guildId = props.guildId;
const stateFromStores = useStateFromStores([AuthenticationStore], () => AuthenticationStore.getId());
let guildName = useStateFromStores([GuildStore], () => GuildStore.getGuild(guildId), [guildId])?.name;
if (guildName == null) {
guildName = "";
}
L11: {
const stateFromStores2 = useStateFromStores([GuildMemberStore], () => {
if (guildId == null) {
return null;
}
return getAutomodReason(getAutomodQuarantinedGuildMemberFlags(GuildMemberStore.getMember(guildId, stateFromStores)));
}, [guildId, stateFromStores]);
useMountEffect(() => {
AnalyticsUtils.track(AnalyticEvents.OPEN_MODAL, {
type: QUARANTINE_USER_ALERT_KEY,
guild_id: guildId,
other_user_id: stateFromStores
});
});
if (stateFromStores2 !== GuildMemberFlags.AUTOMOD_QUARANTINED_BIO && stateFromStores2 !== GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME) {
if (stateFromStores2 === GuildMemberFlags.AUTOMOD_QUARANTINED_SERVER_TAG) {
r49 = <ServerTagAlert guildName={guildName} {...props} />;
break L11;
}
r49 = <PerServerProfileAlert automodReason={stateFromStores2} guildName={guildName} {...props} />;
} else {
r49 = <PerServerProfileAlert automodReason={stateFromStores2} guildName={guildName} {...props} />;
}
}
return r49;
};
@@ -0,0 +1,132 @@
// Metro module 11024 (f11025).
import { memo, Fragment } from "react";
import GuildMemberStore from "../../../stores/GuildMemberStore";
import GuildStore from "../../../stores/GuildStore";
import PermissionStore from "../../../stores/PermissionStore";
import UserStore from "../../../stores/UserStore";
import { Permissions } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import { useStateFromStores, useStateFromStoresObject } from "../../../_bundle/Module589";
import { canKickMember, canBanMember } from "../../guild_member/GuildMemberUtils";
import { canToggleCommunicationDisableOnUser } from "../../guild_communication_disabled/useCanToggleCommunicationDisableOnUser";
import NicknameUtils from "../../../utils/NicknameUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import { ActionSheetRow } from "../../../design/components/Sheet/native/ActionSheetRow.native";
import { intl, t } from "../../../intl/index.native";
import { SettingsIcon } from "../../../design/components/Icon/native/redesign/generated/SettingsIcon";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import showModerateUserActionSheet from "./showModerateUserActionSheet";
import * as _CommunicationDisabledUtils from "../../guild_communication_disabled/CommunicationDisabledUtils";
import { ClockWarningIcon } from "../../../design/components/Icon/native/redesign/generated/ClockWarningIcon";
import { openEnableCommunication, openDisableCommunication } from "../../guild_communication_disabled/GuildDisableCommunicationActionCreators.native";
import { UserMinusIcon } from "../../../design/components/Icon/native/redesign/generated/UserMinusIcon";
import showKickConfirmModal from "../../guild_moderation/native/showKickConfirmModal";
import { HammerIcon } from "../../../design/components/Icon/native/redesign/generated/HammerIcon";
import showBanConfirmModal from "../../guild_moderation/native/showBanConfirmModal";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { BottomSheetTitleHeader } from "../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
import MemberRolesList from "../../../components_native/MemberRolesList";
import { TableRowGroup } from "../../../design/components/TableRow/native/TableRowGroup.native";
const useStyles = createStyles({
container: {
padding: 16,
gap: 16
},
memberRoles: {
justifyContent: "flex-start"
}
});
const r39 = memo(function({ user, guild }) {
let hideActionSheet, isMemberCommunicationDisabled;
hideActionSheet = void 0;
isMemberCommunicationDisabled = void 0;
const styles = useStyles();
const stateFromStores = useStateFromStores([GuildMemberStore], () => GuildMemberStore.getMember(guild?.id, user.id), [user, guild]);
const userRoles = stateFromStores != null ? stateFromStores.roles : [];
const stateFromStoresObject = useStateFromStoresObject([PermissionStore, UserStore, GuildStore], () => ({
canKickUser: guild != null && canKickMember(user, guild),
canBanUser: guild != null && canBanMember(user, guild),
canChangeNick: guild != null && PermissionStore.canManageUser(Permissions.MANAGE_NICKNAMES, user, guild),
canManageRoles: guild != null && PermissionStore.can(Permissions.MANAGE_ROLES, guild),
canModerateMembers: guild != null && canToggleCommunicationDisableOnUser(guild.id, user.id, [UserStore, GuildStore, PermissionStore])
}), [user, guild]);
const { canKickUser, canBanUser, canChangeNick, canManageRoles, canModerateMembers } = stateFromStoresObject;
if (guild != null && stateFromStores != null) {
const name = NicknameUtils.getName(guild.id, void 0, user);
hideActionSheet = ActionSheetActionCreators.hideActionSheet;
const r47 = stateFromStores != null && ((canKickUser ? canKickUser : canBanUser) || canChangeNick || canManageRoles) && !user.isNonUserBot();
const r51 = [];
if (r47) {
r51.push(<ActionSheetRow label={intl.string(t.HxrBOZ)} icon={<ActionSheetRow.Icon IconComponent={SettingsIcon} />} onPress={() => {
hideActionSheet();
ModalActionCreators.pushLazy(import("../../guild_settings/native/GuildSettingsModalMemberEdit"), {
userId: user.id,
guildId: guild.id,
onClose: () => {
ModalActionCreators.pop();
showModerateUserActionSheet({
guild,
user
});
},
onRemove: () => {
ModalActionCreators.pop();
}
});
}} />);
}
if (stateFromStores != null && canModerateMembers) {
isMemberCommunicationDisabled = _CommunicationDisabledUtils.isMemberCommunicationDisabled(stateFromStores);
r51.push(<ActionSheetRow label={isMemberCommunicationDisabled ? intl.string(t.qXtNtS) : intl.string(t.xpsADY)} icon={<ActionSheetRow.Icon IconComponent={ClockWarningIcon} />} onPress={() => {
hideActionSheet();
if (isMemberCommunicationDisabled) {
openEnableCommunication({
guildId: stateFromStores.guildId,
userId: stateFromStores.userId
});
} else {
openDisableCommunication({
guildId: stateFromStores.guildId,
userId: stateFromStores.userId
});
}
}} />);
}
if (stateFromStores != null && canKickUser) {
r51.push(<ActionSheetRow label={intl.string(t["3glT6Z"])} icon={<ActionSheetRow.Icon IconComponent={UserMinusIcon} />} variant="danger" onPress={() => {
showKickConfirmModal({
guildId: guild.id,
userId: user.id,
cancelButtonCallback: () => showModerateUserActionSheet({
guild,
user
})
});
}} />);
}
if (stateFromStores != null && canBanUser) {
r51.push(<ActionSheetRow label={intl.string(t["5MBJ5M"])} icon={<ActionSheetRow.Icon IconComponent={HammerIcon} />} variant="danger" onPress={() => {
showBanConfirmModal({
guildId: guild.id,
userId: user.id,
cancelButtonCallback: () => showModerateUserActionSheet({
guild,
user
})
});
}} />);
}
return <BottomSheet header={<BottomSheetTitleHeader title={intl.formatToPlainString(t["792QKT"], {
nick: name
})} />} bodyStyles={styles.container}>
<MemberRolesList style={[styles.memberRoles]} guild={guild} userRoles={userRoles} />
<TableRowGroup hasIcons>
{r51.map((item, index) => <Fragment key={`action_${index}`}>
{item}
</Fragment>)}
</TableRowGroup>
</BottomSheet>;
}
return null;
});
export default r39;
@@ -0,0 +1,5 @@
// Metro module 11023 (f11024).
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
export default function showModerateUserActionSheet(a0) {
ActionSheetActionCreators.openLazy(import("./ModerateUserActionSheet"), "ModerateUserActionSheet", a0);
};