Update ApiV1Controller, improve statusesById perf and dispatch CommentPipeline job when applicable

This commit is contained in:
Daniel Supernault 2021-12-10 22:03:33 -07:00
parent b6b0837f49
commit 466286af92
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -42,6 +42,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Http\Controllers\StatusController; use App\Http\Controllers\StatusController;
use App\Jobs\AvatarPipeline\AvatarOptimize; use App\Jobs\AvatarPipeline\AvatarOptimize;
use App\Jobs\CommentPipeline\CommentPipeline;
use App\Jobs\LikePipeline\LikePipeline; use App\Jobs\LikePipeline\LikePipeline;
use App\Jobs\SharePipeline\SharePipeline; use App\Jobs\SharePipeline\SharePipeline;
use App\Jobs\StatusPipeline\NewStatusPipeline; use App\Jobs\StatusPipeline\NewStatusPipeline;
@ -1799,9 +1800,9 @@ class ApiV1Controller extends Controller
} }
} }
$resource = new Fractal\Resource\Item($status, new StatusTransformer()); $res = StatusService::get($status->id);
$res = $this->fractal->createData($resource)->toArray(); $res['favourited'] = LikeService::liked($user->profile_id, $status->id);
$res['reblogged'] = false;
return response()->json($res); return response()->json($res);
} }
@ -2114,6 +2115,9 @@ class ApiV1Controller extends Controller
} }
NewStatusPipeline::dispatch($status); NewStatusPipeline::dispatch($status);
if($status->in_reply_to_id) {
CommentPipeline::dispatch($parent, $status);
}
Cache::forget('user:account:id:'.$user->id); Cache::forget('user:account:id:'.$user->id);
Cache::forget('_api:statuses:recent_9:'.$user->profile_id); Cache::forget('_api:statuses:recent_9:'.$user->profile_id);
Cache::forget('profile:status_count:'.$user->profile_id); Cache::forget('profile:status_count:'.$user->profile_id);