Update StatusController to handle Moved accounts

This commit is contained in:
Daniel Supernault 2024-09-11 02:50:43 -06:00
parent 447aa1e1ea
commit 1da08feed0
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -121,7 +121,8 @@ class StatusController extends Controller
! $status || ! $status ||
! isset($status['account'], $status['account']['id'], $status['local']) || ! isset($status['account'], $status['account']['id'], $status['local']) ||
! $status['local'] || ! $status['local'] ||
strtolower($status['account']['username']) !== strtolower($username) strtolower($status['account']['username']) !== strtolower($username) ||
isset($status['account']['moved'], $status['account']['moved']['id'])
) { ) {
$content = view('status.embed-removed'); $content = view('status.embed-removed');
@ -220,10 +221,7 @@ class StatusController extends Controller
return view('status.compose'); return view('status.compose');
} }
public function store(Request $request) public function store(Request $request) {}
{
}
public function delete(Request $request) public function delete(Request $request)
{ {
@ -307,6 +305,8 @@ class StatusController extends Controller
$profile = $user->profile; $profile = $user->profile;
$status = Status::whereScope('public') $status = Status::whereScope('public')
->findOrFail($request->input('item')); ->findOrFail($request->input('item'));
$statusAccount = AccountService::get($status->profile_id);
abort_if(! $statusAccount || isset($statusAccount['moved'], $statusAccount['moved']['id']), 422, 'Account moved');
$count = $status->reblogs_count; $count = $status->reblogs_count;
@ -323,7 +323,7 @@ class StatusController extends Controller
$count--; $count--;
} }
} else { } else {
$share = new Status(); $share = new Status;
$share->profile_id = $profile->id; $share->profile_id = $profile->id;
$share->reblog_of_id = $status->id; $share->reblog_of_id = $status->id;
$share->in_reply_to_profile_id = $status->profile_id; $share->in_reply_to_profile_id = $status->profile_id;
@ -352,8 +352,8 @@ class StatusController extends Controller
return Cache::remember($key, 3600, function () use ($status) { return Cache::remember($key, 3600, function () use ($status) {
$status = Status::findOrFail($status['id']); $status = Status::findOrFail($status['id']);
$object = $status->type == 'poll' ? new Question() : new Note(); $object = $status->type == 'poll' ? new Question : new Note;
$fractal = new Fractal\Manager(); $fractal = new Fractal\Manager;
$resource = new Fractal\Resource\Item($status, $object); $resource = new Fractal\Resource\Item($status, $object);
$res = $fractal->createData($resource)->toArray(); $res = $fractal->createData($resource)->toArray();