Skip to content

Commit

Permalink
feat(backend): more meeting options (#1375)
Browse files Browse the repository at this point in the history
* Add body options to create Meeting

Set default layout of BBB to VIDEO_FOCUS

Set message to blank div, is there a way to use no space at all? May be CSS inside the div?

Pass the invite link through the moderator only message

* remove unused imports

* fix typo

---------

Co-authored-by: Hannes Heine <heine.hannes@gmail.com>
  • Loading branch information
Mogge and Elweyn authored Jul 11, 2024
1 parent 4f5dbfd commit 7e67458
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
3 changes: 3 additions & 0 deletions backend/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ BREVO_NEWSLETTER_TEMPLATE_OPTIN="3"
BREVO_NEWSLETTER_LIST="3"
DATABASE_URL="mysql://root:@localhost:3306/dreammall.earth"

FRONTEND_URL="http://localhost:3000/"
INVITE_LINK_URL="${FRONTEND_URL}join-room/"

BBB_SHARED_SECRET=""
BBB_URL=""
16 changes: 13 additions & 3 deletions backend/src/api/BBB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
GetMeetingsResponse,
CreateMeetingOptions,
JoinMeetinLinkOptions,
CreateMeetingBodyOptions,
MeetingLayouts,
} from './BBB/types'

export { MeetingInfo, AttendeeInfo } from './BBB/types'
Expand All @@ -20,6 +22,11 @@ const parser = new XMLParser({
isArray: (_, jpath) => alwaysArray.indexOf(jpath) !== -1,
})

const defaultCreateMeetingBodyOptions = {
welcome: '<div></div>',
meetingLayout: MeetingLayouts.VIDEO_FOCUS,
}

export const getMeetings = async (): Promise<MeetingInfo[]> => {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand All @@ -42,18 +49,21 @@ export const getMeetings = async (): Promise<MeetingInfo[]> => {

export const createMeeting = async (
options: CreateMeetingOptions,
bodyOptions: CreateMeetingBodyOptions = {},
): Promise<CreateMeetingResponse | null> => {
const { name, meetingID /*, welcome */ } = options
const { name, meetingID } = options
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data } = await axiosInstance.post(
'/create',
{},
{
...defaultCreateMeetingBodyOptions,
...bodyOptions,
},
{
params: {
name,
meetingID,
// welcome,
},
},
)
Expand Down
13 changes: 13 additions & 0 deletions backend/src/api/BBB/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,16 @@ export interface JoinMeetinLinkOptions {
createTime?: string
userID?: string
}

export enum MeetingLayouts {
CUSTOM_LAYOUT = 'CUSTOM_LAYOUT',
SMART_LAYOUT = 'SMART_LAYOUT',
PRESENTATION_FOCUS = 'PRESENTATION_FOCUS',
VIDEO_FOCUS = 'VIDEO_FOCUS',
}

export interface CreateMeetingBodyOptions {
welcome?: string
meetingLayout?: MeetingLayouts
moderatorOnlyMessage?: string
}
7 changes: 7 additions & 0 deletions backend/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ const BBB = {
BBB_PULL_MEETINGS: process.env.NODE_ENV !== 'test' && process.env.BBB_URL,
}

const FRONTEND = {
FRONTEND_URL: process.env.FRONTEND_URL ?? 'http://localhost:3000/',
FRONTEND_INVITE_LINK_URL:
process.env.FRONTEND_INVITE_LINK_URL ?? 'http://localhost:3000/join-room/',
}

export const CONFIG = {
...BREVO,
...BBB,
...FRONTEND,
}

// Config Checks
Expand Down
14 changes: 13 additions & 1 deletion backend/src/graphql/resolvers/RoomResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ApolloServer } from '@apollo/server'
import { gql } from 'graphql-tag'

import { createMeeting, joinMeetingLink, getMeetings } from '#api/BBB'
import { CONFIG } from '#config/config'
import { prisma } from '#src/prisma'
import { createTestServer } from '#src/server/server'

Expand All @@ -14,6 +15,8 @@ const getMeetingsMock = getMeetings as jest.MockedFunction<typeof getMeetings>

let testServer: ApolloServer

CONFIG.FRONTEND_INVITE_LINK_URL = '/'

beforeAll(async () => {
testServer = await createTestServer()
})
Expand Down Expand Up @@ -340,7 +343,7 @@ describe('RoomResolver', () => {
})
})

it('creates meeting in database', async () => {
it('creates meeting in database and calls createMeeting', async () => {
const result = await prisma.user.findFirst({
include: {
meeting: true,
Expand All @@ -363,6 +366,15 @@ describe('RoomResolver', () => {
createDate: expect.any(Date),
},
})
expect(createMeetingMock).toBeCalledWith(
{
name: 'mockedUser',
meetingID: result?.meeting?.meetingID,
},
{
moderatorOnlyMessage: `Use this link to invite more people:<br/>/${result?.meeting?.id}`,
},
)
})
})

Expand Down
16 changes: 12 additions & 4 deletions backend/src/graphql/resolvers/RoomResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { v4 as uuidv4 } from 'uuid'

import { createMeeting, joinMeetingLink, getMeetings, MeetingInfo } from '#api/BBB'
import { CONFIG } from '#config/config'
import { Room, OpenRoom } from '#models/RoomModel'
import logger from '#src/logger'
import { prisma } from '#src/prisma'
Expand Down Expand Up @@ -105,10 +106,17 @@ export class RoomResolver {
throw new Error('Could not create Meeting in DB!')
}

const meeting = await createMeeting({
name: dbMeeting.name,
meetingID: dbMeeting.meetingID,
})
const inviteLink = CONFIG.FRONTEND_INVITE_LINK_URL + dbMeeting.id

const meeting = await createMeeting(
{
name: dbMeeting.name,
meetingID: dbMeeting.meetingID,
},
{
moderatorOnlyMessage: `Use this link to invite more people:<br/>${inviteLink}`,
},
)

if (!meeting) throw new Error('Could not create meeting!')

Expand Down

0 comments on commit 7e67458

Please sign in to comment.