80 lines
2.6 KiB
TypeScript
80 lines
2.6 KiB
TypeScript
// Metro module 10022 (f10023).
|
|
import { Endpoints } from "../../Constants";
|
|
import { HTTP } from "../../_bundle/sendRequest";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import { requestMembersForRole } from "../guild_settings/GuildRoleMemberActionCreators";
|
|
export function fetchRoleConnectionsConfiguration(a0, a1) {
|
|
const roleId = a1;
|
|
HTTP.get({
|
|
url: Endpoints.GUILD_ROLE_CONNECTIONS_CONFIGURATION(a0, a1),
|
|
rejectWithError: true
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_ROLE_CONNECTIONS_CONFIGURATIONS_FETCH_SUCCESS",
|
|
roleId,
|
|
roleConnectionConfigurations: result.body.length > 0 ? result.body.map((a0) => a0.map((item) => ({
|
|
connectionType: item.connection_type,
|
|
connectionMetadataField: item.connection_metadata_field,
|
|
applicationId: item.application_id,
|
|
operator: item.operator,
|
|
value: item.value
|
|
}))) : []
|
|
});
|
|
}).catch(() => {});
|
|
}
|
|
export async function putRoleConnectionsConfigurations(c26601_0, c26601_1, c26601_2) {
|
|
let c26601_4;
|
|
let env30179;
|
|
c26601_4 = void 0;
|
|
const r10 = env30179 = {};
|
|
let c26601_3 = r10;
|
|
env30179[0] = c26601_0;
|
|
env30179[1] = c26601_1;
|
|
env30179[2] = void 0;
|
|
env30179[3] = void 0;
|
|
let body = c26601_2.map((a0) => a0.map((item) => ({
|
|
connection_type: item.connectionType,
|
|
connection_metadata_field: item.connectionMetadataField,
|
|
application_id: item.applicationId,
|
|
operator: item.operator,
|
|
value: item.value
|
|
})));
|
|
const r41 = {
|
|
url: Endpoints.GUILD_ROLE_CONNECTIONS_CONFIGURATION(c26601_0, c26601_1),
|
|
body: null,
|
|
oldFormErrors: true,
|
|
rejectWithError: false
|
|
};
|
|
if (body.length === 0) {
|
|
body = [];
|
|
}
|
|
r41.body = body;
|
|
env30179[2] = await HTTP.put(r41).then((result) => result.body.length > 0 ? result.body.map((item) => item.map((item) => ({
|
|
connectionType: item.connection_type,
|
|
connectionMetadataField: item.connection_metadata_field,
|
|
applicationId: item.application_id,
|
|
operator: item.operator,
|
|
value: item.value
|
|
}))) : []);
|
|
env30179[3] = await requestMembersForRole(env30179[0], env30179[1], false);
|
|
if (env30179[3] != null) {
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_ROLE_MEMBER_COUNT_UPDATE",
|
|
guildId: env30179[0],
|
|
roleId: env30179[1],
|
|
count: env30179[3]
|
|
});
|
|
}
|
|
Dispatcher.dispatch({
|
|
type: "GUILD_ROLE_CONNECTIONS_CONFIGURATIONS_FETCH_SUCCESS",
|
|
roleId: env30179[1],
|
|
roleConnectionConfigurations: env30179[2]
|
|
});
|
|
}
|
|
export async function fetchUserApplicationRoleConnections() {
|
|
return (await HTTP.get({
|
|
url: Endpoints.APPLICATION_USER_ROLE_CONNECTIONS,
|
|
rejectWithError: false
|
|
})).body;
|
|
}
|