upload notifications for matrix
This commit is contained in:
@@ -164,28 +164,36 @@ class VideoController extends Controller
|
||||
// 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')) {
|
||||
$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');
|
||||
|
||||
$mauauth = config('matrix.mauauth');
|
||||
$mauurl = config('matrix.mauurl');
|
||||
|
||||
$payload = json_encode([
|
||||
"msgtype" => "m.text",
|
||||
"body" => $message
|
||||
"user" => $user->username,
|
||||
"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([
|
||||
|
Reference in New Issue
Block a user