legacy mode
This commit is contained in:
parent
ae5d0c7800
commit
ba0b240d4f
@ -17,6 +17,9 @@ class MatrixClient
|
|||||||
/** @var int Update period in microseconds */
|
/** @var int Update period in microseconds */
|
||||||
private $update_period = 1000000;
|
private $update_period = 1000000;
|
||||||
|
|
||||||
|
/** @var bool Enable legacy mode for matrix API */
|
||||||
|
private $legacy_mode_enabled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $matrix_server Matrix server (https://domain.tld)
|
* @param string $matrix_server Matrix server (https://domain.tld)
|
||||||
*/
|
*/
|
||||||
@ -63,6 +66,15 @@ class MatrixClient
|
|||||||
$this->update_period = intval($seconds * 1000000);
|
$this->update_period = intval($seconds * 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change legacy mode
|
||||||
|
* @param bool $mode Enabled if true
|
||||||
|
*/
|
||||||
|
public function set_legacy_mode_enabled($mode)
|
||||||
|
{
|
||||||
|
$this->legacy_mode_enabled = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to login to Matrix API and get an access token.
|
* Try to login to Matrix API and get an access token.
|
||||||
* Will throw a MatrixRequestException if it fails
|
* Will throw a MatrixRequestException if it fails
|
||||||
@ -162,8 +174,14 @@ class MatrixClient
|
|||||||
{
|
{
|
||||||
$txn_id = $this->get_new_transaction_id();
|
$txn_id = $this->get_new_transaction_id();
|
||||||
$room_id = curl_escape($this->ch, $room_id);
|
$room_id = curl_escape($this->ch, $room_id);
|
||||||
$path = "/_matrix/client/v3/rooms/{$room_id}/send/{$event_type}/{$txn_id}";
|
if ($this->legacy_mode_enabled) {
|
||||||
return $this->query($path, "PUT", $body);
|
$path = "/_matrix/client/r0/rooms/{$room_id}/send/{$event_type}";
|
||||||
|
return $this->query($path, "POST", $body);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$path = "/_matrix/client/v3/rooms/{$room_id}/send/{$event_type}/{$txn_id}";
|
||||||
|
return $this->query($path, "PUT", $body);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user