1
0
Fork 0

Update CommentPipeline

This commit is contained in:
Daniel Supernault 2019-05-20 21:35:09 -06:00
parent 519c05de32
commit 777b103288
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
1 changed files with 11 additions and 15 deletions

View File

@ -2,16 +2,18 @@
namespace App\Jobs\CommentPipeline; namespace App\Jobs\CommentPipeline;
use App\Notification; use App\{
use App\Status; Notification,
use Cache; Status
};
use App\Services\NotificationService;
use DB, Cache, Log, Redis;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Log;
use Redis;
class CommentPipeline implements ShouldQueue class CommentPipeline implements ShouldQueue
{ {
@ -55,7 +57,7 @@ class CommentPipeline implements ShouldQueue
return true; return true;
} }
try { DB::transaction(function() use($target, $actor, $comment) {
$notification = new Notification(); $notification = new Notification();
$notification->profile_id = $target->id; $notification->profile_id = $target->id;
$notification->actor_id = $actor->id; $notification->actor_id = $actor->id;
@ -66,14 +68,8 @@ class CommentPipeline implements ShouldQueue
$notification->item_type = "App\Status"; $notification->item_type = "App\Status";
$notification->save(); $notification->save();
Cache::forever('notification.'.$notification->id, $notification); NotificationService::setNotification($notification);
NotificationService::set($notification->profile_id, $notification->id);
$redis = Redis::connection(); });
$nkey = config('cache.prefix').':user.'.$target->id.'.notifications';
$redis->lpush($nkey, $notification->id);
} catch (Exception $e) {
Log::error($e);
}
} }
} }