forked from mirror/pixelfed
Update FederationController
This commit is contained in:
parent
93c9ce2ff4
commit
2bc7f9f7d0
1 changed files with 19 additions and 47 deletions
|
@ -34,47 +34,22 @@ class FederationController extends Controller
|
||||||
abort_if(!Auth::check(), 403);
|
abort_if(!Auth::check(), 403);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated, remove in 0.10
|
||||||
public function authorizeFollow(Request $request)
|
public function authorizeFollow(Request $request)
|
||||||
{
|
{
|
||||||
$this->authCheck();
|
abort(404);
|
||||||
$this->validate($request, [
|
|
||||||
'acct' => 'required|string|min:3|max:255',
|
|
||||||
]);
|
|
||||||
$acct = $request->input('acct');
|
|
||||||
$nickname = Nickname::normalizeProfileUrl($acct);
|
|
||||||
|
|
||||||
return view('federation.authorizefollow', compact('acct', 'nickname'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated, remove in 0.10
|
||||||
public function remoteFollow()
|
public function remoteFollow()
|
||||||
{
|
{
|
||||||
$this->authCheck();
|
abort(404);
|
||||||
|
|
||||||
return view('federation.remotefollow');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// deprecated, remove in 0.10
|
||||||
public function remoteFollowStore(Request $request)
|
public function remoteFollowStore(Request $request)
|
||||||
{
|
{
|
||||||
return;
|
abort(404);
|
||||||
|
|
||||||
$this->authCheck();
|
|
||||||
$this->validate($request, [
|
|
||||||
'url' => 'required|string',
|
|
||||||
]);
|
|
||||||
|
|
||||||
abort_if(!config('federation.activitypub.remoteFollow'), 403);
|
|
||||||
|
|
||||||
$follower = Auth::user()->profile;
|
|
||||||
$url = $request->input('url');
|
|
||||||
$url = Helpers::validateUrl($url);
|
|
||||||
|
|
||||||
if(!$url) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoteFollowPipeline::dispatch($follower, $url);
|
|
||||||
|
|
||||||
return response(['success' => true, 'follower' => $follower]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nodeinfoWellKnown()
|
public function nodeinfoWellKnown()
|
||||||
|
@ -162,10 +137,12 @@ class FederationController extends Controller
|
||||||
$this->validate($request, ['resource'=>'required|string|min:3|max:255']);
|
$this->validate($request, ['resource'=>'required|string|min:3|max:255']);
|
||||||
|
|
||||||
$resource = $request->input('resource');
|
$resource = $request->input('resource');
|
||||||
$hash = hash('sha256', $resource);
|
|
||||||
$parsed = Nickname::normalizeProfileUrl($resource);
|
$parsed = Nickname::normalizeProfileUrl($resource);
|
||||||
|
if($parsed['domain'] !== config('pixelfed.domain.app')) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
$username = $parsed['username'];
|
$username = $parsed['username'];
|
||||||
$profile = Profile::whereUsername($username)->firstOrFail();
|
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
||||||
if($profile->status != null) {
|
if($profile->status != null) {
|
||||||
return ProfileController::accountCheck($profile);
|
return ProfileController::accountCheck($profile);
|
||||||
}
|
}
|
||||||
|
@ -315,19 +292,16 @@ class FederationController extends Controller
|
||||||
->whereIsPrivate(false)
|
->whereIsPrivate(false)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
return [];
|
|
||||||
|
|
||||||
if($profile->status != null) {
|
if($profile->status != null) {
|
||||||
return [];
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = [
|
$obj = [
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => $request->getUri(),
|
'id' => $request->getUri(),
|
||||||
'type' => 'OrderedCollectionPage',
|
'type' => 'OrderedCollectionPage',
|
||||||
'totalItems' => $profile->following()->count(),
|
'totalItems' => 0,
|
||||||
'orderedItems' => $profile->following->map(function($f) {
|
'orderedItems' => []
|
||||||
return $f->permalink();
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
return response()->json($obj);
|
return response()->json($obj);
|
||||||
}
|
}
|
||||||
|
@ -341,20 +315,18 @@ class FederationController extends Controller
|
||||||
->whereIsPrivate(false)
|
->whereIsPrivate(false)
|
||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
return [];
|
|
||||||
|
|
||||||
if($profile->status != null) {
|
if($profile->status != null) {
|
||||||
return [];
|
abort(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj = [
|
$obj = [
|
||||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'id' => $request->getUri(),
|
'id' => $request->getUri(),
|
||||||
'type' => 'OrderedCollectionPage',
|
'type' => 'OrderedCollectionPage',
|
||||||
'totalItems' => $profile->followers()->count(),
|
'totalItems' => 0,
|
||||||
'orderedItems' => $profile->followers->map(function($f) {
|
'orderedItems' => []
|
||||||
return $f->permalink();
|
|
||||||
})
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return response()->json($obj);
|
return response()->json($obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue