mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Update ap helpers
This commit is contained in:
parent
7066e19d0e
commit
e73b2f8373
1 changed files with 17 additions and 5 deletions
|
@ -6,6 +6,7 @@ use DB, Cache, Purify, Storage, Request, Validator;
|
|||
use App\{
|
||||
Activity,
|
||||
Follower,
|
||||
Instance,
|
||||
Like,
|
||||
Media,
|
||||
Notification,
|
||||
|
@ -174,6 +175,14 @@ class Helpers {
|
|||
}
|
||||
}
|
||||
|
||||
$bannedInstances = Cache::remember('instances:banned:domains', now()->addHours(12), function() {
|
||||
return Instance::whereBanned(true)->pluck('domain')->toArray();
|
||||
});
|
||||
|
||||
if(in_array($host, $bannedInstances)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(in_array($host, $localhosts)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -472,21 +481,24 @@ class Helpers {
|
|||
|
||||
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
||||
if(!$profile) {
|
||||
Instance::firstOrCreate([
|
||||
'domain' => $domain
|
||||
]);
|
||||
$profileLockKey = 'helpers:profile-lock:' . hash('sha256', $res['id']);
|
||||
$profile = Cache::lock($profileLockKey)->get(function () use($domain, $webfinger, $res, $runJobs) {
|
||||
return DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
||||
$profile = new Profile();
|
||||
$profile->domain = strtolower($domain);
|
||||
$profile->username = strtolower(Purify::clean($webfinger));
|
||||
$profile->username = Purify::clean($webfinger);
|
||||
$profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
||||
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
||||
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
||||
$profile->inbox_url = strtolower($res['inbox']);
|
||||
$profile->outbox_url = strtolower($res['outbox']);
|
||||
$profile->remote_url = strtolower($res['id']);
|
||||
$profile->inbox_url = $res['inbox'];
|
||||
$profile->outbox_url = $res['outbox'];
|
||||
$profile->remote_url = $res['id'];
|
||||
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
||||
$profile->key_id = $res['publicKey']['id'];
|
||||
$profile->webfinger = strtolower(Purify::clean($webfinger));
|
||||
$profile->webfinger = Purify::clean($webfinger);
|
||||
$profile->last_fetched_at = now();
|
||||
$profile->save();
|
||||
if(config('pixelfed.cloud_storage') == true) {
|
||||
|
|
Loading…
Reference in a new issue