Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4791.js (118.4 MB)
274 lines
9.8 KiB
TypeScript
274 lines
9.8 KiB
TypeScript
// Module ID: 10187
|
|
// Function ID: 10188
|
|
// Name: GuildAntiRaidHooks
|
|
// Dependencies: [1221, 1979, 4245, 4428, 1371, 10170, 8090, 1074, 563, 11, 8089, 1086, 4250, 10188, 2]
|
|
// Exports: getDisabledActions, shouldShowRaidInAppNotification, shouldShowRaidNotificationNagbar, useDisabledActions, useFirstGuildIncidentId, useGuildIncidentsState, useShowAntiRaidInGuildNotifSettings
|
|
|
|
// Module 10187 (GuildAntiRaidHooks)
|
|
import SnowflakeUtilsDefault from "SnowflakeUtils" /* 11 */;
|
|
import BigFlagUtilsAll from "BigFlagUtils" /* 1086 */;
|
|
import PermissionUtilsAll from "PermissionUtils" /* 4250 */;
|
|
import GuildAntiRaidUtils from "GuildAntiRaidUtils" /* 8089 */;
|
|
import GuildAntiRaidPermissionsUtils from "GuildAntiRaidPermissionsUtils" /* 10188 */;
|
|
import UserSettingsProtoStore from "UserSettingsProtoStore" /* 1221 */;
|
|
import GuildStore from "GuildStore" /* 1979 */;
|
|
import PermissionStore from "PermissionStore" /* 4245 */;
|
|
import SelectedGuildStore from "SelectedGuildStore" /* 4428 */;
|
|
import UserStore from "UserStore" /* 1371 */;
|
|
import GuildIncidentsStore from "GuildIncidentsStore" /* 10170 */;
|
|
|
|
const require = globalThis.__r;
|
|
|
|
require = fn;
|
|
function getFirstGuildIncidentId(guildId) {
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const incidentsByGuild = GuildIncidentsStore.getIncidentsByGuild();
|
|
const keys = SnowflakeUtilsDefault.keys(incidentsByGuild);
|
|
const mapped = keys.map((item) => guild.getGuild(item));
|
|
const iter = mapped[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp5 = nextResult;
|
|
if (null != nextResult) {
|
|
let tmp17 = incidentsByGuild[tmp5.id];
|
|
let tmp18 = tmp17;
|
|
if (null != tmp17) {
|
|
let tmp19 = require;
|
|
let obj7 = GuildAntiRaidUtils;
|
|
if (obj7.hasDetectedActivity(tmp18)) {
|
|
let tmp19Result = tmp19(8089);
|
|
if (!tmp19Result.isUnderLockdown(tmp18)) {
|
|
let obj4 = BigFlagUtilsAll;
|
|
let obj5 = PermissionUtilsAll;
|
|
let obj2 = { user: currentUser, context: null, checkElevated: false };
|
|
obj2.context = tmp5;
|
|
if (obj4.hasAny(obj5.computePermissions(obj2), closure_10)) {
|
|
iter.return();
|
|
return nextResult.id;
|
|
}
|
|
}
|
|
} else {
|
|
let tmp19Result2 = tmp19(8089);
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
}
|
|
let closure_10 = fn(8090).IncidentAlertModeratorPermissions;
|
|
const Constants = fn(1074);
|
|
({ EMPTY_STRING_SNOWFLAKE_ID: closure_11, GuildFeatures: closure_12 } = Constants);
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/guild_antiraid/GuildAntiRaidHooks.tsx");
|
|
|
|
export const useFirstGuildIncidentId = function useFirstGuildIncidentId() {
|
|
const items = [UserStore];
|
|
const stateFromStores = stateFromStores1(563).useStateFromStores(items, () => currentUser.getCurrentUser());
|
|
const obj = stateFromStores1(563);
|
|
const items1 = [GuildIncidentsStore];
|
|
stateFromStores1 = stateFromStores1(563).useStateFromStores(items1, () => incidentsByGuild.getIncidentsByGuild());
|
|
const obj2 = stateFromStores1(563);
|
|
const items2 = [GuildStore];
|
|
const stateFromStoresArray = stateFromStores1(563).useStateFromStoresArray(items2, () => {
|
|
const keys = SnowflakeUtilsDefault.keys(stateFromStores1);
|
|
return keys.map((item) => guild.getGuild(item));
|
|
});
|
|
const iter = stateFromStoresArray[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp5 = nextResult;
|
|
if (null != nextResult) {
|
|
let tmp15 = stateFromStores1[tmp5.id];
|
|
let tmp16 = tmp15;
|
|
if (null != tmp15) {
|
|
let tmp18 = stateFromStores1;
|
|
let obj8 = stateFromStores1(8089);
|
|
if (obj8.hasDetectedActivity(tmp16)) {
|
|
let obj5 = BigFlagUtilsAll;
|
|
let obj6 = PermissionUtilsAll;
|
|
let obj4 = { user: stateFromStores, context: null, checkElevated: false };
|
|
obj4.context = tmp5;
|
|
if (obj5.hasAny(obj6.computePermissions(obj4), closure_10)) {
|
|
iter.return();
|
|
return nextResult.id;
|
|
}
|
|
} else {
|
|
let tmp18Result = tmp18(8089);
|
|
}
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
return null;
|
|
};
|
|
export const useGuildIncidentsState = function useGuildIncidentsState(id) {
|
|
_require = id;
|
|
const items = [GuildStore, PermissionStore];
|
|
const stateFromStores = require("useStateFromStores").useStateFromStores(items, () => {
|
|
const guild = GuildStore.getGuild(closure_0);
|
|
if (null == guild) {
|
|
return false;
|
|
} else {
|
|
const guildPermissions = PermissionStore.getGuildPermissions(guild);
|
|
let hasAnyResult = null != guildPermissions;
|
|
if (hasAnyResult) {
|
|
hasAnyResult = BigFlagUtilsAll.hasAny(guildPermissions, closure_10);
|
|
}
|
|
return hasAnyResult;
|
|
}
|
|
});
|
|
let obj = require("useStateFromStores");
|
|
const tmp = _require;
|
|
const items1 = [GuildIncidentsStore];
|
|
const stateFromStores1 = require("useStateFromStores").useStateFromStores(items1, () => {
|
|
let guildIncident = null;
|
|
if (null != closure_0) {
|
|
guildIncident = GuildIncidentsStore.getGuildIncident(tmp);
|
|
}
|
|
return guildIncident;
|
|
});
|
|
const obj3 = { shouldShowIncidentActions: stateFromStores, incidentData: stateFromStores1, isUnderLockdown: null };
|
|
let isUnderLockdownResult = null != stateFromStores1;
|
|
if (isUnderLockdownResult) {
|
|
isUnderLockdownResult = tmp(8089).isUnderLockdown(stateFromStores1);
|
|
const tmpResult = tmp(8089);
|
|
}
|
|
obj3.isUnderLockdown = isUnderLockdownResult;
|
|
return obj3;
|
|
};
|
|
export const shouldShowRaidNotificationNagbar = function shouldShowRaidNotificationNagbar() {
|
|
const guildId = getFirstGuildIncidentId(SelectedGuildStore.getGuildId());
|
|
let guildsProto = UserSettingsProtoStore.getGuildsProto();
|
|
if (guildsProto == null) {
|
|
guildsProto = {};
|
|
}
|
|
let tmp2 = null;
|
|
if (null != guildId) {
|
|
tmp2 = guildsProto[guildId];
|
|
}
|
|
const show = null != guildId && !(null != tmp2 && tmp2.disableRaidAlertNag);
|
|
return { show, guildId };
|
|
};
|
|
export const shouldShowRaidInAppNotification = function shouldShowRaidInAppNotification() {
|
|
const guildId = getFirstGuildIncidentId(SelectedGuildStore.getGuildId());
|
|
let guildsProto = UserSettingsProtoStore.getGuildsProto();
|
|
if (guildsProto == null) {
|
|
guildsProto = {};
|
|
}
|
|
let tmp2 = null;
|
|
if (null != guildId) {
|
|
tmp2 = guildsProto[guildId];
|
|
}
|
|
let guildIncident = null;
|
|
if (null != guildId) {
|
|
guildIncident = GuildIncidentsStore.getGuildIncident(guildId);
|
|
}
|
|
let isUnderLockdownResult = null != guildIncident;
|
|
if (isUnderLockdownResult) {
|
|
isUnderLockdownResult = GuildAntiRaidUtils.isUnderLockdown(guildIncident);
|
|
}
|
|
const show = null != guildId && !isUnderLockdownResult && !(null != tmp2 && tmp2.disableRaidAlertNag);
|
|
return { show, guildId };
|
|
};
|
|
export const getDisabledActions = function getDisabledActions(id) {
|
|
if (null == id) {
|
|
return { dmsDisabled: false, invitesDisabled: false };
|
|
} else {
|
|
const guildIncident = GuildIncidentsStore.getGuildIncident(id.id);
|
|
let hasItem;
|
|
if (id != null) {
|
|
const features = id.features;
|
|
hasItem = features.has(constants.INVITES_DISABLED);
|
|
}
|
|
if (!hasItem) {
|
|
let invitesDisabledUntil;
|
|
if (guildIncident != null) {
|
|
invitesDisabledUntil = guildIncident.invitesDisabledUntil;
|
|
}
|
|
let tmp4 = null != invitesDisabledUntil;
|
|
if (tmp4) {
|
|
const _Date = Date;
|
|
const date = new Date(guildIncident.invitesDisabledUntil);
|
|
const _Date2 = Date;
|
|
const date1 = new Date();
|
|
tmp4 = date > date1;
|
|
}
|
|
hasItem = tmp4;
|
|
}
|
|
const obj = { invitesDisabled: hasItem, dmsDisabled: null };
|
|
let dmsDisabledUntil;
|
|
if (guildIncident != null) {
|
|
dmsDisabledUntil = guildIncident.dmsDisabledUntil;
|
|
}
|
|
let tmp15 = null != dmsDisabledUntil;
|
|
if (tmp15) {
|
|
const _Date3 = Date;
|
|
const date2 = new Date(guildIncident.dmsDisabledUntil);
|
|
const _Date4 = Date;
|
|
const date3 = new Date();
|
|
tmp15 = date2 > date3;
|
|
}
|
|
obj.dmsDisabled = tmp15;
|
|
return obj;
|
|
}
|
|
};
|
|
export const useDisabledActions = function useDisabledActions(id) {
|
|
id = undefined;
|
|
if (id != null) {
|
|
id = id.id;
|
|
}
|
|
if (id == null) {
|
|
id = closure_11;
|
|
}
|
|
const items = [GuildIncidentsStore];
|
|
const items1 = [id];
|
|
const stateFromStores = id(563).useStateFromStores(items, () => GuildIncidentsStore.getGuildIncident(id), items1);
|
|
if (null == id) {
|
|
let obj2 = { dmsDisabled: false, invitesDisabled: false };
|
|
} else {
|
|
let hasItem;
|
|
if (id != null) {
|
|
const features = id.features;
|
|
hasItem = features.has(constants.INVITES_DISABLED);
|
|
}
|
|
if (!hasItem) {
|
|
let invitesDisabledUntil;
|
|
if (stateFromStores != null) {
|
|
invitesDisabledUntil = stateFromStores.invitesDisabledUntil;
|
|
}
|
|
let tmp6 = null != invitesDisabledUntil;
|
|
if (tmp6) {
|
|
const _Date = Date;
|
|
const date = new Date(stateFromStores.invitesDisabledUntil);
|
|
const _Date2 = Date;
|
|
const date1 = new Date();
|
|
tmp6 = date > date1;
|
|
}
|
|
hasItem = tmp6;
|
|
}
|
|
obj2 = { invitesDisabled: hasItem, dmsDisabled: null };
|
|
let dmsDisabledUntil;
|
|
if (stateFromStores != null) {
|
|
dmsDisabledUntil = stateFromStores.dmsDisabledUntil;
|
|
}
|
|
let tmp17 = null != dmsDisabledUntil;
|
|
if (tmp17) {
|
|
const _Date3 = Date;
|
|
const date2 = new Date(stateFromStores.dmsDisabledUntil);
|
|
const _Date4 = Date;
|
|
const date3 = new Date();
|
|
tmp17 = date2 > date3;
|
|
}
|
|
obj2.dmsDisabled = tmp17;
|
|
}
|
|
return obj2;
|
|
};
|
|
export const useShowAntiRaidInGuildNotifSettings = function useShowAntiRaidInGuildNotifSettings(arg0) {
|
|
_require = arg0;
|
|
const items = [PermissionStore, GuildStore];
|
|
return require("useStateFromStores").useStateFromStores(items, () => {
|
|
const guild = GuildStore.getGuild(closure_0);
|
|
return GuildAntiRaidPermissionsUtils.canReportRaid(guild, PermissionStore);
|
|
});
|
|
};
|