Update FollowerController, send Undo Follow

This commit is contained in:
Daniel Supernault 2019-06-11 14:34:05 -06:00
parent 43073bd226
commit 37289f7935
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -86,6 +86,9 @@ class FollowerController extends Controller
FollowPipeline::dispatch($follower);
} else {
$follower = Follower::whereProfileId($user->id)->whereFollowingId($target->id)->firstOrFail();
if($remote == true) {
$this->sendUndoFollow($user, $target);
}
$follower->delete();
}
@ -115,4 +118,28 @@ class FollowerController extends Controller
Helpers::sendSignedObject($user, $inbox, $payload);
}
protected function sendUndoFollow($user, $target)
{
if($target->domain == null || $user->domain != null) {
return;
}
$payload = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $user->permalink('#follow/'.$target->id.'/undo'),
'type' => 'Undo',
'actor' => $user->permalink(),
'object' => [
'id' => $user->permalink('#follows/'.$target->id),
'actor' => $user->permalink(),
'object' => $target->permalink(),
'type' => 'Follow'
]
];
$inbox = $target->sharedInbox ?? $target->inbox_url;
Helpers::sendSignedObject($user, $inbox, $payload);
}
}