Commit a15ae67e authored by Sean O'Donnell's avatar Sean O'Donnell

Notification for followers

parent 2809e8f6
......@@ -45,7 +45,7 @@ class updateTwitchLease extends Command
{
foreach(User::where('twitch_id', '!=', null)->get() as $user)
{
Log::info("Getting lease for followers for user: " . $user->id);
Log::info("Getting lease for followers for user (CRON TASK): " . $user->id);
$ch = curl_init();
/*
hub.mode = Subscribe/Unsubscribe, we're always going to be subscribing, doing it more than once doesn't seem to matter.
......@@ -73,7 +73,9 @@ class updateTwitchLease extends Command
));
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
Log::info($response);
if($http_status == '429'){
sleep(60);
}
curl_close($ch);
}
}
......
......@@ -7,6 +7,7 @@ use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use App\Notifications\FollowerProcessed;
use App\UserFollow;
use App\User;
use Log;
......@@ -67,6 +68,7 @@ class ProcessFollowers implements ShouldQueue
'updated_at' => Carbon::parse($c->followed_at),
'from_display_name' => $c->from_name
]);
$userFollowAdded->notify(new FollowerProcessed($userFollowAdded));
}
}
......@@ -77,6 +79,7 @@ class ProcessFollowers implements ShouldQueue
$this->dispatch($twitch_id, $pagination);
}
return 'Followers Added ';
......
......@@ -59,11 +59,11 @@ class FollowerProcessed extends Notification
];
}
public function toSlack()
public function toSlack($notifiable)
{
return (new SlackMessage)
->from('Production')
->to('#notify-followers')
->content('Someone just Followed');
->from('Production')
->to('#notify-followers')
->content('Someone just Followed');
}
}
......@@ -2,11 +2,15 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class UserFollow extends Model
{
use Notifiable;
/**
* The database table used by the model.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment