MDL-76551 mod_bigbluebuttonbn: Refactor join url

* get_join url should not have as many parameters as they can be deduced from the instance.
* Refactoring it will allow to pass on more implicit parameters like the user profile file.
This commit is contained in:
Laurent David 2023-01-11 17:38:03 +01:00
parent 794f107e88
commit ba81f720db
3 changed files with 54 additions and 52 deletions

View File

@ -51,50 +51,70 @@ class bigbluebutton_proxy extends proxy_base {
const DEFAULT_POLL_INTERVAL = 5;
/**
* Builds and returns a url for joining a bigbluebutton meeting.
* Builds and returns a url for joining a BigBlueButton meeting.
*
* @param string $meetingid
* @param string $username
* @param string $pw
* @param string $logouturl
* @param string $role
* @param string|null $configtoken
* @param int $userid
* @param instance $instance
* @param string|null $createtime
*
* @return string
*/
public static function get_join_url(
string $meetingid,
string $username,
string $pw,
string $logouturl,
string $role,
string $configtoken = null,
int $userid = 0,
string $createtime = null
instance $instance,
?string $createtime
): string {
return self::internal_get_join_url($instance, $createtime);
}
/**
* Builds and returns a url for joining a BigBlueButton meeting.
*
* @param instance $instance
* @param string|null $createtime
* @param string $username
* @return string
*/
public static function get_guest_join_url(
instance $instance,
?string $createtime,
string $username
): string {
return self::internal_get_join_url($instance, $createtime, $username, true);
}
/**
* Internal helper method to builds and returns a url for joining a BigBlueButton meeting.
*
*
* @param instance $instance
* @param string|null $jointime = null
* @param string|null $userfullname
* @param bool $isguestjoin
* @return string
* @throws \coding_exception
*/
private static function internal_get_join_url(
instance $instance,
?string $jointime,
string $userfullname = null,
bool $isguestjoin = false
): string {
$data = [
'meetingID' => $meetingid,
'fullName' => $username,
'password' => $pw,
'logoutURL' => $logouturl,
'role' => $role
'meetingID' => $instance->get_meeting_id(),
'fullName' => $userfullname ?? $instance->get_user_fullname(),
'password' => $instance->get_current_user_password(),
'logoutURL' => $isguestjoin ? $instance->get_guest_access_url()->out(false) : $instance->get_logout_url()->out(false),
'role' => $instance->get_current_user_role()
];
if (!is_null($configtoken)) {
$data['configToken'] = $configtoken;
}
if (!empty($userid)) {
$data['userID'] = $userid;
if (!$isguestjoin) {
$data['userID'] = $instance->get_user_id();
$data['guest'] = "false";
} else {
$data['guest'] = "true";
}
if (!is_null($createtime)) {
$data['createTime'] = $createtime;
if (!is_null($jointime)) {
$data['createTime'] = $jointime;
}
$currentlang = current_language();
if (!empty(trim($currentlang))) {

View File

@ -193,35 +193,17 @@ class meeting {
* @return string
*/
public function get_join_url(): string {
return bigbluebutton_proxy::get_join_url(
$this->instance->get_meeting_id(),
$this->instance->get_user_fullname(),
$this->instance->get_current_user_password(),
$this->instance->get_logout_url()->out(false),
$this->instance->get_current_user_role(),
null,
$this->instance->get_user_id(),
$this->get_meeting_info()->createtime
);
return bigbluebutton_proxy::get_join_url($this->instance, $this->get_meeting_info()->createtime);
}
/**
* Get meeting join URL for guest
*
* @param string $fullname
* @param string $userfullname
* @return string
*/
public function get_guest_join_url(string $fullname): string {
return bigbluebutton_proxy::get_join_url(
$this->instance->get_meeting_id(),
$fullname,
$this->instance->get_current_user_password(),
$this->instance->get_guest_access_url()->out(false),
$this->instance->get_current_user_role(),
null,
0,
$this->get_meeting_info()->createtime
);
public function get_guest_join_url(string $userfullname): string {
return bigbluebutton_proxy::get_guest_join_url($this->instance, $this->get_meeting_info()->createtime, $userfullname);
}

View File

@ -1,6 +1,6 @@
This files describes API changes in the bigbluebuttonbn code.
=== 4.2 ===
* Simplify bigbluebutton_proxy get_join_url so to pass only parameters that cannot be deduced from the instance.
* Add a new parameter for mod_bigbluebuttonbn\recording::sync_pending_recordings_from_server so sync only 'dismissed' recordings
(This was fixed in 4.2, 4.1.3 and 4.0.8).