Skip to content

Commit

Permalink
fix(backend): derive INVITE_LINK_URL and BBB_LOGOUT_URL from FRONTEND…
Browse files Browse the repository at this point in the history
…_URL (#1820)

In our kubernetes Deployment, the environment variable FRONTEND_BBB_LOGOUT_URL was missing. Therefore the fix for #1261 did not work.

Instead of adding the environment variable, I propose to simplify the config and derive its value, as well as the one for invite links, from the FRONTEND_URL.
  • Loading branch information
Bettelstab authored Aug 22, 2024
1 parent 8446bb8 commit 6ebf34c
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 23 deletions.
2 changes: 0 additions & 2 deletions backend/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ BREVO_NEWSLETTER_LIST="3"
DATABASE_URL="mysql://root:@localhost:3306/dreammall.earth"

FRONTEND_URL="http://localhost:3000/"
FRONTEND_INVITE_LINK_URL="${FRONTEND_URL}join-table/"
FRONTEND_BBB_LOGOUT_URL="${FRONTEND_URL}table-closed/"

BBB_SHARED_SECRET=""
BBB_URL=""
Expand Down
2 changes: 1 addition & 1 deletion backend/src/api/BBB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const parser = new XMLParser({
const defaultCreateMeetingBodyOptions = {
welcome: '<div></div>',
meetingLayout: MeetingLayouts.SMART_LAYOUT,
logoutURL: CONFIG.FRONTEND_BBB_LOGOUT_URL,
logoutURL: new URL('table-closed/', CONFIG.FRONTEND_URL),
}

export const getMeetings = async (): Promise<MeetingInfo[]> => {
Expand Down
8 changes: 3 additions & 5 deletions backend/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ const BBB = {
BBB_PULL_MEETINGS: process.env.NODE_ENV !== 'test' && process.env.BBB_URL,
}

const FRONTEND_URL = process.env.FRONTEND_URL ?? 'http://localhost:3000/'

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-table/',
FRONTEND_BBB_LOGOUT_URL:
process.env.FRONTEND_BBB_LOGOUT_URL ?? 'http://localhost:3000/table-closed/',
FRONTEND_URL,
}

const { JWKS_URI } = process.env
Expand Down
4 changes: 2 additions & 2 deletions backend/src/graphql/resolvers/TableResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getMeetingsMock = jest.mocked(getMeetings)

let testServer: ApolloServer<Context>

CONFIG.FRONTEND_INVITE_LINK_URL = '/'
CONFIG.FRONTEND_URL = 'https://my.frontend.url'

const nickname = 'mockedUser'
const name = 'User'
Expand Down Expand Up @@ -808,7 +808,7 @@ describe('TableResolver', () => {
meetingID: result?.meeting?.meetingID,
},
{
moderatorOnlyMessage: `Use this link to invite more people:<br/>/${result?.meeting?.id}`,
moderatorOnlyMessage: `Use this link to invite more people:<br/>https://my.frontend.url/join-table/${result?.meeting?.id}`,
},
)
})
Expand Down
2 changes: 1 addition & 1 deletion backend/src/graphql/resolvers/TableResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class TableResolver {
throw new Error('Could not create Meeting in DB!')
}

const inviteLink = CONFIG.FRONTEND_INVITE_LINK_URL + dbMeeting.id
const inviteLink = new URL(`join-table/${dbMeeting.id}`, CONFIG.FRONTEND_URL).toString()

const meeting = await createMeeting(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ spec:
configMapKeyRef:
name: {{ .Release.Name }}
key: frontend_url
- name: FRONTEND_INVITE_LINK_URL
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}
key: frontend_invite_link_url
- name: NODE_ENV
value: production
image: "{{ .Values.backend.image.repository }}:{{ default .Values.global.image.tag .Values.backend.image.tag "latest" }}"
Expand All @@ -48,11 +43,6 @@ spec:
configMapKeyRef:
name: {{ .Release.Name }}
key: frontend_url
- name: FRONTEND_INVITE_LINK_URL
valueFrom:
configMapKeyRef:
name: {{ .Release.Name }}
key: frontend_invite_link_url
- name: JWKS_URI
valueFrom:
configMapKeyRef:
Expand Down
1 change: 0 additions & 1 deletion infrastructure/helmfile/dreammall/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ configmap:
bbb_url: https://cafe.dreammall.earth/bigbluebutton/api/
endpoints_graphql_uri: https://master.dreammall.earth/api/
endpoints_websocket_uri: ws://master.dreammall.earth/api/subscriptions
frontend_invite_link_url: https://app.master.dreammall.earth/join-room/
frontend_url: https://app.master.dreammall.earth
jwks_uri: http://authentik-server/application/o/dreammallearth/jwks/
presenter_url: https://master.dreammall.earth
1 change: 0 additions & 1 deletion infrastructure/helmfile/values/dreammall.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ configmap:
bbb_url: https://cafe.dreammall.earth/bigbluebutton/api/
endpoints_graphql_uri: https://{{ .StateValues.domain }}/api/
endpoints_websocket_uri: ws://{{ .StateValues.domain }}/api/subscriptions
frontend_invite_link_url: https://app.{{ .StateValues.domain }}/join-room/
frontend_url: https://app.{{ .StateValues.domain }}
jwks_uri: http://authentik-server/application/o/dreammallearth/jwks/
presenter_url: https://{{ .StateValues.domain }}

0 comments on commit 6ebf34c

Please sign in to comment.