Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

pixelfed/pixelfed

6813 stars
2 code files
View pixelfed/pixelfed on GitHub

app/Services/ProfileService.php

Open in GitHub
use Cache;
use Illuminate\Support\Facades\Redis;
use App\Transformer\Api\AccountTransformer;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\Profile;
 
class ProfileService {
 
public static function get($id)
{
$key = 'profile:model:' . $id;
$ttl = now()->addHours(4);
$res = Cache::remember($key, $ttl, function() use($id) {
$profile = Profile::find($id);
if(!$profile) {
return false;
}
$fractal = new Fractal\Manager();
$fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
return $fractal->createData($resource)->toArray();
});
return $res;
}
 
}

app/Http/Controllers/Api/ApiV1Controller.php

Open in GitHub
use App\Http\Controllers\Controller;
se App\Services\{
LikeService,
NotificationService,
MediaPathService,
PublicTimelineService,
ProfileService,
SearchApiV2Service,
StatusService,
MediaBlocklistService
};
 
class ApiV1Controller extends Controller
{
//
public function verifyCredentials(Request $request)
{
abort_if(!$request->user(), 403);
$id = $request->user()->profile_id;
 
$res = ProfileService::get($id);
 
$res['source'] = [
'privacy' => $res['locked'] ? 'private' : 'public',
'sensitive' => false,
'language' => null,
'note' => '',
'fields' => []
];
 
return response()->json($res);
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.