From 0a9a98973db60895dcab511db03e34de5569ccf1 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Jul 2019 19:00:14 -0600 Subject: [PATCH 1/5] Remove OStatus legacy code --- resources/views/atom/user.blade.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/resources/views/atom/user.blade.php b/resources/views/atom/user.blade.php index 7c0c24d49..24644d953 100644 --- a/resources/views/atom/user.blade.php +++ b/resources/views/atom/user.blade.php @@ -2,25 +2,20 @@ /* Using an echo tag here so the `` won't get parsed as short tags */ ''.PHP_EOL ?> - + {{$profile->permalink('.atom')}} - {{$profile->username}} + {{$profile->username}} on Pixelfed {{$profile->bio}} {{$profile->updated_at->toAtomString()}} {{$profile->permalink()}} - http://activitystrea.ms/schema/1.0/person {{$profile->permalink()}} {{$profile->permalink()}} {{$profile->emailUrl()}} {{$profile->bio}} - {{$profile->username}} - {{$profile->name}} - {{$profile->bio}} - public From 01fd26a296657a38eb7bb577264d860b55aee49b Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Jul 2019 19:06:59 -0600 Subject: [PATCH 2/5] Remove OStatus legacy code --- app/WebSub.php | 10 ------- ...019_07_16_010525_remove_web_subs_table.php | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) delete mode 100644 app/WebSub.php create mode 100644 database/migrations/2019_07_16_010525_remove_web_subs_table.php diff --git a/app/WebSub.php b/app/WebSub.php deleted file mode 100644 index 5be3ad93f..000000000 --- a/app/WebSub.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Mon, 15 Jul 2019 19:15:30 -0600 Subject: [PATCH 3/5] Update FederationController --- app/Http/Controllers/FederationController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index f4c162ca3..743b27688 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -98,20 +98,20 @@ class FederationController extends Controller abort_if(!config('federation.nodeinfo.enabled'), 404); $res = Cache::remember('api:nodeinfo', now()->addMinutes(15), function () { - $activeHalfYear = Cache::remember('api:nodeinfo:ahy', now()->addHours(12), function() { + $activeHalfYear = Cache::remember('api:nodeinfo:ahy', now()->addHours(6), function() { $count = collect([]); - // $likes = Like::select('profile_id')->where('created_at', '>', now()->subMonths(6)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); - // $count = $count->merge($likes); + $likes = Like::select('profile_id')->where('created_at', '>', now()->subMonths(6)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); + $count = $count->merge($likes); $statuses = Status::select('profile_id')->whereLocal(true)->where('created_at', '>', now()->subMonths(6)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); $count = $count->merge($statuses); $profiles = Profile::select('id')->whereNull('domain')->where('created_at', '>', now()->subMonths(6)->toDateTimeString())->groupBy('id')->pluck('id')->toArray(); $count = $count->merge($profiles); return $count->unique()->count(); }); - $activeMonth = Cache::remember('api:nodeinfo:am', now()->addHours(12), function() { + $activeMonth = Cache::remember('api:nodeinfo:am', now()->addHours(6), function() { $count = collect([]); - // $likes = Like::select('profile_id')->where('created_at', '>', now()->subMonths(1)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); - // $count = $count->merge($likes); + $likes = Like::select('profile_id')->where('created_at', '>', now()->subMonths(1)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); + $count = $count->merge($likes); $statuses = Status::select('profile_id')->whereLocal(true)->where('created_at', '>', now()->subMonths(1)->toDateTimeString())->groupBy('profile_id')->pluck('profile_id')->toArray(); $count = $count->merge($statuses); $profiles = Profile::select('id')->whereNull('domain')->where('created_at', '>', now()->subMonths(1)->toDateTimeString())->groupBy('id')->pluck('id')->toArray(); From 2bc7f9f7d003d2d1cc4bd70278cae33e56b79daa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Jul 2019 19:22:48 -0600 Subject: [PATCH 4/5] Update FederationController --- app/Http/Controllers/FederationController.php | 66 ++++++------------- 1 file changed, 19 insertions(+), 47 deletions(-) diff --git a/app/Http/Controllers/FederationController.php b/app/Http/Controllers/FederationController.php index 743b27688..4689173b7 100644 --- a/app/Http/Controllers/FederationController.php +++ b/app/Http/Controllers/FederationController.php @@ -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); } } From 5ebbe26145c407768b1f6667e36313566326570a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Jul 2019 19:23:55 -0600 Subject: [PATCH 5/5] Remove OStatus legacy code --- resources/views/atom/user.blade.php | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/views/atom/user.blade.php b/resources/views/atom/user.blade.php index 24644d953..ec1f3594a 100644 --- a/resources/views/atom/user.blade.php +++ b/resources/views/atom/user.blade.php @@ -12,7 +12,6 @@ {{$profile->permalink()}} {{$profile->permalink()}} {{$profile->permalink()}} - {{$profile->emailUrl()}} {{$profile->bio}}