From d3eaccf7061590a1ac069e5eb42c2e39219bbe56 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 03:25:26 -0600 Subject: [PATCH 1/8] Update Two factor middleware to allow 3 attempts --- app/Http/Middleware/TwoFactorAuth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Middleware/TwoFactorAuth.php b/app/Http/Middleware/TwoFactorAuth.php index e5392281e..b59b2c31f 100644 --- a/app/Http/Middleware/TwoFactorAuth.php +++ b/app/Http/Middleware/TwoFactorAuth.php @@ -24,7 +24,7 @@ class TwoFactorAuth if($request->session()->has('2fa.session.active') !== true && !$request->is($checkpoint)) { return redirect('/i/auth/checkpoint'); - } elseif($request->session()->has('2fa.attempts') || (int) $request->session()->get('2fa.attempts') > 3) { + } elseif($request->session()->has('2fa.attempts') && (int) $request->session()->get('2fa.attempts') > 3) { $request->session()->pull('2fa.attempts'); Auth::logout(); } From d06622b7d4f51446efa54056234556bf4b013c8a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 03:30:53 -0600 Subject: [PATCH 2/8] Update tombstone handler --- app/Util/ActivityPub/Inbox.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index fdd39d61b..8cc001f01 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -307,11 +307,8 @@ class Inbox $id = $this->payload['object']['id']; switch ($type) { case 'Person': - $profile = Profile::whereNull('domain') - ->whereNull('private_key') - ->whereRemoteUrl($id) - ->first(); - if(!$profile) { + $profile = Helpers::fetchProfile($actor); + if(!$profile || $profile->private_key != null) { return; } Notification::whereActorId($profile->id)->delete(); @@ -326,11 +323,18 @@ class Inbox break; case 'Tombstone': - $status = Status::whereUri($id)->orWhere('object_url', $id)->first(); + $profile = Helpers::fetchProfile($actor); + $status = Status::whereProfileId($profile->id) + ->whereUri($id) + ->orWhereUrl($id) + ->orWhere('object_url', $id) + ->first(); if(!$status) { return; } - $status->media->delete(); + $status->media()->delete(); + $status->likes()->delete(); + $status->shares()->delete(); $status->delete(); return; break; From d85cdd13de8039a7fcf45f5d24277c34387c4deb Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 03:36:51 -0600 Subject: [PATCH 3/8] Update AP inbox --- app/Util/ActivityPub/Inbox.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index 8cc001f01..eec2290c4 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -307,7 +307,7 @@ class Inbox $id = $this->payload['object']['id']; switch ($type) { case 'Person': - $profile = Helpers::fetchProfile($actor); + $profile = Helpers::profileFetch($actor); if(!$profile || $profile->private_key != null) { return; } @@ -323,7 +323,7 @@ class Inbox break; case 'Tombstone': - $profile = Helpers::fetchProfile($actor); + $profile = Helpers::profileFetch($actor); $status = Status::whereProfileId($profile->id) ->whereUri($id) ->orWhereUrl($id) From 7c0426ab2c08a392e23faeae25805b6c9c0ea739 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 03:39:56 -0600 Subject: [PATCH 4/8] Update AP inbox --- app/Util/ActivityPub/Inbox.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index eec2290c4..052b5fd07 100644 --- a/app/Util/ActivityPub/Inbox.php +++ b/app/Util/ActivityPub/Inbox.php @@ -326,7 +326,7 @@ class Inbox $profile = Helpers::profileFetch($actor); $status = Status::whereProfileId($profile->id) ->whereUri($id) - ->orWhereUrl($id) + ->orWhere('url', $id) ->orWhere('object_url', $id) ->first(); if(!$status) { From 2a849be650b1625388b1039ca98096ea8a8c7007 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 7 Oct 2019 18:35:13 +0200 Subject: [PATCH 5/8] Add some elements in api/v1/instance --- app/Http/Controllers/Api/ApiV1Controller.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/ApiV1Controller.php b/app/Http/Controllers/Api/ApiV1Controller.php index e99d45c77..ad8772230 100644 --- a/app/Http/Controllers/Api/ApiV1Controller.php +++ b/app/Http/Controllers/Api/ApiV1Controller.php @@ -900,7 +900,14 @@ class ApiV1Controller extends Controller 'title' => 'Pixelfed (' . config('pixelfed.domain.app') . ')', 'uri' => config('app.url'), 'urls' => [], - 'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')' + 'version' => '2.7.2 (compatible; Pixelfed ' . config('pixelfed.version') . ')', + 'environment' => [ + 'max_photo_size' => config('pixelfed.max_photo_size'), + 'max_avatar_size' => config('pixelfed.max_avatar_size'), + 'max_caption_length' => config('pixelfed.max_caption_length'), + 'max_bio_length' => config('pixelfed.max_bio_length'), + 'max_album_length' => config('pixelfed.max_album_length') + ] ]; return response()->json($res, 200, [], JSON_PRETTY_PRINT); } From 72db2b35b50df16ce9df169da53fb95517e6d806 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 7 Oct 2019 19:48:58 -0600 Subject: [PATCH 6/8] Update AdminController, improve dashboard caching --- app/Http/Controllers/AdminController.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 6fcd1a412..80d096fb9 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -45,20 +45,21 @@ class AdminController extends Controller public function home() { - $data = Cache::remember('admin:dashboard:home:data', now()->addMinutes(15), function() { - $day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day('; + $day = config('database.default') == 'pgsql' ? 'DATE_PART(\'day\',' : 'day('; + + $recent = Cache::remember('admin:dashboard:home:data:15min', now()->addMinutes(15), function() use ($day) { return [ 'contact' => [ 'count' => PrettyNumber::convert(Contact::whereNull('read_at')->count()), - 'graph' => Contact::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereNull('read_at')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') + 'graph' => Contact::selectRaw('count(*) as count, '.$day.'created_at) as d')->groupBy('d')->whereNull('read_at')->whereBetween('created_at',[now()->subDays(14), now()])->orderBy('d')->pluck('count') ], 'failedjobs' => [ 'count' => PrettyNumber::convert(FailedJob::where('failed_at', '>=', \Carbon\Carbon::now()->subDay())->count()), - 'graph' => FailedJob::selectRaw('count(*) as count, '.$day.'failed_at) as d')->groupBy('d')->whereBetween('failed_at',[now()->subDays(24), now()])->orderBy('d')->pluck('count') + 'graph' => FailedJob::selectRaw('count(*) as count, '.$day.'failed_at) as d')->groupBy('d')->whereBetween('failed_at',[now()->subDays(14), now()])->orderBy('d')->pluck('count') ], 'reports' => [ 'count' => PrettyNumber::convert(Report::whereNull('admin_seen')->count()), - 'graph' => Report::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') + 'graph' => Report::selectRaw('count(*) as count, '.$day.'created_at) as d')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('d')->orderBy('d')->pluck('count') ], 'statuses' => [ 'count' => PrettyNumber::convert(Status::whereNull('in_reply_to_id')->whereNull('reblog_of_id')->count()), @@ -80,6 +81,11 @@ class AdminController extends Controller 'count' => PrettyNumber::convert(Profile::count()), 'graph' => Profile::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') ], + ]; + }); + + $longer = Cache::remember('admin:dashboard:home:data:24hr', now()->addHours(24), function() use ($day) { + return [ 'users' => [ 'count' => PrettyNumber::convert(User::count()), 'graph' => User::selectRaw('count(*) as count, '.$day.'created_at) as day')->whereBetween('created_at',[now()->subDays(14), now()])->groupBy('day')->orderBy('day')->pluck('count') @@ -98,6 +104,8 @@ class AdminController extends Controller ] ]; }); + + $data = array_merge($recent, $longer); return view('admin.home', compact('data')); } From 009c6ee820f507386741f158c6283abfbdcc6ecd Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 8 Oct 2019 22:56:38 -0600 Subject: [PATCH 7/8] Update ComposeModal.vue, added a caption counter. Fixes #1722 --- resources/assets/js/components/ComposeModal.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index 5ee92427b..911e8bca3 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -110,7 +110,8 @@
- + +

{{composeTextLength}}/{{config.uploader.max_caption_length}}

@@ -474,9 +475,11 @@ export default { }, mediaDragAndDrop() { + let self = this; let pdz = document.getElementById('content'); + function allowDrag(e) { e.dataTransfer.dropEffect = 'copy'; e.preventDefault(); @@ -484,10 +487,10 @@ export default { function handleDrop(e) { e.preventDefault(); - let dz = document.querySelector('#pf-dz'); - dz.files = e.dataTransfer.files; - $('#composeModal').modal('show'); - self.mediaUpload(); + // let dz = document.querySelector('#pf-dz'); + // dz.files = e.dataTransfer.files; + // $('#composeModal').modal('show'); + // self.mediaUpload(); } window.addEventListener('dragenter', function(e) { From 78b32c43d7adcd1b3a661cf85be9e1aa764bbd15 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 10 Oct 2019 15:52:54 -0600 Subject: [PATCH 8/8] Update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1fd743a76..bade3dfe5 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,5 @@ Matrix](https://matrix.to/#/#freenode_#pixelfed:matrix.org)) We would like to extend our thanks to the following sponsors for funding Pixelfed development. If you are interested in becoming a sponsor, please visit the Pixelfed [Patreon Page](https://www.patreon.com/dansup/overview) -- [](https://oscillas.com/) \ No newline at end of file +- [](https://oscillas.com/) +- Managed Pixelfed Hosting by [Spacebear](https://app.spacebear.ee/) \ No newline at end of file