Switch getJoinUrl to a POST request as it contains meeting join details
This commit is contained in:
parent
191f30819b
commit
688442ed31
|
@ -1,8 +1,8 @@
|
||||||
import { GET, Path, QueryParam } from "typescript-rest";
|
import { GET, POST, Path, QueryParam } from "typescript-rest";
|
||||||
import * as request from "request";
|
import * as request from "request";
|
||||||
import { LogService } from "matrix-js-snippets";
|
import { LogService } from "matrix-js-snippets";
|
||||||
import { URL } from "url";
|
import { URL } from "url";
|
||||||
import { BigBlueButtonJoinRequest } from "../../models/Widget";
|
import { BigBlueButtonGetJoinUrlRequest } from "../../models/Widget";
|
||||||
import { BigBlueButtonJoinResponse, BigBlueButtonCreateAndJoinMeetingResponse, BigBlueButtonWidgetResponse } from "../../models/WidgetResponses";
|
import { BigBlueButtonJoinResponse, BigBlueButtonCreateAndJoinMeetingResponse, BigBlueButtonWidgetResponse } from "../../models/WidgetResponses";
|
||||||
import { AutoWired } from "typescript-ioc/es6";
|
import { AutoWired } from "typescript-ioc/es6";
|
||||||
import { ApiError } from "../ApiError";
|
import { ApiError } from "../ApiError";
|
||||||
|
@ -112,7 +112,6 @@ export class DimensionBigBlueButtonService {
|
||||||
@GET
|
@GET
|
||||||
@Path("join")
|
@Path("join")
|
||||||
public async join(
|
public async join(
|
||||||
joinRequest: BigBlueButtonJoinRequest,
|
|
||||||
@QueryParam("greenlightUrl") greenlightURL: string,
|
@QueryParam("greenlightUrl") greenlightURL: string,
|
||||||
@QueryParam("fullName") fullName: string,
|
@QueryParam("fullName") fullName: string,
|
||||||
): Promise<BigBlueButtonJoinResponse|ApiError> {
|
): Promise<BigBlueButtonJoinResponse|ApiError> {
|
||||||
|
@ -122,7 +121,6 @@ export class DimensionBigBlueButtonService {
|
||||||
LogService.info("BigBlueButton", "URL from client: " + greenlightURL);
|
LogService.info("BigBlueButton", "URL from client: " + greenlightURL);
|
||||||
LogService.info("BigBlueButton", "MeetingID: " + greenlightMeetingID);
|
LogService.info("BigBlueButton", "MeetingID: " + greenlightMeetingID);
|
||||||
LogService.info("BigBlueButton", "Name given from client: " + fullName);
|
LogService.info("BigBlueButton", "Name given from client: " + fullName);
|
||||||
LogService.info("BigBlueButton", joinRequest);
|
|
||||||
|
|
||||||
// Query the URL the user has given us
|
// Query the URL the user has given us
|
||||||
let response = await this.doRequest("GET", greenlightURL);
|
let response = await this.doRequest("GET", greenlightURL);
|
||||||
|
@ -254,24 +252,16 @@ export class DimensionBigBlueButtonService {
|
||||||
* Clients can call this endpoint in order to retrieve a URL that leads to the BigBlueButton API that they can
|
* Clients can call this endpoint in order to retrieve a URL that leads to the BigBlueButton API that they can
|
||||||
* use to join the meeting with. They will need to provide the meeting ID and password which are only available
|
* use to join the meeting with. They will need to provide the meeting ID and password which are only available
|
||||||
* from the widget room state event.
|
* from the widget room state event.
|
||||||
* @param {string} displayName The displayname of the user.
|
* @param {BigBlueButtonGetJoinUrlRequest} getJoinUrlRequest The body of the request.
|
||||||
* @param {string} userId The Matrix User ID of the user.
|
|
||||||
* @param {string} avatarUrl The avatar of the user (mxc://...).
|
|
||||||
* @param {string} meetingId The meeting ID to join.
|
|
||||||
* @param {string} password The password to attempt to join the meeting with.
|
|
||||||
*/
|
*/
|
||||||
@GET
|
@POST
|
||||||
@Path("getJoinUrl")
|
@Path("getJoinUrl")
|
||||||
public async createAndJoinMeeting(
|
public async getJoinUrl(
|
||||||
@QueryParam("displayName") displayName: string,
|
getJoinUrlRequest: BigBlueButtonGetJoinUrlRequest,
|
||||||
@QueryParam("userId") userId: string,
|
|
||||||
@QueryParam("avatarUrl") avatarUrl: string,
|
|
||||||
@QueryParam("meetingId") meetingId: string,
|
|
||||||
@QueryParam("meetingPassword") password: string,
|
|
||||||
): Promise<BigBlueButtonCreateAndJoinMeetingResponse|ApiError> {
|
): Promise<BigBlueButtonCreateAndJoinMeetingResponse|ApiError> {
|
||||||
// Check if the meeting exists and is running. If not, return an error for each case
|
// Check if the meeting exists and is running. If not, return an error for each case
|
||||||
let getMeetingInfoParameters = {
|
let getMeetingInfoParameters = {
|
||||||
meetingID: meetingId,
|
meetingID: getJoinUrlRequest.meetingId,
|
||||||
}
|
}
|
||||||
|
|
||||||
const getMeetingInfoResponse = await this.makeBBBApiCall("GET", "getMeetingInfo", getMeetingInfoParameters, null);
|
const getMeetingInfoResponse = await this.makeBBBApiCall("GET", "getMeetingInfo", getMeetingInfoParameters, null);
|
||||||
|
@ -292,16 +282,25 @@ export class DimensionBigBlueButtonService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Construct a fullName parameter from the provided user ID and display name (if provided).
|
||||||
|
// It's important to display the user ID so that users cannot impersonate each other.
|
||||||
|
let fullName: string;
|
||||||
|
if (getJoinUrlRequest.displayName) {
|
||||||
|
fullName = `${getJoinUrlRequest.displayName} (${getJoinUrlRequest.userId})`;
|
||||||
|
} else {
|
||||||
|
fullName = getJoinUrlRequest.userId;
|
||||||
|
}
|
||||||
|
|
||||||
let joinQueryParameters = {
|
let joinQueryParameters = {
|
||||||
meetingID: meetingId,
|
meetingID: getJoinUrlRequest.meetingId,
|
||||||
password: password,
|
password: getJoinUrlRequest.meetingPassword,
|
||||||
fullName: `${displayName} (${userId})`,
|
fullName: fullName,
|
||||||
userID: userId,
|
userID: getJoinUrlRequest.userId,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add an avatar to the join request if the user provided one
|
// Add an avatar to the join request if the user provided one
|
||||||
if (avatarUrl.startsWith("mxc")) {
|
if (getJoinUrlRequest.avatarUrl.startsWith("mxc")) {
|
||||||
joinQueryParameters["avatarURL"] = this.getHTTPAvatarUrlFromMXCUrl(avatarUrl);
|
joinQueryParameters["avatarURL"] = this.getHTTPAvatarUrlFromMXCUrl(getJoinUrlRequest.avatarUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the checksum for the join URL. We need to do so as a browser would as we're passing this back to a browser
|
// Calculate the checksum for the join URL. We need to do so as a browser would as we're passing this back to a browser
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
export interface BigBlueButtonJoinRequest {
|
export interface BigBlueButtonGetJoinUrlRequest {
|
||||||
// A URL supplied by greenlight, BigBlueButton's nice UI project that is itself
|
// The display name of the user attempting to join the meeting.
|
||||||
// a BigBlueButton client
|
// Will be combined with userId and passed to BigBlueButton.
|
||||||
greenlightUrl: string;
|
displayName: string;
|
||||||
// The name the user wishes to join the meeting with
|
// The user ID of the user attempting to join the meeting.
|
||||||
fullName: string;
|
// Will be combined with displayName and passed to BigBlueButton.
|
||||||
}
|
userId: string;
|
||||||
|
// Optional. The avatar of the user attempting to join the meeting.
|
||||||
export interface BigBlueButtonCreateAndJoinMeetingRequest {
|
// Will be passed to BigBlueButton.
|
||||||
// The ID of the room that the BBB meeting is a part of
|
avatarUrl: string;
|
||||||
roomId: string;
|
// The ID of the meeting to join.
|
||||||
// The name the user wishes to join the meeting with
|
meetingId: string;
|
||||||
fullName: string;
|
// The password to join the meeting with.
|
||||||
|
meetingPassword: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class BigBlueButtonApiService extends AuthedApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getJoinUrl(displayName: string, userId: string, avatarUrl: string, meetingId: string, meetingPassword: string): Promise<FE_BigBlueButtonCreateAndJoinMeeting|ApiError> {
|
public getJoinUrl(displayName: string, userId: string, avatarUrl: string, meetingId: string, meetingPassword: string): Promise<FE_BigBlueButtonCreateAndJoinMeeting|ApiError> {
|
||||||
return this.authedGet<FE_BigBlueButtonCreateAndJoinMeeting|ApiError>(
|
return this.authedPost<FE_BigBlueButtonCreateAndJoinMeeting|ApiError>(
|
||||||
"/api/v1/dimension/bigbluebutton/getJoinUrl",
|
"/api/v1/dimension/bigbluebutton/getJoinUrl",
|
||||||
{displayName: displayName, userId: userId, avatarUrl: avatarUrl, meetingId: meetingId, meetingPassword: meetingPassword},
|
{displayName: displayName, userId: userId, avatarUrl: avatarUrl, meetingId: meetingId, meetingPassword: meetingPassword},
|
||||||
).toPromise();
|
).toPromise();
|
||||||
|
|
Loading…
Reference in a new issue