Merge pull request #3995 from pixelfed/staging

Update federation logic
This commit is contained in:
daniel 2022-12-23 23:23:37 -07:00 committed by GitHub
commit def5ac8a28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 6 deletions

View file

@ -60,7 +60,7 @@ class InboxValidator implements ShouldQueue
$payload = json_decode($this->payload, true, 8);
if(isset($payload['id'])) {
$lockKey = 'ap:icid:' . hash('sha256', $payload['id']);
$lockKey = 'pf:ap:user-inbox:activity:' . hash('sha256', $payload['id']);
if(Cache::get($lockKey) !== null) {
// Job processed already
return 1;

View file

@ -57,7 +57,7 @@ class InboxWorker implements ShouldQueue
$payload = json_decode($this->payload, true, 8);
if(isset($payload['id'])) {
$lockKey = 'ap:icid:' . hash('sha256', $payload['id']);
$lockKey = 'pf:ap:user-inbox:activity:' . hash('sha256', $payload['id']);
if(Cache::get($lockKey) !== null) {
// Job processed already
return 1;

View file

@ -373,6 +373,10 @@ class Helpers {
return;
}
if(!isset($activity['object']['attributedTo'])) {
return;
}
$attributedTo = is_string($activity['object']['attributedTo']) ?
$activity['object']['attributedTo'] :
(is_array($activity['object']['attributedTo']) ?

View file

@ -180,6 +180,8 @@ class Inbox
StoryFetch::dispatchNow($this->payload);
break;
}
return;
}
public function handleCreateActivity()
@ -267,15 +269,24 @@ class Inbox
return;
}
if($actor->followers()->count() == 0) {
if($actor->followers_count == 0) {
if(FollowerService::followerCount($actor->id, true) == 0) {
return;
}
}
$hasUrl = isset($activity['url']);
$url = isset($activity['url']) ? $activity['url'] : $activity['id'];
if(Status::whereUrl($url)->exists()) {
if($hasUrl) {
if(Status::whereUri($url)->exists()) {
return;
}
} else {
if(Status::whereObjectUrl($url)->exists()) {
return;
}
}
Helpers::storeStatus(
$url,