Add media endpoint support for the source parameter
This commit is contained in:
parent
8e4e09c38f
commit
ae2c45ff3d
2 changed files with 97 additions and 0 deletions
|
@ -63,6 +63,30 @@ class MicropubMediaController extends Controller
|
|||
|
||||
return response()->json(['url' => $media->url]);
|
||||
}
|
||||
|
||||
if (request()->input('q') === 'source') {
|
||||
$limit = request()->input('limit', 10);
|
||||
$offset = request()->input('offset', 0);
|
||||
|
||||
$media = Media::latest()->offset($offset)->limit($limit)->get();
|
||||
|
||||
$media->transform(function ($mediaItem) {
|
||||
return [
|
||||
'url' => $mediaItem->url,
|
||||
];
|
||||
});
|
||||
|
||||
return response()->json(['items' => $media]);
|
||||
}
|
||||
|
||||
if (request()->has('q')) {
|
||||
return response()->json([
|
||||
'error' => 'invalid_request',
|
||||
'error_description' => 'This server does not know how to handle this q parameter (' . request()->input('q') . ')',
|
||||
], 400);
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'OK']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue