mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-31 03:13:04 +00:00
Update Inbox, handle Accept.Follow
This commit is contained in:
parent
5f03dfa05b
commit
ad4a36affd
1 changed files with 32 additions and 21 deletions
|
@ -15,6 +15,7 @@ use App\{
|
|||
use Carbon\Carbon;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use App\Jobs\LikePipeline\LikePipeline;
|
||||
use App\Jobs\FollowPipeline\FollowPipeline;
|
||||
|
||||
use App\Util\ActivityPub\Validator\{
|
||||
Accept,
|
||||
|
@ -243,30 +244,40 @@ class Inbox
|
|||
|
||||
public function handleAcceptActivity()
|
||||
{
|
||||
return;
|
||||
|
||||
|
||||
$actor = $this->payload['actor'];
|
||||
$obj = $this->payload['object'];
|
||||
switch ($obj['type']) {
|
||||
case 'Follow':
|
||||
$accept = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $target->permalink().'#accepts/follows/' . $follower->id,
|
||||
'type' => 'Accept',
|
||||
'actor' => $target->permalink(),
|
||||
'object' => [
|
||||
'id' => $actor->permalink('#follows/'.$target->id),
|
||||
'type' => 'Follow',
|
||||
'actor' => $actor->permalink(),
|
||||
'object' => $target->permalink()
|
||||
]
|
||||
];
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
$type = $this->payload['object']['type'];
|
||||
|
||||
if($type !== 'Follow') {
|
||||
return;
|
||||
}
|
||||
|
||||
$actor = Helpers::validateUrl($actor);
|
||||
$target = Helpers::validateLocalUrl($obj);
|
||||
|
||||
if(!$actor || !$target) {
|
||||
return;
|
||||
}
|
||||
$actor = Helpers::profileFetch($actor);
|
||||
$target = Helpers::profileFetch($target);
|
||||
|
||||
$request = FollowRequest::whereFollowerId($actor->id)
|
||||
->whereFollowingId($target->id)
|
||||
->whereIsRejected(false)
|
||||
->first();
|
||||
|
||||
if(!$request) {
|
||||
return;
|
||||
}
|
||||
|
||||
$follower = new Follower();
|
||||
$follower->profile_id = $actor->id;
|
||||
$follower->following_id = $target->id;
|
||||
$follower->save();
|
||||
FollowPipeline::dispatch($follower);
|
||||
|
||||
$request->delete();
|
||||
}
|
||||
|
||||
public function handleDeleteActivity()
|
||||
|
|
Loading…
Reference in a new issue