From fcfa21543122390ce35f4288e8f68f9c57165bd3 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Thu, 7 Dec 2023 10:08:42 -0300 Subject: [PATCH] Add graphql actions for Users --- .../src/actions/cameraBroadcastStart.ts | 22 +++++++++++++++ .../src/actions/cameraBroadcastStop.ts | 22 +++++++++++++++ .../src/actions/userSetMuted.ts | 27 +++++++++++++++++++ .../src/actions/userThirdPartyInfoResquest.ts | 26 ++++++++++++++++++ .../src/index.ts | 13 +++++++-- bbb-graphql-server/metadata/actions.graphql | 24 +++++++++++++++++ bbb-graphql-server/metadata/actions.yaml | 24 +++++++++++++++++ 7 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStart.ts create mode 100644 bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStop.ts create mode 100644 bbb-graphql-actions-adapter-server/src/actions/userSetMuted.ts create mode 100644 bbb-graphql-actions-adapter-server/src/actions/userThirdPartyInfoResquest.ts diff --git a/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStart.ts b/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStart.ts new file mode 100644 index 0000000000..1cde21991f --- /dev/null +++ b/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStart.ts @@ -0,0 +1,22 @@ +import { RedisMessage } from '../types'; + +export default function buildRedisMessage(sessionVariables: Record, input: Record): 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 }; +} diff --git a/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStop.ts b/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStop.ts new file mode 100644 index 0000000000..5468ca9ae7 --- /dev/null +++ b/bbb-graphql-actions-adapter-server/src/actions/cameraBroadcastStop.ts @@ -0,0 +1,22 @@ +import { RedisMessage } from '../types'; + +export default function buildRedisMessage(sessionVariables: Record, input: Record): 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 }; +} diff --git a/bbb-graphql-actions-adapter-server/src/actions/userSetMuted.ts b/bbb-graphql-actions-adapter-server/src/actions/userSetMuted.ts new file mode 100644 index 0000000000..6b6d87b8c5 --- /dev/null +++ b/bbb-graphql-actions-adapter-server/src/actions/userSetMuted.ts @@ -0,0 +1,27 @@ +import { RedisMessage } from '../types'; +import {isModerator} from "../imports/validation"; + +export default function buildRedisMessage(sessionVariables: Record, input: Record): 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 }; +} diff --git a/bbb-graphql-actions-adapter-server/src/actions/userThirdPartyInfoResquest.ts b/bbb-graphql-actions-adapter-server/src/actions/userThirdPartyInfoResquest.ts new file mode 100644 index 0000000000..ca613e994b --- /dev/null +++ b/bbb-graphql-actions-adapter-server/src/actions/userThirdPartyInfoResquest.ts @@ -0,0 +1,26 @@ +import { RedisMessage } from '../types'; +import {throwErrorIfNotModerator} from "../imports/validation"; + +export default function buildRedisMessage(sessionVariables: Record, input: Record): 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 }; +} diff --git a/bbb-graphql-actions-adapter-server/src/index.ts b/bbb-graphql-actions-adapter-server/src/index.ts index d4896cd399..9609d9bf4d 100644 --- a/bbb-graphql-actions-adapter-server/src/index.ts +++ b/bbb-graphql-actions-adapter-server/src/index.ts @@ -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); diff --git a/bbb-graphql-server/metadata/actions.graphql b/bbb-graphql-server/metadata/actions.graphql index bdf04702fe..38d1c84958 100644 --- a/bbb-graphql-server/metadata/actions.graphql +++ b/bbb-graphql-server/metadata/actions.graphql @@ -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 +} diff --git a/bbb-graphql-server/metadata/actions.yaml b/bbb-graphql-server/metadata/actions.yaml index 8ce45cc758..facbee10ac 100644 --- a/bbb-graphql-server/metadata/actions.yaml +++ b/bbb-graphql-server/metadata/actions.yaml @@ -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: