mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-20 05:21:27 +00:00
commit
51364826ee
3 changed files with 7 additions and 124 deletions
|
@ -70,58 +70,6 @@ class InboxValidator implements ShouldQueue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $payload['type'] === 'Delete' &&
|
|
||||||
( ( is_string($payload['object']) &&
|
|
||||||
$payload['object'] === $payload['actor'] ) ||
|
|
||||||
( is_array($payload['object']) &&
|
|
||||||
isset($payload['object']['id'], $payload['object']['type']) &&
|
|
||||||
$payload['object']['type'] === 'Person' &&
|
|
||||||
$payload['actor'] === $payload['object']['id']
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
$actor = $payload['actor'];
|
|
||||||
$hash = strlen($actor) <= 48 ?
|
|
||||||
'b:' . base64_encode($actor) :
|
|
||||||
'h:' . hash('sha256', $actor);
|
|
||||||
|
|
||||||
$lockKey = 'ap:inbox:actor-delete-exists:lock:' . $hash;
|
|
||||||
Cache::lock($lockKey, 10)->block(5, function () use(
|
|
||||||
$headers,
|
|
||||||
$payload,
|
|
||||||
$actor,
|
|
||||||
$hash,
|
|
||||||
$profile
|
|
||||||
) {
|
|
||||||
$key = 'ap:inbox:actor-delete-exists:' . $hash;
|
|
||||||
$actorDelete = Cache::remember($key, now()->addMinutes(15), function() use($actor) {
|
|
||||||
return Profile::whereRemoteUrl($actor)
|
|
||||||
->whereNotNull('domain')
|
|
||||||
->exists();
|
|
||||||
});
|
|
||||||
if($actorDelete) {
|
|
||||||
if($this->verifySignature($headers, $profile, $payload) == true) {
|
|
||||||
Cache::set($key, false);
|
|
||||||
$profile = Profile::whereNotNull('domain')
|
|
||||||
->whereNull('status')
|
|
||||||
->whereRemoteUrl($actor)
|
|
||||||
->first();
|
|
||||||
if($profile) {
|
|
||||||
DeleteRemoteProfilePipeline::dispatchNow($profile);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// Signature verification failed, exit.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Remote user doesn't exist, exit early.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($profile->status != null) {
|
if($profile->status != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,57 +66,6 @@ class InboxWorker implements ShouldQueue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( $payload['type'] === 'Delete' &&
|
|
||||||
( ( is_string($payload['object']) &&
|
|
||||||
$payload['object'] === $payload['actor'] ) ||
|
|
||||||
( is_array($payload['object']) &&
|
|
||||||
isset($payload['object']['id'], $payload['object']['type']) &&
|
|
||||||
$payload['object']['type'] === 'Person' &&
|
|
||||||
$payload['actor'] === $payload['object']['id']
|
|
||||||
))
|
|
||||||
) {
|
|
||||||
$actor = $payload['actor'];
|
|
||||||
$hash = strlen($actor) <= 48 ?
|
|
||||||
'b:' . base64_encode($actor) :
|
|
||||||
'h:' . hash('sha256', $actor);
|
|
||||||
|
|
||||||
$lockKey = 'ap:inbox:actor-delete-exists:lock:' . $hash;
|
|
||||||
Cache::lock($lockKey, 10)->block(5, function () use(
|
|
||||||
$headers,
|
|
||||||
$payload,
|
|
||||||
$actor,
|
|
||||||
$hash
|
|
||||||
) {
|
|
||||||
$key = 'ap:inbox:actor-delete-exists:' . $hash;
|
|
||||||
$actorDelete = Cache::remember($key, now()->addMinutes(15), function() use($actor) {
|
|
||||||
return Profile::whereRemoteUrl($actor)
|
|
||||||
->whereNotNull('domain')
|
|
||||||
->exists();
|
|
||||||
});
|
|
||||||
if($actorDelete) {
|
|
||||||
if($this->verifySignature($headers, $payload) == true) {
|
|
||||||
Cache::set($key, false);
|
|
||||||
$profile = Profile::whereNotNull('domain')
|
|
||||||
->whereNull('status')
|
|
||||||
->whereRemoteUrl($actor)
|
|
||||||
->first();
|
|
||||||
if($profile) {
|
|
||||||
DeleteRemoteProfilePipeline::dispatchNow($profile);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
// Signature verification failed, exit.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Remote user doesn't exist, exit early.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->verifySignature($headers, $payload) == true) {
|
if($this->verifySignature($headers, $payload) == true) {
|
||||||
(new Inbox($headers, $profile, $payload))->handle();
|
(new Inbox($headers, $profile, $payload))->handle();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -419,19 +419,6 @@ class Helpers {
|
||||||
$cw = true;
|
$cw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$statusLockKey = 'helpers:status-lock:' . hash('sha256', $res['id']);
|
|
||||||
$status = Cache::lock($statusLockKey)
|
|
||||||
->get(function () use(
|
|
||||||
$profile,
|
|
||||||
$res,
|
|
||||||
$url,
|
|
||||||
$ts,
|
|
||||||
$reply_to,
|
|
||||||
$cw,
|
|
||||||
$scope,
|
|
||||||
$id
|
|
||||||
) {
|
|
||||||
|
|
||||||
if($res['type'] === 'Question') {
|
if($res['type'] === 'Question') {
|
||||||
$status = self::storePoll(
|
$status = self::storePoll(
|
||||||
$profile,
|
$profile,
|
||||||
|
@ -444,11 +431,10 @@ class Helpers {
|
||||||
$id
|
$id
|
||||||
);
|
);
|
||||||
return $status;
|
return $status;
|
||||||
|
} else {
|
||||||
|
$status = self::storeStatus($url, $profile, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::storeStatus($url, $profile, $res);
|
|
||||||
});
|
|
||||||
|
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue