Update ApiV1Controller, fix instance endpoint

This commit is contained in:
Daniel Supernault 2022-03-22 21:56:22 -06:00
parent c0ae0e9267
commit c383f1008d
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7
2 changed files with 30 additions and 3 deletions

View file

@ -1236,11 +1236,13 @@ class ApiV1Controller extends Controller
'description' => 'Pixelfed is an image sharing platform, an ethical alternative to centralized platforms',
'email' => config('instance.email'),
'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') .')',
'urls' => [],
'urls' => [
'streaming_api' => 'wss://' . config('pixelfed.domain.app')
],
'stats' => $stats,
'thumbnail' => url('headers/default.jpg'),
'thumbnail' => url('img/pixelfed-icon-color.png'),
'languages' => ['en'],
'registrations' => (bool) config('pixelfed.open_registration'),
'registrations' => (bool) config_cache('pixelfed.open_registration'),
'approval_required' => false,
'contact_account' => $contact,
'rules' => $rules
@ -1434,6 +1436,30 @@ class ApiV1Controller extends Controller
return response()->json($res);
}
/**
* GET /api/v1/media/{id}
*
* @param integer $id
*
* @return MediaTransformer
*/
public function mediaGet(Request $request, $id)
{
abort_if(!$request->user(), 403);
$user = $request->user();
$media = Media::whereUserId($user->id)
->whereNull('status_id')
->findOrFail($id);
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
$res = $this->fractal->createData($resource)->toArray();
$res['preview_url'] = url('/storage/no-preview.png');
$res['url'] = url('/storage/no-preview.png');
return response()->json($res);
}
/**
* GET /api/v1/mutes
*

View file

@ -24,6 +24,7 @@ class AccountTransformer extends Fractal\TransformerAbstract
'username' => $username,
'acct' => $acct,
'display_name' => $profile->name,
'discoverable' => true,
'locked' => (bool) $profile->is_private,
'followers_count' => (int) $profile->followerCount(),
'following_count' => (int) $profile->followingCount(),