105 lines
3.7 KiB
TypeScript
105 lines
3.7 KiB
TypeScript
// Metro module 10244 (f10245).
|
|
import ExperimentStore from "../experiments/ExperimentStore";
|
|
import UserSettingsProtoStore from "../user_settings/UserSettingsProtoStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import { hasDetectedActivity, isUnderLockdown } from "./GuildAntiRaidUtils";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c6833_6, c6833_7, incidentsDataFromServer;
|
|
const computeAlertSettings = function computeAlertSettings() {
|
|
let r3 = UserSettingsProtoStore.getGuildsProto();
|
|
if (r3 == null) {
|
|
r3 = {};
|
|
}
|
|
const guildsArray = GuildStore.getGuildsArray();
|
|
c6833_7 = {};
|
|
for (const item of guildsArray) {
|
|
c6833_7[item.id] = {
|
|
guildId: item.id,
|
|
guildName: item.name,
|
|
...r3[item.id]
|
|
};
|
|
}
|
|
};
|
|
incidentsDataFromServer = function incidentsDataFromServer(a0) {
|
|
return a0 != null ? Object.keys(a0).length > 0 ? {
|
|
raidDetectedAt: a0.raid_detected_at,
|
|
dmSpamDetectedAt: a0.dm_spam_detected_at,
|
|
dmsDisabledUntil: a0.dms_disabled_until,
|
|
invitesDisabledUntil: a0.invites_disabled_until,
|
|
lockdownDurationHours: a0.lockdown_duration_hours
|
|
} : null : null;
|
|
};
|
|
c6833_6 = {};
|
|
c6833_7 = {};
|
|
class GuildIncidentsStore extends Module589.Store {
|
|
static displayName = "GuildIncidentsStore";
|
|
initialize() {
|
|
this.waitFor(UserSettingsProtoStore, GuildStore, PermissionStore, ExperimentStore);
|
|
this.syncWith([UserSettingsProtoStore, GuildStore, PermissionStore, ExperimentStore], computeAlertSettings);
|
|
}
|
|
getGuildIncident(a0) {
|
|
return c6833_6[a0];
|
|
}
|
|
getIncidentsByGuild() {
|
|
return c6833_6;
|
|
}
|
|
getGuildAlertSettings() {
|
|
return c6833_7;
|
|
}
|
|
}
|
|
const guildIncidentsStore = new GuildIncidentsStore(Dispatcher, {
|
|
CONNECTION_OPEN: function handleConnectionOpen(a0) {
|
|
c6833_6 = {};
|
|
for (const guild of a0.guilds) {
|
|
const r33 = incidentsDataFromServer(guild.properties?.incidents_data);
|
|
if (r33 != null && (hasDetectedActivity(r33) || isUnderLockdown(r33))) {
|
|
c6833_6[guild.id] = r33;
|
|
}
|
|
}
|
|
},
|
|
GUILD_CREATE: function handleGuildCreate({ guild }) {
|
|
const incidents_data = guild.properties?.incidents_data;
|
|
const r6 = incidents_data != null ? Object.keys(incidents_data).length > 0 ? {
|
|
raidDetectedAt: incidents_data.raid_detected_at,
|
|
dmSpamDetectedAt: incidents_data.dm_spam_detected_at,
|
|
dmsDisabledUntil: incidents_data.dms_disabled_until,
|
|
invitesDisabledUntil: incidents_data.invites_disabled_until,
|
|
lockdownDurationHours: incidents_data.lockdown_duration_hours
|
|
} : null : null;
|
|
if (r6 != null && (hasDetectedActivity(r6) || isUnderLockdown(r6))) {
|
|
c6833_6[guild.id] = r6;
|
|
}
|
|
},
|
|
GUILD_UPDATE: function handleGuildUpdate({ guild }) {
|
|
const incidents_data = guild.incidents_data;
|
|
const r5 = incidents_data != null ? Object.keys(incidents_data).length > 0 ? {
|
|
raidDetectedAt: incidents_data.raid_detected_at,
|
|
dmSpamDetectedAt: incidents_data.dm_spam_detected_at,
|
|
dmsDisabledUntil: incidents_data.dms_disabled_until,
|
|
invitesDisabledUntil: incidents_data.invites_disabled_until,
|
|
lockdownDurationHours: incidents_data.lockdown_duration_hours
|
|
} : null : null;
|
|
L8: {
|
|
L6: {
|
|
if (r5 != null) {
|
|
if (!hasDetectedActivity(r5) && !isUnderLockdown(r5)) {
|
|
break L6;
|
|
}
|
|
c6833_6[guild.id] = r5;
|
|
break L8;
|
|
}
|
|
}
|
|
delete c6833_6[guild.id];
|
|
}
|
|
},
|
|
GUILD_DELETE: function handleGuildDelete(a0) {
|
|
delete c6833_6[a0.guild.id];
|
|
},
|
|
LOGOUT: function handleLogout() {
|
|
c6833_6 = {};
|
|
}
|
|
});
|
|
export default guildIncidentsStore;
|