Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backend): correct password in open room query #1258

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions backend/src/graphql/resolvers/RoomResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,17 @@ describe('RoomResolver', () => {
})
})

describe('one attendee', () => {
describe('one attendee and meeting in DB', () => {
beforeAll(async () => {
await prisma.meeting.create({
data: {
name: 'Dreammall Entwicklung',
meetingID: 'Dreammall-Entwicklung',
attendeePW: '1234',
},
})
})

beforeEach(() => {
getMeetingsMock.mockResolvedValue([
{
Expand Down Expand Up @@ -617,7 +627,8 @@ describe('RoomResolver', () => {
])
})

it('returns empty array', async () => {
it('returns room with attendee', async () => {
jest.clearAllMocks()
await expect(
testServer.executeOperation(
{
Expand Down Expand Up @@ -655,6 +666,14 @@ describe('RoomResolver', () => {
},
})
})

it('calls joinMeetingLink with correct PW', () => {
expect(joinMeetingLinkMock).toBeCalledWith({
fullName: 'User',
meetingID: 'Dreammall-Entwicklung',
password: '1234',
})
})
})

describe('some attendee', () => {
Expand Down
26 changes: 20 additions & 6 deletions backend/src/graphql/resolvers/RoomResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,31 @@ export class RoomResolver {
const { user } = context
if (!user) return []
const meetings = await getMeetings()
return meetings.map(
(m: MeetingInfo) =>
new OpenRoom(

if (meetings.length) {
const dbMeetingsPwMap = await prisma.meeting.findMany({
where: {
meetingID: { in: meetings.map((m: MeetingInfo) => m.meetingID) },
},
select: {
meetingID: true,
attendeePW: true,
},
})

return meetings.map((m: MeetingInfo) => {
const pw = dbMeetingsPwMap.find((pw) => pw.meetingID === m.meetingID)
return new OpenRoom(
m,
joinMeetingLink({
fullName: user.name,
meetingID: m.meetingID,
password: '',
password: pw?.attendeePW ? pw.attendeePW : '',
}),
),
)
)
})
}
return []
}

@Query(() => String, { nullable: true })
Expand Down