Update FederationController

This commit is contained in:
Daniel Supernault 2019-07-15 19:22:48 -06:00
parent 93c9ce2ff4
commit 2bc7f9f7d0
No known key found for this signature in database
GPG key ID: 0DEF1C662C9033F7

View file

@ -34,47 +34,22 @@ class FederationController extends Controller
abort_if(!Auth::check(), 403);
}
// deprecated, remove in 0.10
public function authorizeFollow(Request $request)
{
$this->authCheck();
$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'));
abort(404);
}
// deprecated, remove in 0.10
public function remoteFollow()
{
$this->authCheck();
return view('federation.remotefollow');
abort(404);
}
// deprecated, remove in 0.10
public function remoteFollowStore(Request $request)
{
return;
$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]);
abort(404);
}
public function nodeinfoWellKnown()
@ -162,10 +137,12 @@ class FederationController extends Controller
$this->validate($request, ['resource'=>'required|string|min:3|max:255']);
$resource = $request->input('resource');
$hash = hash('sha256', $resource);
$parsed = Nickname::normalizeProfileUrl($resource);
if($parsed['domain'] !== config('pixelfed.domain.app')) {
abort(404);
}
$username = $parsed['username'];
$profile = Profile::whereUsername($username)->firstOrFail();
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
if($profile->status != null) {
return ProfileController::accountCheck($profile);
}
@ -315,19 +292,16 @@ class FederationController extends Controller
->whereIsPrivate(false)
->firstOrFail();
return [];
if($profile->status != null) {
return [];
abort(404);
}
$obj = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(),
'type' => 'OrderedCollectionPage',
'totalItems' => $profile->following()->count(),
'orderedItems' => $profile->following->map(function($f) {
return $f->permalink();
})
'totalItems' => 0,
'orderedItems' => []
];
return response()->json($obj);
}
@ -341,20 +315,18 @@ class FederationController extends Controller
->whereIsPrivate(false)
->firstOrFail();
return [];
if($profile->status != null) {
return [];
abort(404);
}
$obj = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $request->getUri(),
'type' => 'OrderedCollectionPage',
'totalItems' => $profile->followers()->count(),
'orderedItems' => $profile->followers->map(function($f) {
return $f->permalink();
})
'totalItems' => 0,
'orderedItems' => []
];
return response()->json($obj);
}
}