|
|
@ -6,6 +6,7 @@ use DB, Cache, Purify, Storage, Request, Validator;
|
|
|
|
use App\{
|
|
|
|
use App\{
|
|
|
|
Activity,
|
|
|
|
Activity,
|
|
|
|
Follower,
|
|
|
|
Follower,
|
|
|
|
|
|
|
|
Instance,
|
|
|
|
Like,
|
|
|
|
Like,
|
|
|
|
Media,
|
|
|
|
Media,
|
|
|
|
Notification,
|
|
|
|
Notification,
|
|
|
@ -25,6 +26,7 @@ use App\Util\ActivityPub\HttpSignature;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
use App\Services\ActivityPubFetchService;
|
|
|
|
use App\Services\ActivityPubFetchService;
|
|
|
|
use App\Services\ActivityPubDeliveryService;
|
|
|
|
use App\Services\ActivityPubDeliveryService;
|
|
|
|
|
|
|
|
use App\Services\InstanceService;
|
|
|
|
use App\Services\MediaPathService;
|
|
|
|
use App\Services\MediaPathService;
|
|
|
|
use App\Services\MediaStorageService;
|
|
|
|
use App\Services\MediaStorageService;
|
|
|
|
use App\Jobs\MediaPipeline\MediaStoragePipeline;
|
|
|
|
use App\Jobs\MediaPipeline\MediaStoragePipeline;
|
|
|
@ -161,9 +163,9 @@ class Helpers {
|
|
|
|
|
|
|
|
|
|
|
|
$host = parse_url($valid, PHP_URL_HOST);
|
|
|
|
$host = parse_url($valid, PHP_URL_HOST);
|
|
|
|
|
|
|
|
|
|
|
|
if(count(dns_get_record($host, DNS_A | DNS_AAAA)) == 0) {
|
|
|
|
// if(count(dns_get_record($host, DNS_A | DNS_AAAA)) == 0) {
|
|
|
|
return false;
|
|
|
|
// return false;
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if(config('costar.enabled') == true) {
|
|
|
|
if(config('costar.enabled') == true) {
|
|
|
|
if(
|
|
|
|
if(
|
|
|
@ -174,6 +176,12 @@ class Helpers {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$bannedInstances = InstanceService::getBannedDomains();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(in_array($host, $bannedInstances)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(in_array($host, $localhosts)) {
|
|
|
|
if(in_array($host, $localhosts)) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -319,6 +327,7 @@ class Helpers {
|
|
|
|
$idDomain = parse_url($id, PHP_URL_HOST);
|
|
|
|
$idDomain = parse_url($id, PHP_URL_HOST);
|
|
|
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
|
|
|
$urlDomain = parse_url($url, PHP_URL_HOST);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!self::validateUrl($id)) {
|
|
|
|
if(!self::validateUrl($id)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -347,6 +356,14 @@ class Helpers {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$ts = is_array($res['published']) ? $res['published'][0] : $res['published'];
|
|
|
|
$ts = is_array($res['published']) ? $res['published'][0] : $res['published'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($scope == 'public' && in_array($urlDomain, InstanceService::getUnlistedDomains())) {
|
|
|
|
|
|
|
|
$scope = 'unlisted';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(in_array($urlDomain, InstanceService::getNsfwDomains())) {
|
|
|
|
|
|
|
|
$cw = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$statusLockKey = 'helpers:status-lock:' . hash('sha256', $res['id']);
|
|
|
|
$statusLockKey = 'helpers:status-lock:' . hash('sha256', $res['id']);
|
|
|
|
$status = Cache::lock($statusLockKey)
|
|
|
|
$status = Cache::lock($statusLockKey)
|
|
|
|
->get(function () use(
|
|
|
|
->get(function () use(
|
|
|
@ -472,21 +489,24 @@ class Helpers {
|
|
|
|
|
|
|
|
|
|
|
|
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
|
|
|
$profile = Profile::whereRemoteUrl($res['id'])->first();
|
|
|
|
if(!$profile) {
|
|
|
|
if(!$profile) {
|
|
|
|
|
|
|
|
Instance::firstOrCreate([
|
|
|
|
|
|
|
|
'domain' => $domain
|
|
|
|
|
|
|
|
]);
|
|
|
|
$profileLockKey = 'helpers:profile-lock:' . hash('sha256', $res['id']);
|
|
|
|
$profileLockKey = 'helpers:profile-lock:' . hash('sha256', $res['id']);
|
|
|
|
$profile = Cache::lock($profileLockKey)->get(function () use($domain, $webfinger, $res, $runJobs) {
|
|
|
|
$profile = Cache::lock($profileLockKey)->get(function () use($domain, $webfinger, $res, $runJobs) {
|
|
|
|
return DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
|
|
|
return DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
|
|
|
|
$profile = new Profile();
|
|
|
|
$profile = new Profile();
|
|
|
|
$profile->domain = strtolower($domain);
|
|
|
|
$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->name = isset($res['name']) ? Purify::clean($res['name']) : 'user';
|
|
|
|
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
|
|
|
$profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null;
|
|
|
|
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
|
|
|
$profile->sharedInbox = isset($res['endpoints']) && isset($res['endpoints']['sharedInbox']) ? $res['endpoints']['sharedInbox'] : null;
|
|
|
|
$profile->inbox_url = strtolower($res['inbox']);
|
|
|
|
$profile->inbox_url = $res['inbox'];
|
|
|
|
$profile->outbox_url = strtolower($res['outbox']);
|
|
|
|
$profile->outbox_url = $res['outbox'];
|
|
|
|
$profile->remote_url = strtolower($res['id']);
|
|
|
|
$profile->remote_url = $res['id'];
|
|
|
|
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
|
|
|
$profile->public_key = $res['publicKey']['publicKeyPem'];
|
|
|
|
$profile->key_id = $res['publicKey']['id'];
|
|
|
|
$profile->key_id = $res['publicKey']['id'];
|
|
|
|
$profile->webfinger = strtolower(Purify::clean($webfinger));
|
|
|
|
$profile->webfinger = Purify::clean($webfinger);
|
|
|
|
$profile->last_fetched_at = now();
|
|
|
|
$profile->last_fetched_at = now();
|
|
|
|
$profile->save();
|
|
|
|
$profile->save();
|
|
|
|
if(config('pixelfed.cloud_storage') == true) {
|
|
|
|
if(config('pixelfed.cloud_storage') == true) {
|
|
|
|