Commit 8d749533 authored by Sean O'Donnell's avatar Sean O'Donnell

Notifications for followers

parent a15ae67e
......@@ -14,6 +14,8 @@ use Log;
use App\UserFollow;
use Event;
use App\Events\UserFollowed;
use App\Notifications\FollowerProcessed;
class ListenController extends Controller
{
......@@ -32,14 +34,7 @@ class ListenController extends Controller
}
// If no challenge assume that we are being sent a follower
$userfollow = UserFollow::where('notification_id', $r->input('id'))->first();
if($userfollow)
{
Log::info("A follow by that ID has already been generated");
return response(200);
}
if(UserFollow::where('user_id', $r->input('data')['to_id'])->where('from_id', $r->input('data')['from_id'])->first())
{
Log::info("A follow by that twitch id and follower id has already been in the system before");
if($userfollow || UserFollow::where('user_id', $r->input('data')['to_id'])->where('from_id', $r->input('data')['from_id'])->first()){
return response(200);
}
......@@ -50,8 +45,8 @@ class ListenController extends Controller
'type' => $r->input('type'),
'from_id' => $r->input('data')['from_id']
]);
$userfollow->notify(new FollowerProcessed($userfollow));
Event::fire(new UserFollowed());
Log::info('User Follow Created' . $userfollow->id);
return response(200);
}
......
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