2018-04-18 02:17:30 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
2018-11-03 02:58:26 +00:00
|
|
|
use App\{
|
|
|
|
Follower,
|
|
|
|
FollowRequest,
|
|
|
|
Profile,
|
|
|
|
UserFilter
|
|
|
|
};
|
2019-02-25 05:57:22 +00:00
|
|
|
use Auth, Cache;
|
2018-04-18 02:17:30 +00:00
|
|
|
use Illuminate\Http\Request;
|
2018-11-03 02:58:26 +00:00
|
|
|
use App\Jobs\FollowPipeline\FollowPipeline;
|
2019-06-11 03:30:01 +00:00
|
|
|
use App\Util\ActivityPub\Helpers;
|
2021-10-07 09:27:13 +00:00
|
|
|
use App\Services\FollowerService;
|
2018-04-18 02:17:30 +00:00
|
|
|
|
|
|
|
class FollowerController extends Controller
|
|
|
|
{
|
2018-05-30 02:59:10 +00:00
|
|
|
public function __construct()
|
|
|
|
{
|
2018-08-28 03:07:36 +00:00
|
|
|
$this->middleware('auth');
|
2018-05-30 02:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
2023-03-05 10:13:12 +00:00
|
|
|
abort(422, 'Deprecated API Endpoint, use /api/v1/accounts/{id}/follow or /api/v1/accounts/{id}/unfollow instead.');
|
2018-05-30 02:59:10 +00:00
|
|
|
}
|
2019-06-11 03:30:01 +00:00
|
|
|
|
2019-09-25 03:20:53 +00:00
|
|
|
public function sendFollow($user, $target)
|
2019-06-11 03:30:01 +00:00
|
|
|
{
|
|
|
|
if($target->domain == null || $user->domain != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$payload = [
|
|
|
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
2019-09-25 03:20:53 +00:00
|
|
|
'id' => $user->permalink('#follow/'.$target->id),
|
2019-06-11 03:30:01 +00:00
|
|
|
'type' => 'Follow',
|
|
|
|
'actor' => $user->permalink(),
|
|
|
|
'object' => $target->permalink()
|
|
|
|
];
|
|
|
|
|
|
|
|
$inbox = $target->sharedInbox ?? $target->inbox_url;
|
|
|
|
|
|
|
|
Helpers::sendSignedObject($user, $inbox, $payload);
|
|
|
|
}
|
2019-06-11 20:34:05 +00:00
|
|
|
|
2019-09-25 03:20:53 +00:00
|
|
|
public function sendUndoFollow($user, $target)
|
2019-06-11 20:34:05 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2018-04-18 02:17:30 +00:00
|
|
|
}
|