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 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')); } 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); } 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(); } diff --git a/app/Util/ActivityPub/Inbox.php b/app/Util/ActivityPub/Inbox.php index fdd39d61b..052b5fd07 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::profileFetch($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::profileFetch($actor); + $status = Status::whereProfileId($profile->id) + ->whereUri($id) + ->orWhere('url', $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; 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) {