Files
discord-decomp/sources/modules/guild_automod/GuildAutomodActionCreators.tsx
T
2026-07-27 16:20:00 +03:00

288 lines
14 KiB
TypeScript

/* Metro module 11459; source: modules/guild_automod/GuildAutomodActionCreators.tsx; dependencies: [5, 1867, 3784, 661, 11460, 1360, 21, 507, 11453, 4863, 5061, 694, 2] */
function _fun87719(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#87719, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:6, offset: 0x01fc91dc, size: 405 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(5) /* metro dependency 5 */;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
const permissionStore = importDefault(3784) /* metro dependency 3784: PermissionStore */;
const constantsModule = require(661) /* metro dependency 661: Constants */;
const env0_6 = constantsModule.AnalyticEvents;
const env0_7 = constantsModule.Endpoints;
const env0_8 = constantsModule.Permissions;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/guild_automod/GuildAutomodActionCreators.tsx');
exports.validateAutomodRule = function() {
return _validateAutomodRule.apply(this, arguments);
};
exports.createAutomodRule = function() {
return _createAutomodRule.apply(this, arguments);
};
exports.updateAutomodRule = function() {
return _updateAutomodRule.apply(this, arguments);
};
exports.deleteAutomodRule = function() {
return _deleteAutomodRule.apply(this, arguments);
};
exports.fetchAutomodRules = function() {
return _fetchAutomodRules.apply(this, arguments);
};
exports.executeAlertAction = function() {
return _executeAlertAction.apply(this, arguments);
};
exports.removeMentionRaidRestrictionWithFeedback = removeMentionRaidRestrictionWithFeedback;
exports.clearMentionRaidDetected = clearMentionRaidDetected;
}
function _transformClientActionToApiAction({type, metadata}) { // fn#87720, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:185, offset: 0x01fc9371, size: 63 bytes, params: 2, frame: 13
const object2 = {};
object2.type = type;
object2.metadata = (require(11460) /* metro dependency 11460: DataUtils */)._transformMetadataToSnakeCase(metadata);
return object2;
}
function _transformClientRuleToApiRule({triggerMetadata, id, name, guildId, eventType, triggerType, actions, enabled, creatorId, position, exemptChannels, exemptRoles}) { // fn#87721, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:310, offset: 0x01fc93b0, size: 276 bytes, params: 2, frame: 18
const value2 = (require(11460) /* metro dependency 11460: DataUtils */)._transformMetadataToSnakeCase(triggerMetadata);
if (value2 != null) {
delete value2.keywordLists;
}
const object2 = {};
object2.id = id;
object2.name = name;
object2.guild_id = guildId;
object2.event_type = eventType;
object2.trigger_type = triggerType;
object2.trigger_metadata = value2;
const value3 = actions.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish);
object2.actions = value3.map(_transformClientActionToApiAction);
object2.enabled = enabled;
object2.creator_id = creatorId;
object2.position = position;
let Array = global.Array;
object2.exempt_channels = Array.from(exemptChannels ?? []);
Array = global.Array;
object2.exempt_roles = Array.from(exemptRoles ?? []);
return object2;
}
function _transformApiActionToClientAction({type, metadata}) { // fn#87722, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:828, offset: 0x01fc94c4, size: 63 bytes, params: 2, frame: 13
const object2 = {};
object2.type = type;
object2.metadata = (require(11460) /* metro dependency 11460: DataUtils */)._transformMetadataToCamelCase(metadata);
return object2;
}
function _transformApiRuletoClientRule({id, name, guild_id, event_type, trigger_type, trigger_metadata, actions, enabled, creator_id, position, exempt_channels, exempt_roles}) { // fn#87723, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:953, offset: 0x01fc9503, size: 363 bytes, params: 2, frame: 18
var r3;
var value;
var fromTimestamp;
var Date;
const object2 = {};
if (id != null) {
r3 = id;
} else {
value = importDefault(21) /* metro dependency 21: SnowflakeUtils */;
fromTimestamp = value.fromTimestamp;
Date = global.Date;
value = Reflect.apply(fromTimestamp, value, [Date.now()]);
r3 = value;
}
object2.id = r3;
object2.name = name;
object2.guildId = guild_id;
object2.eventType = event_type;
object2.triggerType = trigger_type;
object2.triggerMetadata = (require(11460) /* metro dependency 11460: DataUtils */)._transformMetadataToCamelCase(trigger_metadata);
const value2 = actions.filter((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish);
object2.actions = value2.map(_transformApiActionToClientAction);
object2.enabled = enabled;
object2.creatorId = creator_id;
object2.position = position;
let Set = global.Set;
object2.exemptChannels = new Set(exempt_channels ?? []);
Set = global.Set;
object2.exemptRoles = new Set(exempt_roles ?? []);
if (object2.triggerMetadata != null) {
delete object2.triggerMetadata.keywordLists;
}
return object2;
}
function _validateAutomodRule() { // fn#87724, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:1545, offset: 0x01fc966e, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87726).apply(this, arguments);
}
function _createAutomodRule() { // fn#87727, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:1839, offset: 0x01fc9745, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87729).apply(this, arguments);
}
function _updateAutomodRule() { // fn#87730, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2123, offset: 0x01fc9808, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87732).apply(this, arguments);
}
function _deleteAutomodRule() { // fn#87733, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2400, offset: 0x01fc98cf, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87735).apply(this, arguments);
}
function _fetchAutomodRules() { // fn#87736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2585, offset: 0x01fc9973, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87738).apply(this, arguments);
}
function _executeAlertAction() { // fn#87739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2837, offset: 0x01fc9a46, size: 50 bytes, params: 1, frame: 14
return env0_3(_fun87741).apply(this, arguments);
}
function removeMentionRaidRestrictionWithFeedback(a0, a1, a2) { // fn#87748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:3845, offset: 0x01fc9b2c, size: 123 bytes, params: 4, frame: 16
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
const guild = GuildStore.getGuild(a0);
if (guild != null && PermissionStore.can(Permissions.MANAGE_GUILD, guild)) {
(require(11453) /* metro dependency 11453: GuildAutomodActionActionCreatorsNative */).openConfirmRemoveMentionRaid(_fun87749);
}
}
function clearMentionRaidDetected(a0) { // fn#87750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:4248, offset: 0x01fc9c46, size: 56 bytes, params: 2, frame: 13
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({type: 'AUTO_MODERATION_MENTION_RAID_NOTICE_DISMISS',
guildId: a0});
}
function* _fun87726(a0) { // fn#87726, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:1608, offset: 0x01fc96ab, size: 154 bytes, params: 2, frame: 18
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const value3 = env2_10(a0);
let binding = env2_0;
const HTTP = binding(env2_2[7]).HTTP;
const post = HTTP.post;
binding = env2_7;
const GUILD_AUTOMOD_VALIDATE_RULE = binding.GUILD_AUTOMOD_VALIDATE_RULE;
yield Reflect.apply(post, HTTP, [{url: Reflect.apply(GUILD_AUTOMOD_VALIDATE_RULE, binding, [a0.guildId]),
body: value3, rejectWithError: false}]);
const value4 = undefined;
if (false) {
return value4;
}
value = env2_0(env2_2[4]);
return value._transformMetadataToCamelCase(value4.body);
}
function* _fun87729(a0) { // fn#87729, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:1898, offset: 0x01fc9782, size: 134 bytes, params: 2, frame: 18
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const value3 = env2_10(a0);
delete value3.id;
const binding = env2_12;
const HTTP = env2_0(env2_2[7]).HTTP;
const post = HTTP.post;
const binding3 = env2_7;
const GUILD_AUTOMOD_RULES = binding3.GUILD_AUTOMOD_RULES;
yield Reflect.apply(post, HTTP, [{url: Reflect.apply(GUILD_AUTOMOD_RULES, binding3, [a0.guildId]), body: value3,
rejectWithError: false}]);
value = undefined;
if (false) {
return value;
}
return binding(value.body);
}
function* _fun87732(a0) { // fn#87732, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2182, offset: 0x01fc9845, size: 138 bytes, params: 2, frame: 20
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const value3 = env2_10(a0);
const binding = env2_12;
const HTTP = env2_0(env2_2[7]).HTTP;
const patch = HTTP.patch;
const binding3 = env2_7;
const GUILD_AUTOMOD_RULE = binding3.GUILD_AUTOMOD_RULE;
yield Reflect.apply(patch, HTTP, [{url: Reflect.apply(GUILD_AUTOMOD_RULE, binding3, [a0.guildId, a0.id]),
body: value3, rejectWithError: false}]);
value = undefined;
if (false) {
return value;
}
return binding(value.body);
}
function* _fun87735(a0, a1) { // fn#87735, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2459, offset: 0x01fc990c, size: 103 bytes, params: 3, frame: 17
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const HTTP = env2_0(env2_2[7]).HTTP;
const del = HTTP.del;
const object2 = {};
object2.url = env2_7.GUILD_AUTOMOD_RULE(a1, a0);
object2.rejectWithError = false;
yield Reflect.apply(del, HTTP, [object2]);
if (false) {
return undefined;
}
return true;
}
function* _fun87738(a0) { // fn#87738, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2644, offset: 0x01fc99b0, size: 150 bytes, params: 2, frame: 16
if (false) {
return undefined;
}
value = environment.__proto__.__proto__;
const HTTP = env2_0(env2_2[7]).HTTP;
const get = HTTP.get;
const object2 = {};
object2.url = env2_7.GUILD_AUTOMOD_RULES(a0);
object2.rejectWithError = false;
yield Reflect.apply(get, HTTP, [object2]);
const value3 = undefined;
if (false) {
return value3;
}
const Array = global.Array;
return Array.isArray(value3.body) ? value3.body.map(env2_12) : [];
}
function* _fun87741(a0, a1, a2) { // fn#87741, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:2898, offset: 0x01fc9a83, size: 169 bytes, params: 4, frame: 17
var HTTP;
var post;
if (true) {
value = environment.__proto__.__proto__;
var binding = env2_5;
var can = binding.can;
var MANAGE_MESSAGES = env2_8.MANAGE_MESSAGES;
if (Reflect.apply(can, binding, [MANAGE_MESSAGES, a1])) {
binding = env2_0;
HTTP = binding(env2_2[7]).HTTP;
post = HTTP.post;
binding = env2_7;
yield Reflect.apply(post, HTTP, [{url: binding.GUILD_AUTOMOD_ALERT_ACTION(a1.guild_id),
body: {message_id: a0,
channel_id: a1.id, alert_action_type: a2}, rejectWithError: false}]);
if (false) {
return undefined;
}
}
}
}
function _fun87749() { // fn#87749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11645:3994, offset: 0x01fc9ba7, size: 159 bytes, params: 1, frame: 19
var object2;
const appAnalyticsUtilsModule = require(4863) /* metro dependency 4863: AppAnalyticsUtils */;
const trackWithMetadata = appAnalyticsUtilsModule.trackWithMetadata;
const GUILD_AUTOMOD_FEEDBACK = AnalyticEvents.GUILD_AUTOMOD_FEEDBACK;
const Feedback = (require(5061) /* metro dependency 5061: AutomodFeedback */).Feedback;
const MENTION_RAID_REMOVE_RESTRICTION = Feedback.MENTION_RAID_REMOVE_RESTRICTION;
Reflect.apply(trackWithMetadata, appAnalyticsUtilsModule, [GUILD_AUTOMOD_FEEDBACK,
{feedback_type: MENTION_RAID_REMOVE_RESTRICTION, decision_id: require}]);
const HTTP = (require(507) /* metro dependency 507: HTTPUtils */).HTTP;
const post = HTTP.post;
object2 = {};
object2.url = Endpoints.GUILD_AUTOMOD_CLEAR_MENTION_RAID(env0_0);
object2.rejectWithError = true;
Reflect.apply(post, HTTP, [object2]);
importDefault();
}