diff --git a/app/Http/Controllers/VideoController.php b/app/Http/Controllers/VideoController.php index 98c38ce..cc165a3 100644 --- a/app/Http/Controllers/VideoController.php +++ b/app/Http/Controllers/VideoController.php @@ -147,24 +147,25 @@ class VideoController extends Controller $video->tesThumb(); // Discord - if (config('discord.enabled') && config('discord.webhookurl')) { - $nsfw = in_array('nsfw', $video->getTagArrayNormalizedAttribute()); - $nsfw = $nsfw ? ' :exclamation: **NSFW** :exclamation:' : ''; - $message = config('discord.message'); - $message = str_replace( - ['', '', ''], - [$user->username, $video->id, $nsfw], - $message - ); - $url = config('discord.webhookurl'); - $payload = json_encode([ - 'content' => $message, - ]); - // exec with & so it is async - exec("curl -H \"Content-Type: application/json; charset=UTF-8\" -X POST -d '$payload' '$url' > /dev/null &"); - } + // if (config('discord.enabled') && config('discord.webhookurl')) { + // $nsfw = in_array('nsfw', $video->getTagArrayNormalizedAttribute()); + // $nsfw = $nsfw ? ' :exclamation: **NSFW** :exclamation:' : ''; + // $message = config('discord.message'); + // $message = str_replace( + // ['', '', ''], + // [$user->username, $video->id, $nsfw], + // $message + // ); + // $url = config('discord.webhookurl'); + // $payload = json_encode([ + // 'content' => $message, + // ]); + // // exec with & so it is async + // exec("curl -H \"Content-Type: application/json; charset=UTF-8\" -X POST -d '$payload' '$url' > /dev/null &"); + // } - if (config('matrix.enabled') && config('matrix.roomid')) { + + if (config('matrix.enabled') && config('matrix.token') && config('matrix.homeserver') && config('matrix.room')) { $nsfw = in_array('nsfw', $video->getTagArrayNormalizedAttribute()); $nsfw = $nsfw ? ' :exclamation: **NSFW** :exclamation:' : ''; $message = config('matrix.message'); @@ -173,14 +174,17 @@ class VideoController extends Controller [$user->username, $video->id, $nsfw], $message ); - $room = "DBWMqijxlNIUIjBNdM:f0ck.it"; - $url = "https://f0ck.it/_matrix/client/r0/rooms/%21DBWMqijxlNIUIjBNdM:f0ck.it/send/m.room.message?access_token=syt_bml4Yw_yIqaTxnQHQBzeYnHusNi_3Th9Pn"; + + $token = config('matrix.token'); + $homeserver = config('matrix.homeserver'); + $room = config('matrix.room'); $payload = json_encode([ - 'content' => $message, + "msgtype" => "m.text", + "body" => $message ]); - exec("curl -X POST -d '{ 'msgtype : m.text', 'body: $payload'}' '$url' > /dev/null &"); + exec("curl -v -XPOST -d '$payload' '$homeserver$room/send/m.room.message?access_token=$token' > /dev/null &"); } diff --git a/app/Http/Controllers/tmp/test.png b/app/Http/Controllers/tmp/test.png index e264753..0f88676 100644 Binary files a/app/Http/Controllers/tmp/test.png and b/app/Http/Controllers/tmp/test.png differ diff --git a/blah.log b/blah.log new file mode 100644 index 0000000..90e526e --- /dev/null +++ b/blah.log @@ -0,0 +1 @@ +{"errcode":"M_UNKNOWN","error":"'body' not a string type"} \ No newline at end of file diff --git a/blah2.log b/blah2.log new file mode 100644 index 0000000..1016a60 --- /dev/null +++ b/blah2.log @@ -0,0 +1 @@ +{"event_id":"$RcOS8ZN5HNujEnr9cEjFb-2UJ3A7pj0rSm4RiSZ9WIk"} \ No newline at end of file diff --git a/config/matrix.php b/config/matrix.php index a930465..bc9db13 100644 --- a/config/matrix.php +++ b/config/matrix.php @@ -1,6 +1,8 @@ true, - 'webhookurl' => env('matrix_WEBHOOK', false), + 'homeserver' => env('MATRIX_HOMESERVER'), + 'room' => env('MATRIX_ROOMID'), + 'token' => env('MATRIX_TOKEN'), 'message' => ' uploaded a new webm: https://w0bm.com/', ];