186 lines
5.3 KiB
TypeScript
186 lines
5.3 KiB
TypeScript
// Metro module 16380 (f16381).
|
|
import GuildSettingsAuditLogStore from "../modules/guild_settings/audit_log/GuildSettingsAuditLogStore";
|
|
import { AUDIT_LOG_PAGE_LIMIT, Endpoints } from "../Constants";
|
|
import { HTTP } from "../_bundle/sendRequest";
|
|
import Dispatcher from "../Dispatcher";
|
|
let $mk99459 = function() {
|
|
return ({ body }) => {
|
|
const { audit_log_entries, integrations, users, webhooks } = body;
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_SUCCESS",
|
|
logs: audit_log_entries,
|
|
integrations,
|
|
users,
|
|
webhooks,
|
|
guildScheduledEvents: body.guild_scheduled_events,
|
|
automodRules: body.auto_moderation_rules,
|
|
threads: body.threads,
|
|
applicationCommands: body.application_commands
|
|
});
|
|
};
|
|
}, $mk99460 = function() {
|
|
return () => Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_FAIL"
|
|
});
|
|
};
|
|
const makeRequest = function makeRequest(a0, a1) {
|
|
const before = a1.before;
|
|
let userId = a1.userId;
|
|
let targetId = a1.targetId;
|
|
let action = a1.action;
|
|
if (userId == null) {
|
|
userId = GuildSettingsAuditLogStore.userIdFilter;
|
|
}
|
|
if (action == null) {
|
|
action = GuildSettingsAuditLogStore.actionFilter;
|
|
}
|
|
if (targetId == null) {
|
|
targetId = GuildSettingsAuditLogStore.targetIdFilter;
|
|
}
|
|
const query = {
|
|
limit: AUDIT_LOG_PAGE_LIMIT
|
|
};
|
|
if (before != null) {
|
|
query.before = before;
|
|
}
|
|
if (userId != null) {
|
|
query.user_id = userId;
|
|
}
|
|
if (action != null) {
|
|
query.action_type = action;
|
|
}
|
|
if (targetId != null) {
|
|
query.target_id = targetId;
|
|
}
|
|
return HTTP.get({
|
|
url: Endpoints.GUILD_AUDIT_LOG(a0),
|
|
query,
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
});
|
|
};
|
|
export function fetchLogs(a0, a1, a2, a3) {
|
|
if (!(GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage) && a0 != null) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_START"
|
|
});
|
|
const r19 = makeRequest(a0, {
|
|
userId: a1,
|
|
action: a3,
|
|
targetId: a2
|
|
});
|
|
const r21 = $mk99460();
|
|
return r19.then($mk99459(), r21);
|
|
}
|
|
}
|
|
export function fetchNextLogPage(a0, isGroupedFetch = false) {
|
|
if (GuildSettingsAuditLogStore.hasOlderLogs && !(GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage) && a0 != null) {
|
|
const r14 = GuildSettingsAuditLogStore.logs[GuildSettingsAuditLogStore.logs.length - 1];
|
|
const before = r14 != null ? r14.id : null;
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_NEXT_PAGE_START",
|
|
before,
|
|
isGroupedFetch
|
|
});
|
|
return makeRequest(a0, {
|
|
before
|
|
}).then(({ body }) => {
|
|
const { audit_log_entries, integrations, users, webhooks } = body;
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_NEXT_PAGE_SUCCESS",
|
|
logs: audit_log_entries,
|
|
integrations,
|
|
users,
|
|
webhooks,
|
|
guildScheduledEvents: body.guild_scheduled_events,
|
|
automodRules: body.auto_moderation_rules,
|
|
threads: body.threads,
|
|
applicationCommands: body.application_commands
|
|
});
|
|
}, () => Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_NEXT_PAGE_FAIL"
|
|
}));
|
|
}
|
|
}
|
|
export function filterByAction(a0, a1) {
|
|
if (!(GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage) && a1 != null) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FILTER_BY_ACTION",
|
|
action: a0
|
|
});
|
|
const r15 = GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage;
|
|
let r16 = void 0;
|
|
if (!r15) {
|
|
const r17 = a1 != null;
|
|
r16 = void 0;
|
|
if (r17) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_START"
|
|
});
|
|
const r25 = makeRequest(a1, {
|
|
userId: null,
|
|
action: a0,
|
|
targetId: null
|
|
});
|
|
const r27 = $mk99460();
|
|
r16 = r25.then($mk99459(), r27);
|
|
}
|
|
}
|
|
return r16;
|
|
}
|
|
}
|
|
export function filterByUserId(a0, a1) {
|
|
if (!(GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage) && a1 != null) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FILTER_BY_USER",
|
|
userId: a0
|
|
});
|
|
const r15 = GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage;
|
|
let r16 = void 0;
|
|
if (!r15) {
|
|
const r17 = a1 != null;
|
|
r16 = void 0;
|
|
if (r17) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_START"
|
|
});
|
|
const r25 = makeRequest(a1, {
|
|
userId: a0,
|
|
action: void 0,
|
|
targetId: void 0
|
|
});
|
|
const r27 = $mk99460();
|
|
r16 = r25.then($mk99459(), r27);
|
|
}
|
|
}
|
|
return r16;
|
|
}
|
|
}
|
|
export function filterByTargetId(a0, a1) {
|
|
if (!(GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage) && a1 != null) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FILTER_BY_TARGET",
|
|
targetId: a0
|
|
});
|
|
const r15 = GuildSettingsAuditLogStore.isLoading || GuildSettingsAuditLogStore.isLoadingNextPage;
|
|
let r16 = void 0;
|
|
if (!r15) {
|
|
const r17 = a1 != null;
|
|
r16 = void 0;
|
|
if (r17) {
|
|
Dispatcher.dispatch({
|
|
type: "AUDIT_LOG_FETCH_START"
|
|
});
|
|
const r25 = makeRequest(a1, {
|
|
userId: null,
|
|
action: void 0,
|
|
targetId: a0
|
|
});
|
|
const r27 = $mk99460();
|
|
r16 = r25.then($mk99459(), r27);
|
|
}
|
|
}
|
|
return r16;
|
|
}
|
|
}
|