]> git.localhorst.tv Git - alttp.git/commitdiff
associate user with twitch command
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 8 Oct 2023 14:14:03 +0000 (16:14 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 8 Oct 2023 14:14:03 +0000 (16:14 +0200)
app/Http/Controllers/ChannelController.php
app/Models/TwitchBotCommand.php

index 904cb8ff81ebc0833fc7912aeae96a10edae2ef5..f6840f87f837f27e94dc36d4dad096d8d4a4ba17 100644 (file)
@@ -49,7 +49,7 @@ class ChannelController extends Controller {
                $this->authorize('editRestream', $channel);
                $channel->join = true;
                $channel->save();
-               TwitchBotCommand::join($channel->twitch_chat);
+               TwitchBotCommand::join($channel->twitch_chat, $request->user());
                return $channel->toJson();
        }
 
@@ -60,7 +60,7 @@ class ChannelController extends Controller {
                $this->authorize('editRestream', $channel);
                $channel->join = false;
                $channel->save();
-               TwitchBotCommand::part($channel->twitch_chat);
+               TwitchBotCommand::part($channel->twitch_chat, $request->user());
                return $channel->toJson();
        }
 
index f2b35e30657d42a1f57fc66eb9bc437df83233ea..94462e4e5798b6d7967052b2d3054a59b77f722b 100644 (file)
@@ -11,23 +11,25 @@ class TwitchBotCommand extends Model
 {
        use HasFactory;
 
-       public static function join($channel) {
+       public static function join($channel, User $user = null) {
                $cmd = new TwitchBotCommand();
                $cmd->command = 'join';
                $cmd->parameters = [
                        'channel' => $channel,
                ];
                $cmd->status = 'pending';
+               $cmd->user()->associate($user);
                $cmd->save();
        }
 
-       public static function part($channel) {
+       public static function part($channel, User $user = null) {
                $cmd = new TwitchBotCommand();
                $cmd->command = 'part';
                $cmd->parameters = [
                        'channel' => $channel,
                ];
                $cmd->status = 'pending';
+               $cmd->user()->associate($user);
                $cmd->save();
        }