MATRIX_SERVER configuration item is now a URL
This commit is contained in:
parent
6342fe28b2
commit
a310f4190c
@ -42,13 +42,13 @@ abstract class Base
|
|||||||
|
|
||||||
case 'room':
|
case 'room':
|
||||||
$room_alias = Http::withToken(config('matrix.as_token'))
|
$room_alias = Http::withToken(config('matrix.as_token'))
|
||||||
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.canonical_alias',config('matrix.server'),$this->room_id));
|
->get(sprintf('%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);
|
return $room_alias->json('alias',$this->room_id);
|
||||||
|
|
||||||
case 'topic':
|
case 'topic':
|
||||||
$subject = Http::withToken(config('matrix.as_token'))
|
$subject = Http::withToken(config('matrix.as_token'))
|
||||||
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$this->room_id));
|
->get(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$this->room_id));
|
||||||
|
|
||||||
return $subject->json('topic','Message from Matrix');
|
return $subject->json('topic','Message from Matrix');
|
||||||
|
|
||||||
|
@ -43,15 +43,15 @@ class Echomail extends Matrix
|
|||||||
$this->o->fftn->point_id,
|
$this->o->fftn->point_id,
|
||||||
);
|
);
|
||||||
|
|
||||||
$user = sprintf('@%s:%s',$username,config('matrix.server'));
|
$user = sprintf('@%s:%s',$username,preg_replace('#^(http[s]?://)?([^:]+)(:[0-9]+)?$#','$2',config('matrix.server')));
|
||||||
|
|
||||||
// Set topic if it is different:
|
// Set topic if it is different:
|
||||||
$subject = Http::withToken(config('matrix.as_token'))
|
$subject = Http::withToken(config('matrix.as_token'))
|
||||||
->get(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room));
|
->get(sprintf('%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')) {
|
if (($x=preg_replace('/^RE:\s*/i','',$this->o->subject)) !== $subject->json('topic','Message from Matrix')) {
|
||||||
$topic = Http::withToken(config('matrix.as_token'))
|
$topic = Http::withToken(config('matrix.as_token'))
|
||||||
->put(sprintf('https://%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room),[
|
->put(sprintf('%s/_matrix/client/v3/rooms/%s/state/m.room.topic',config('matrix.server'),$room),[
|
||||||
'topic'=>$x,
|
'topic'=>$x,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class Echomail extends Matrix
|
|||||||
|
|
||||||
$msg = Http::withToken(config('matrix.as_token'))
|
$msg = Http::withToken(config('matrix.as_token'))
|
||||||
->withQueryParameters(['user_id'=>$user])
|
->withQueryParameters(['user_id'=>$user])
|
||||||
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[
|
->post(sprintf('%s/_matrix/client/v3/rooms/%s/send/m.room.message',config('matrix.server'),$room),[
|
||||||
'msgtype'=>'m.text',
|
'msgtype'=>'m.text',
|
||||||
'format'=>'org.matrix.custom.html',
|
'format'=>'org.matrix.custom.html',
|
||||||
'body'=>mb_convert_encoding(str_replace("\r","\n",$omsg),'UTF-8','IBM850'),
|
'body'=>mb_convert_encoding(str_replace("\r","\n",$omsg),'UTF-8','IBM850'),
|
||||||
@ -82,7 +82,7 @@ class Echomail extends Matrix
|
|||||||
if (str_starts_with($msg->json('error'),'Application service has not registered this user')) {
|
if (str_starts_with($msg->json('error'),'Application service has not registered this user')) {
|
||||||
// Register user
|
// Register user
|
||||||
$msg = Http::withToken(config('matrix.as_token'))
|
$msg = Http::withToken(config('matrix.as_token'))
|
||||||
->post(sprintf('https://%s/_matrix/client/v3/register',config('matrix.server')),[
|
->post(sprintf('%s/_matrix/client/v3/register',config('matrix.server')),[
|
||||||
'type'=>'m.login.application_service',
|
'type'=>'m.login.application_service',
|
||||||
'username'=>$username,
|
'username'=>$username,
|
||||||
]);
|
]);
|
||||||
@ -96,7 +96,7 @@ class Echomail extends Matrix
|
|||||||
// Invite user
|
// Invite user
|
||||||
$msg = Http::withToken(config('matrix.as_token'))
|
$msg = Http::withToken(config('matrix.as_token'))
|
||||||
//->withQueryParameters(['user_id'=>$user])
|
//->withQueryParameters(['user_id'=>$user])
|
||||||
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/invite',config('matrix.server'),$room),[
|
->post(sprintf('%s/_matrix/client/v3/rooms/%s/invite',config('matrix.server'),$room),[
|
||||||
'user_id'=>$user,
|
'user_id'=>$user,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class Echomail extends Matrix
|
|||||||
// Join as user
|
// Join as user
|
||||||
$msg = Http::withToken(config('matrix.as_token'))
|
$msg = Http::withToken(config('matrix.as_token'))
|
||||||
->withQueryParameters(['user_id'=>$user])
|
->withQueryParameters(['user_id'=>$user])
|
||||||
->post(sprintf('https://%s/_matrix/client/v3/rooms/%s/join',config('matrix.server'),$room),[
|
->post(sprintf('%s/_matrix/client/v3/rooms/%s/join',config('matrix.server'),$room),[
|
||||||
'user_id'=>$user,
|
'user_id'=>$user,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user