upload notifications for matrix
This commit is contained in:
@@ -164,29 +164,37 @@ class VideoController extends Controller
|
|||||||
// exec("curl -H \"Content-Type: application/json; charset=UTF-8\" -X POST -d '$payload' '$url' > /dev/null &");
|
// exec("curl -H \"Content-Type: application/json; charset=UTF-8\" -X POST -d '$payload' '$url' > /dev/null &");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (config('matrix.enabled') && config('matrix.token') && config('matrix.homeserver') && config('matrix.room')) {
|
if (config('matrix.enabled') && config('matrix.token') && config('matrix.homeserver') && config('matrix.room')) {
|
||||||
$nsfw = in_array('nsfw', $video->getTagArrayNormalizedAttribute());
|
|
||||||
$nsfw = $nsfw ? ' NSFW' : '';
|
|
||||||
$message = config('matrix.message');
|
|
||||||
$message = str_replace(
|
|
||||||
['<USER>', '<ID>', '<NSFW>'],
|
|
||||||
[$user->username, $video->id, $nsfw],
|
|
||||||
$message
|
|
||||||
);
|
|
||||||
|
|
||||||
$token = config('matrix.token');
|
$mauauth = config('matrix.mauauth');
|
||||||
$homeserver = config('matrix.homeserver');
|
$mauurl = config('matrix.mauurl');
|
||||||
$room = config('matrix.room');
|
|
||||||
|
|
||||||
$payload = json_encode([
|
$payload = json_encode([
|
||||||
"msgtype" => "m.text",
|
"user" => $user->username,
|
||||||
"body" => $message
|
"video_id" => $video->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
exec("curl -v -XPOST -d '$payload' '$homeserver$room/send/m.room.message?access_token=$token' > /dev/null &");
|
exec("curl -X POST -H 'Content-Type: application/json' -u '$mauauth' '$mauurl' -d '$payload' ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (config('matrix.enabled') && config('matrix.token') && config('matrix.homeserver') && config('matrix.room')) {
|
||||||
|
// $nsfw = in_array('nsfw', $video->getTagArrayNormalizedAttribute());
|
||||||
|
// $nsfw = $nsfw ? ' NSFW' : '';
|
||||||
|
// $message = config('matrix.message');
|
||||||
|
// $message = str_replace(
|
||||||
|
// ['<USER>', '<ID>', '<NSFW>'],
|
||||||
|
// [$user->username, $video->id, $nsfw],
|
||||||
|
// $message
|
||||||
|
// );
|
||||||
|
|
||||||
|
// $token = config('matrix.token');
|
||||||
|
// $homeserver = config('matrix.homeserver');
|
||||||
|
// $room = config('matrix.room');
|
||||||
|
|
||||||
|
|
||||||
|
// exec("curl -v -XPOST -d '$payload' '$homeserver$room/send/m.room.message?access_token=$token' > /dev/null &");
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
return new JsonResponse([
|
return new JsonResponse([
|
||||||
'error' => 'null',
|
'error' => 'null',
|
||||||
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'enabled' => true,
|
'enabled' => true,
|
||||||
'homeserver' => env('MATRIX_HOMESERVER'),
|
'mauauth' => env('MATRIX_MAUAUTH'),
|
||||||
'room' => env('MATRIX_ROOMID'),
|
'mauurl' => env('MATRIX_MAUURL')
|
||||||
'token' => env('MATRIX_TOKEN'),
|
|
||||||
'message' => '<USER> uploaded a new <NSFW> webm: https://w0bm.com/<ID>',
|
|
||||||
];
|
];
|
||||||
|
Reference in New Issue
Block a user