mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-23 06:51:27 +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;
|
||||||
$timeago = Carbon::now()->subMonths(6);
|
$page = $request->input('page') ?? 1;
|
||||||
$notifications = Notification::with('actor')
|
$res = Cache::remember('profile:notifications:'.$pid.':page:'.$page, 5, function() use($pid) {
|
||||||
->whereProfileId($pid)
|
$timeago = Carbon::now()->subMonths(6);
|
||||||
->whereDate('created_at', '>', $timeago)
|
$notifications = Notification::whereHas('actor')
|
||||||
->orderBy('created_at','desc')
|
->whereProfileId($pid)
|
||||||
->paginate(10);
|
->whereDate('created_at', '>', $timeago)
|
||||||
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
->orderBy('created_at','desc')
|
||||||
$res = $this->fractal->createData($resource)->toArray();
|
->paginate(10);
|
||||||
|
$resource = new Fractal\Resource\Collection($notifications, new NotificationTransformer());
|
||||||
|
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