43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
// Metro module 13548 (f13549).
|
|
import RelationshipStore from "../../../../stores/RelationshipStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { RPC_SCOPE_CONFIG } from "../../Constants";
|
|
import { ApplicationFlags, RPCErrors, RelationshipTypes, RPCCommands } from "../../../../Constants";
|
|
import { createRPCCommand } from "../../../../_bundle/Module13535";
|
|
import { OAuth2Scopes } from "../../../../_bundle/Module8174";
|
|
import { has, deserialize } from "../../../../_bundle/HighLow";
|
|
import RPCError from "../../RPCError";
|
|
import { transformApplicationRelationship, transformBaseRelationship } from "../../RPCHelpers";
|
|
const r32 = {};
|
|
const { GET_RELATIONSHIPS, GET_RELATIONSHIPS: GET_RELATIONSHIPS2 } = RPCCommands;
|
|
const scope = {};
|
|
scope[RPC_SCOPE_CONFIG.ANY] = [OAuth2Scopes.RELATIONSHIPS_READ];
|
|
r32[GET_RELATIONSHIPS] = createRPCCommand(GET_RELATIONSHIPS2, {
|
|
scope,
|
|
handler: (a0) => {
|
|
let flags = a0.socket.application.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
if (has(deserialize(flags), deserialize(ApplicationFlags.DISABLE_RELATIONSHIPS_ACCESS))) {
|
|
throw new RPCError({
|
|
errorCode: RPCErrors.INVALID_PERMISSIONS
|
|
}, "Missing Permissions");
|
|
}
|
|
const relationships = [];
|
|
for (const item of RelationshipStore.getMutableRelationships().entries()) {
|
|
const [r59, r60] = item;
|
|
if (r60 !== RelationshipTypes.NONE) {
|
|
const user = UserStore.getUser(r59);
|
|
if (user != null) {
|
|
relationships.push(transformApplicationRelationship(transformBaseRelationship(r60, user), a0.socket.application.id));
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
relationships
|
|
};
|
|
}
|
|
});
|
|
export default r32;
|