]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/ChatLog.php
track twitch category where chats were sent in
[alttp.git] / app / Models / ChatLog.php
index d5fc76d9325c565b803ec16eaa92c465366822ac..41bdcc506653a1727e7e13af8f4cafab2df617be 100644 (file)
@@ -97,7 +97,6 @@ class ChatLog extends Model {
 
        protected function evaluateChannel() {
                if (empty($this->params)) {
-                       $this->channel()->associate(null);
                        return;
                }
                $cname = $this->params[0];
@@ -105,7 +104,12 @@ class ChatLog extends Model {
                        $cname = '#'.$cname;
                }
                $channel = Channel::firstWhere('twitch_chat', '=', $cname);
-               $this->channel()->associate($channel);
+               if (!is_null($channel)) {
+                       $this->channel()->associate($channel);
+                       if (now()->sub(5, 'minute')->isBefore($this->created_at)) {
+                               $this->twitch_category = $channel->twitch_category;
+                       }
+               }
        }
 
        protected function detectLanguage() {