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); $payload = json_decode($this->payload, true, 8);
if(isset($payload['id'])) { 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) { if(Cache::get($lockKey) !== null) {
// Job processed already // Job processed already
return 1; return 1;

View file

@ -57,7 +57,7 @@ class InboxWorker implements ShouldQueue
$payload = json_decode($this->payload, true, 8); $payload = json_decode($this->payload, true, 8);
if(isset($payload['id'])) { 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) { if(Cache::get($lockKey) !== null) {
// Job processed already // Job processed already
return 1; return 1;

View file

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

View file

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