|
@@ -19,19 +19,21 @@ class AccountService
|
|
|
|
|
|
public static function get($id, $softFail = false)
|
|
public static function get($id, $softFail = false)
|
|
{
|
|
{
|
|
- return Cache::remember(self::CACHE_KEY . $id, 43200, function() use($id, $softFail) {
|
|
|
|
|
|
+ $res = Cache::remember(self::CACHE_KEY . $id, 43200, function() use($id) {
|
|
$fractal = new Fractal\Manager();
|
|
$fractal = new Fractal\Manager();
|
|
$fractal->setSerializer(new ArraySerializer());
|
|
$fractal->setSerializer(new ArraySerializer());
|
|
$profile = Profile::find($id);
|
|
$profile = Profile::find($id);
|
|
if(!$profile || $profile->status === 'delete') {
|
|
if(!$profile || $profile->status === 'delete') {
|
|
- if($softFail) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
- abort(404);
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
|
|
return $fractal->createData($resource)->toArray();
|
|
return $fractal->createData($resource)->toArray();
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ if(!$res) {
|
|
|
|
+ return $softFail ? null : abort(404);
|
|
|
|
+ }
|
|
|
|
+ return $res;
|
|
}
|
|
}
|
|
|
|
|
|
public static function getMastodon($id, $softFail = false)
|
|
public static function getMastodon($id, $softFail = false)
|