Merge pull request #19303 from gustavotrott/graphql-actions-user2

graphql-actions: User actions (more actions)
This commit is contained in:
Gustavo Trott 2023-12-07 13:55:54 -03:00 committed by GitHub
commit 32ffa5099c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 156 additions and 2 deletions

View File

@ -0,0 +1,22 @@
import { RedisMessage } from '../types';
export default function buildRedisMessage(sessionVariables: Record<string, unknown>, input: Record<string, unknown>): RedisMessage {
const eventName = `UserBroadcastCamStartMsg`;
const routing = {
meetingId: sessionVariables['x-hasura-meetingid'] as String,
userId: sessionVariables['x-hasura-userid'] as String
};
const header = {
name: eventName,
meetingId: routing.meetingId,
userId: routing.userId
};
const body = {
stream: input.stream
};
return { eventName, routing, header, body };
}

View File

@ -0,0 +1,22 @@
import { RedisMessage } from '../types';
export default function buildRedisMessage(sessionVariables: Record<string, unknown>, input: Record<string, unknown>): RedisMessage {
const eventName = `UserBroadcastCamStopMsg`;
const routing = {
meetingId: sessionVariables['x-hasura-meetingid'] as String,
userId: sessionVariables['x-hasura-userid'] as String
};
const header = {
name: eventName,
meetingId: routing.meetingId,
userId: routing.userId
};
const body = {
stream: input.stream
};
return { eventName, routing, header, body };
}

View File

@ -0,0 +1,27 @@
import { RedisMessage } from '../types';
import {isModerator} from "../imports/validation";
export default function buildRedisMessage(sessionVariables: Record<string, unknown>, input: Record<string, unknown>): RedisMessage {
const eventName = `MuteUserCmdMsg`;
const routing = {
meetingId: sessionVariables['x-hasura-meetingid'] as String,
userId: sessionVariables['x-hasura-userid'] as String
};
const header = {
name: eventName,
meetingId: routing.meetingId,
userId: routing.userId
};
const userId = isModerator(sessionVariables) && input.hasOwnProperty('userId') ? input.userId : routing.userId;
const body = {
mutedBy: routing.userId,
userId: userId,
mute: input.muted
};
return { eventName, routing, header, body };
}

View File

@ -0,0 +1,26 @@
import { RedisMessage } from '../types';
import {throwErrorIfNotModerator} from "../imports/validation";
export default function buildRedisMessage(sessionVariables: Record<string, unknown>, input: Record<string, unknown>): RedisMessage {
throwErrorIfNotModerator(sessionVariables);
const eventName = `LookUpUserReqMsg`;
const routing = {
meetingId: sessionVariables['x-hasura-meetingid'] as String,
userId: sessionVariables['x-hasura-userid'] as String
};
const header = {
name: eventName,
meetingId: routing.meetingId,
userId: routing.userId
};
const body = {
externalUserId: input.externalUserId
};
//TODO validate Meteor.settings.public.app.allowUserLookup
return { eventName, routing, header, body };
}

View File

@ -28,7 +28,12 @@ app.post('/', async (req: Request, res: Response) => {
}
// Build message using received information.
const { eventName, routing, header, body } = await redisMessageFactory.buildMessage(sessionVariables, actionName, input);
const {
eventName,
routing,
header,
body
} = await redisMessageFactory.buildMessage(sessionVariables, actionName, input);
// Construct payload to be sent to Redis.
const redisPayload = {
@ -49,7 +54,11 @@ app.post('/', async (req: Request, res: Response) => {
}
// Publish the constructed payload to Redis.
await redisClient.publish('to-akka-apps-redis-channel', JSON.stringify(redisPayload));
if(actionName == 'userThirdPartyInfoResquest') {
await redisClient.publish('to-third-party-redis-channel', JSON.stringify(redisPayload));
} else {
await redisClient.publish('to-akka-apps-redis-channel', JSON.stringify(redisPayload));
}
// Send a success response.
res.status(200).json(true);

View File

@ -456,3 +456,27 @@ input GuestUserApprovalStatus {
status: String!
}
type Mutation {
userSetMuted(
userId: String
muted: Boolean!
): Boolean
}
type Mutation {
cameraBroadcastStart(
stream: String!
): Boolean
}
type Mutation {
cameraBroadcastStop(
stream: String!
): Boolean
}
type Mutation {
userThirdPartyInfoResquest(
externalUserId: String!
): Boolean
}

View File

@ -408,6 +408,30 @@ actions:
handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}'
permissions:
- role: bbb_client
- name: userSetMuted
definition:
kind: synchronous
handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}'
permissions:
- role: bbb_client
- name: cameraBroadcastStart
definition:
kind: synchronous
handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}'
permissions:
- role: bbb_client
- name: cameraBroadcastStop
definition:
kind: synchronous
handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}'
permissions:
- role: bbb_client
- name: userThirdPartyInfoResquest
definition:
kind: synchronous
handler: '{{HASURA_BBB_GRAPHQL_ACTIONS_ADAPTER_URL}}'
permissions:
- role: bbb_client
custom_types:
enums: []
input_objects: