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