Fix unlisted post web redirect and api response

This commit is contained in:
Daniel Supernault 2022-08-13 22:51:02 -06:00
parent 877608db47
commit 6033d83726
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
3 changed files with 11 additions and 2 deletions

View file

@ -118,7 +118,9 @@ class PublicApiController extends Controller
$status = Status::whereProfileId($profile->id)->findOrFail($postid); $status = Status::whereProfileId($profile->id)->findOrFail($postid);
$this->scopeCheck($profile, $status); $this->scopeCheck($profile, $status);
if(!$request->user()) { if(!$request->user()) {
$res = ['status' => StatusService::get($status->id)]; $cached = StatusService::get($status->id, false);
abort_if(!in_array($cached['visibility'], ['public', 'unlisted']), 403);
$res = ['status' => $cached];
} else { } else {
$item = new Fractal\Resource\Item($status, new StatusStatelessTransformer()); $item = new Fractal\Resource\Item($status, new StatusStatelessTransformer());
$res = [ $res = [

View file

@ -27,7 +27,11 @@ class SpaController extends Controller
return view('layouts.spa'); return view('layouts.spa');
} }
$post = StatusService::get($id); $post = StatusService::get($id, false);
if($post && !in_array($post['visibility'], ['public', 'unlisted'])) {
return redirect('/login');
}
if( if(
$post && $post &&

View file

@ -6,6 +6,7 @@ use App\AccountInterstitial;
use App\Status; use App\Status;
use Cache; use Cache;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Services\StatusService;
class Bouncer { class Bouncer {
@ -134,6 +135,8 @@ class Bouncer {
// $status->is_nsfw = true; // $status->is_nsfw = true;
$status->save(); $status->save();
StatusService::del($status->id);
Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id); Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id);
Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id); Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id);
} }