Compare commits

..

No commits in common. "a310f4190c1a58cfb4f4fd025ffee2befd5d7ab1" and "881449a1702b5a49905500364e5abc6c9122e56f" have entirely different histories.

3 changed files with 22 additions and 15 deletions

View File

@ -42,13 +42,13 @@ abstract class Base
case 'room':
$room_alias = Http::withToken(config('matrix.as_token'))
->get(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.canonical_alias',config('matrix.server'),$this->room_id));
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.canonical_alias',config('matrix.server'),$this->room_id));
return $room_alias->json('alias',$this->room_id);
case 'topic':
$subject = Http::withToken(config('matrix.as_token'))
->get(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$this->room_id));
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$this->room_id));
return $subject->json('topic','Message from Matrix');

View File

@ -43,15 +43,21 @@ class Echomail extends Matrix
$this->o->fftn->point_id,
);
$user = sprintf('@%s:%s',$username,preg_replace('#^(http[s]?://)?([^:]+)(:[0-9]+)?$#','$2',config('matrix.server')));
$user = sprintf('@%s:%s',$username,config('matrix.server'));
// @todo We need to force IP4 as running clrghouz in a container without a proper IPv6 address is problematic
$matrix = Http::withToken(config('matrix.as_token'))
->withOptions([
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
]);
// Set topic if it is different:
$subject = Http::withToken(config('matrix.as_token'))
->get(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room));
$subject = $matrix
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room));
if (($x=preg_replace('/^RE:\s*/i','',$this->o->subject)) !== $subject->json('topic','Message from Matrix')) {
$topic = Http::withToken(config('matrix.as_token'))
->put(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room),[
$topic = $matrix
->put(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room),[
'topic'=>$x,
]);
@ -61,9 +67,9 @@ class Echomail extends Matrix
$omsg = preg_replace("/\r---.*$/U",'',$this->o->msg);
$msg = Http::withToken(config('matrix.as_token'))
$msg = $matrix
->withQueryParameters(['user_id'=>$user])
->post(sprintf('%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[
'msgtype'=>'m.text',
'format'=>'org.matrix.custom.html',
'body'=>mb_convert_encoding(str_replace("\r","\n",$omsg),'UTF-8','IBM850'),
@ -81,8 +87,8 @@ class Echomail extends Matrix
// If the user doesnt exist in matrix yet
if (str_starts_with($msg->json('error'),'Application service has not registered this user')) {
// Register user
$msg = Http::withToken(config('matrix.as_token'))
->post(sprintf('%s/_matrix/client/v3/register',config('matrix.server')),[
$msg = $matrix
->post(sprintf('https://%s/_matrix/client/v3/register',config('matrix.server')),[
'type'=>'m.login.application_service',
'username'=>$username,
]);
@ -94,9 +100,9 @@ class Echomail extends Matrix
// @todo Test that the user has been invited
// Invite user
$msg = Http::withToken(config('matrix.as_token'))
$msg = $matrix
//->withQueryParameters(['user_id'=>$user])
->post(sprintf('%s/_matrix/client/v3/rooms/%s/invite',config('matrix.server'),$room),[
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/invite',config('matrix.server'),$room),[
'user_id'=>$user,
]);
@ -106,9 +112,9 @@ class Echomail extends Matrix
}
// Join as user
$msg = Http::withToken(config('matrix.as_token'))
$msg = $matrix
->withQueryParameters(['user_id'=>$user])
->post(sprintf('%s/_matrix/client/v3/rooms/%s/join',config('matrix.server'),$room),[
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/join',config('matrix.server'),$room),[
'user_id'=>$user,
]);

View File

@ -7,6 +7,7 @@
"require": {
"php": "^8.2|8.3",
"ext-bz2": "*",
"ext-curl": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"ext-zip": "*",