Fix broken day GET

cache
Varun Patil 2022-10-06 13:37:12 -07:00
parent 5a250818a5
commit 4c38124ac8
3 changed files with 15 additions and 10 deletions

View File

@ -18,8 +18,8 @@ return [
// API
['name' => 'api#days', 'url' => '/api/days', 'verb' => 'GET'],
['name' => 'api#dayPost', 'url' => '/api/days', 'verb' => 'POST'],
['name' => 'api#day', 'url' => '/api/days/{id}', 'verb' => 'GET'],
['name' => 'api#day', 'url' => '/api/days/{id}', 'verb' => 'POST'],
['name' => 'api#imageInfo', 'url' => '/api/info/{id}', 'verb' => 'GET'],
['name' => 'api#imageEdit', 'url' => '/api/edit/{id}', 'verb' => 'PATCH'],
['name' => 'api#archive', 'url' => '/api/archive/{id}', 'verb' => 'PATCH'],

View File

@ -171,6 +171,19 @@ class ApiController extends Controller {
return new JSONResponse($list, Http::STATUS_OK);
}
/**
* @NoAdminRequired
*
* @return JSONResponse
*/
public function dayPost(): JSONResponse {
$id = $this->request->getParam('body_ids');
if (is_null($id)) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}
return $this->day($id);
}
/**
* @NoAdminRequired
*
@ -183,14 +196,6 @@ class ApiController extends Controller {
}
$uid = $user->getUID();
// Check if post request
if ($this->request->getMethod() === 'POST') {
$id = $this->request->getParam('body_ids');
if (is_null($id)) {
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
}
}
// Split at commas and convert all parts to int
$day_ids = array_map(function ($part) {
return intval($part);

View File

@ -394,7 +394,7 @@ export async function getOnThisDayData() {
// Query for photos
let data: IPhoto[] = [];
try {
const res = await axios.post<IPhoto[]>(generateUrl('/apps/memories/api/days/BODY'), {
const res = await axios.post<IPhoto[]>(generateUrl('/apps/memories/api/days'), {
body_ids: Object.keys(diffs).join(','),
});
data = res.data;