mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 00:33:17 +00:00
Merge pull request #883 from pixelfed/frontend-ui-refactor
Update BaseApiController
This commit is contained in:
commit
b0049181bc
1 changed files with 19 additions and 21 deletions
|
@ -56,14 +56,17 @@ class BaseApiController extends Controller
|
||||||
public function notifications(Request $request)
|
public function notifications(Request $request)
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
|
$page = $request->input('page') ?? 1;
|
||||||
|
$res = Cache::remember('profile:notifications:'.$pid.':page:'.$page, 5, function() use($pid) {
|
||||||
$timeago = Carbon::now()->subMonths(6);
|
$timeago = Carbon::now()->subMonths(6);
|
||||||
$notifications = Notification::with('actor')
|
$notifications = Notification::whereHas('actor')
|
||||||
->whereProfileId($pid)
|
->whereProfileId($pid)
|
||||||
->whereDate('created_at', '>', $timeago)
|
->whereDate('created_at', '>', $timeago)
|
||||||
->orderBy('created_at','desc')
|
->orderBy('created_at','desc')
|
||||||
->paginate(10);
|
->paginate(10);
|
||||||
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
return $this->fractal->createData($resource)->toArray();
|
||||||
|
});
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
@ -215,6 +218,8 @@ class BaseApiController extends Controller
|
||||||
'max:' . config('pixelfed.max_photo_size'),
|
'max:' . config('pixelfed.max_photo_size'),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
'filter_name' => 'nullable|string|max:24',
|
||||||
|
'filter_class' => 'nullable|alpha_dash|max:24'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
@ -256,8 +261,8 @@ class BaseApiController extends Controller
|
||||||
$media->original_sha256 = $hash;
|
$media->original_sha256 = $hash;
|
||||||
$media->size = $photo->getSize();
|
$media->size = $photo->getSize();
|
||||||
$media->mime = $photo->getMimeType();
|
$media->mime = $photo->getMimeType();
|
||||||
$media->filter_class = null;
|
$media->filter_class = $request->input('filter_class') ?? 'filter_1977';
|
||||||
$media->filter_name = null;
|
$media->filter_name = $request->input('filter_name');
|
||||||
$media->save();
|
$media->save();
|
||||||
|
|
||||||
$url = URL::temporarySignedRoute(
|
$url = URL::temporarySignedRoute(
|
||||||
|
@ -278,17 +283,10 @@ class BaseApiController extends Controller
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$res = [
|
$resource = new Fractal\Resource\Item($media, new MediaTransformer());
|
||||||
'id' => $media->id,
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
'type' => $media->activityVerb(),
|
$res['preview_url'] = $url;
|
||||||
'url' => $url,
|
$res['url'] = $url;
|
||||||
'remote_url' => null,
|
|
||||||
'preview_url' => $url,
|
|
||||||
'text_url' => null,
|
|
||||||
'meta' => $media->metadata,
|
|
||||||
'description' => null,
|
|
||||||
];
|
|
||||||
|
|
||||||
return response()->json($res);
|
return response()->json($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue