Skip to content

Commit

Permalink
Expose participant metadata for rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
mjh1 committed Jul 12, 2023
1 parent 64e991e commit 9fefe7d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/api/src/controllers/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ app.post(
}
}

const svc = new RoomServiceClient(
req.config.livekitHost,
req.config.livekitApiKey,
req.config.livekitSecret
);
const rooms = await svc.listRooms([req.params.roomId]);
if (rooms.length < 1) {
throw new BadRequestError(`room not currently running`);
}

const stream = await db.stream.get(req.body.streamId);
if (
!stream ||
Expand Down Expand Up @@ -206,6 +216,7 @@ app.post(
name: req.body.name,
identity: id,
ttl: 5 * 60,
metadata: req.body.metadata,
}
);
at.addGrant({
Expand Down Expand Up @@ -261,8 +272,11 @@ app.get("/:roomId/user/:participantId", authorizer({}), async (req, res) => {
state: participant.state,
joinedAt: participant.joinedAt * 1000,
name: participant.name,
permission: participant.permission,
permission: {
canPublish: participant.permission.canPublish,
},
isPublisher: participant.isPublisher,
metadata: participant.metadata,
});
});

Expand All @@ -281,7 +295,7 @@ app.put(
await svc.updateParticipant(
req.params.roomId,
req.params.participantId,
undefined,
req.body.metadata,
req.body.canPublish !== undefined
? ({ canPublish: req.body.canPublish } as any)
: undefined
Expand Down
9 changes: 9 additions & 0 deletions packages/api/src/schema/api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,9 @@ components:
type: boolean
description: Whether a user is allowed to publish audio/video tracks
example: true
metadata:
type: string
description: User defined payload to store for the participant
create-room-response:
type: object
properties:
Expand Down Expand Up @@ -1085,6 +1088,9 @@ components:
description: Whether a user is allowed to publish audio/video tracks
example: true
default: true
metadata:
type: string
description: User defined payload to store for the participant
room-egress-payload:
type: object
required:
Expand All @@ -1106,6 +1112,9 @@ components:
description: Whether a user is allowed to publish audio/video tracks
example: true
default: true
metadata:
type: string
description: User defined payload to store for the participant
transcode-payload:
additionalProperties: false
required:
Expand Down

0 comments on commit 9fefe7d

Please sign in to comment.