From 68437e614de1fbbb4496521ce1e6a8a90dad1437 Mon Sep 17 00:00:00 2001 From: daniel Date: Sun, 19 Sep 2021 23:10:18 -0600 Subject: [PATCH] Staging (#2927) * Created localized exception.php (DE) * Update German translation * Update German translation * Update de localization, Create New Post -> New * Formatting * Update site.php (#2889) Co-authored-by: daniel * Formatting * Update controllers, fixes #2906 * Update NotificationService, fix 500 bug * Update changelog Co-authored-by: forenta Co-authored-by: Tomas Brabenec --- CHANGELOG.md | 5 ++++- app/Http/Controllers/Import/Instagram.php | 11 +++++++---- app/Http/Controllers/Import/Mastodon.php | 11 +++++++---- app/Http/Controllers/ImportController.php | 4 ---- app/Http/Controllers/PollController.php | 10 ++++------ app/Services/NotificationService.php | 22 ++++++++++++++++++---- resources/lang/cs/site.php | 6 ++++-- resources/lang/de/exception.php | 11 +++++++++++ resources/lang/de/navmenu.php | 3 +-- resources/lang/de/site.php | 2 +- 10 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 resources/lang/de/exception.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b20d1c68..d2ab5ed77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.1...dev) +### Updated +- Updated NotificationService, fix 500 bug. ([4a609dc3](https://github.com/pixelfed/pixelfed/commit/4a609dc3)) +- ([](https://github.com/pixelfed/pixelfed/commit/)) + ## [v0.11.1 (2021-09-07)](https://github.com/pixelfed/pixelfed/compare/v0.11.0...v0.11.1) ### Added - WebP Support ([069a0e4a](https://github.com/pixelfed/pixelfed/commit/069a0e4a)) @@ -112,7 +116,6 @@ - Updated DirectMessageController, fix autocomplete bug. ([0f00be4d](https://github.com/pixelfed/pixelfed/commit/0f00be4d)) - Updated StoryService, fix division by zero bug. ([6ae1ba0a](https://github.com/pixelfed/pixelfed/commit/6ae1ba0a)) - Updated ApiV1Controller, fix empty public timeline bug. ([0584f9ee](https://github.com/pixelfed/pixelfed/commit/0584f9ee)) -- ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0) ### Added diff --git a/app/Http/Controllers/Import/Instagram.php b/app/Http/Controllers/Import/Instagram.php index bde316e13..39d1d4d2e 100644 --- a/app/Http/Controllers/Import/Instagram.php +++ b/app/Http/Controllers/Import/Instagram.php @@ -15,10 +15,13 @@ use App\Jobs\ImportPipeline\ImportInstagram; trait Instagram { - public function instagram() - { - return view('settings.import.instagram.home'); - } + public function instagram() + { + if(config_cache('pixelfed.import.instagram.enabled') != true) { + abort(404, 'Feature not enabled'); + } + return view('settings.import.instagram.home'); + } public function instagramStart(Request $request) { diff --git a/app/Http/Controllers/Import/Mastodon.php b/app/Http/Controllers/Import/Mastodon.php index 14aa48f77..243cefc37 100644 --- a/app/Http/Controllers/Import/Mastodon.php +++ b/app/Http/Controllers/Import/Mastodon.php @@ -6,8 +6,11 @@ use Illuminate\Http\Request; trait Mastodon { - public function mastodon() - { - return view('settings.import.mastodon.home'); - } + public function mastodon() + { + if(config_cache('pixelfed.import.instagram.enabled') != true) { + abort(404, 'Feature not enabled'); + } + return view('settings.import.mastodon.home'); + } } diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 9885455e9..4a7a27e74 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -11,10 +11,6 @@ class ImportController extends Controller public function __construct() { $this->middleware('auth'); - - if(config_cache('pixelfed.import.instagram.enabled') != true) { - abort(404, 'Feature not enabled'); - } } } diff --git a/app/Http/Controllers/PollController.php b/app/Http/Controllers/PollController.php index 13d1f4518..b176e03d3 100644 --- a/app/Http/Controllers/PollController.php +++ b/app/Http/Controllers/PollController.php @@ -11,14 +11,10 @@ use App\Services\FollowerService; class PollController extends Controller { - - public function __construct() - { - abort_if(!config_cache('instance.polls.enabled'), 404); - } - public function getPoll(Request $request, $id) { + abort_if(!config_cache('instance.polls.enabled'), 404); + $poll = Poll::findOrFail($id); $status = Status::findOrFail($poll->status_id); if($status->scope != 'public') { @@ -34,6 +30,8 @@ class PollController extends Controller public function vote(Request $request, $id) { + abort_if(!config_cache('instance.polls.enabled'), 404); + abort_unless($request->user(), 403); $this->validate($request, [ diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 6eaca0301..e84ea9903 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -27,7 +27,10 @@ class NotificationService { $ids = self::coldGet($id, $start, $stop); } foreach($ids as $id) { - $res->push(self::getNotification($id)); + $n = self::getNotification($id); + if($n != null) { + $res->push($n); + } } return $res; } @@ -56,7 +59,10 @@ class NotificationService { $res = collect([]); foreach($ids as $id) { - $res->push(self::getNotification($id)); + $n = self::getNotification($id); + if($n != null) { + $res->push($n); + } } return $res->toArray(); } @@ -71,7 +77,10 @@ class NotificationService { $res = collect([]); foreach($ids as $id) { - $res->push(self::getNotification($id)); + $n = self::getNotification($id); + if($n != null) { + $res->push($n); + } } return $res->toArray(); } @@ -129,7 +138,12 @@ class NotificationService { public static function getNotification($id) { return Cache::remember('service:notification:'.$id, now()->addDays(3), function() use($id) { - $n = Notification::with('item')->findOrFail($id); + $n = Notification::with('item')->find($id); + + if(!$n) { + return null; + } + $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $resource = new Fractal\Resource\Item($n, new NotificationTransformer()); diff --git a/resources/lang/cs/site.php b/resources/lang/cs/site.php index 12034cf6b..9a8540888 100644 --- a/resources/lang/cs/site.php +++ b/resources/lang/cs/site.php @@ -1,7 +1,6 @@ 'O nás', 'help' => 'Nápověda', 'language' => 'Jazyk', @@ -12,5 +11,8 @@ return [ 'l10nWip' => 'Stále pracujeme na podpoře lokalizací', 'currentLocale' => 'Aktuální jazyk', 'selectLocale' => 'Vyberte si jeden z podporovaných jazyků', - + 'contact' => 'Kontakt', + 'contact-us' => 'Kontaktujte nás', + 'places' => 'Místa', + 'profiles' => 'Profily', ]; diff --git a/resources/lang/de/exception.php b/resources/lang/de/exception.php new file mode 100644 index 000000000..53e92f36f --- /dev/null +++ b/resources/lang/de/exception.php @@ -0,0 +1,11 @@ + [ + 'invalid' => [ + 'album' => 'Mindestens 1 Foto oder Video muss enthalten sein.', + ], + ], + +]; diff --git a/resources/lang/de/navmenu.php b/resources/lang/de/navmenu.php index 7408e455d..f75ca7a00 100644 --- a/resources/lang/de/navmenu.php +++ b/resources/lang/de/navmenu.php @@ -1,7 +1,6 @@ 'Suche', 'home' => 'Heim', 'local' => 'Lokal', @@ -16,5 +15,5 @@ return [ 'admin' => 'Administration', 'logout' => 'Abmelden', 'directMessages' => 'Privatnachrichten', - + 'composePost' => 'Neu', ]; diff --git a/resources/lang/de/site.php b/resources/lang/de/site.php index 1197b5e51..92f81e03b 100644 --- a/resources/lang/de/site.php +++ b/resources/lang/de/site.php @@ -15,5 +15,5 @@ return [ 'contact' => 'Kontakt', 'contact-us' => 'Kontaktiere uns', 'places' => 'Orte', - + 'profiles' => 'Profile', ];