From 96f13530e1669a208d82987fa7b387b34b01457d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Aug 2022 22:54:59 -0600 Subject: [PATCH 1/6] Update api routes --- routes/api.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/routes/api.php b/routes/api.php index d4732a9f3..f3d0db24a 100644 --- a/routes/api.php +++ b/routes/api.php @@ -100,6 +100,11 @@ Route::group(['prefix' => 'api'], function() use($middleware) { Route::group(['prefix' => 'v1.1'], function() use($middleware) { Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware); Route::delete('accounts/avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware); + Route::get('direct/thread', 'DirectMessageController@thread')->middleware($middleware); + + Route::group(['prefix' => 'stories'], function () use($middleware) { + Route::get('recent', 'StoryController@recent')->middleware($middleware); + }); }); Route::group(['prefix' => 'live'], function() use($middleware) { From 0b7d0a9627892e8d4b4c32d9e137b54a8348e9ee Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Aug 2022 23:39:33 -0600 Subject: [PATCH 2/6] Add customizable Legal Notice page --- app/Http/Controllers/PageController.php | 22 +++++++++++++++------ app/Http/Controllers/SiteController.php | 10 ++++++++++ app/Services/ConfigCacheService.php | 2 ++ config/instance.php | 2 ++ resources/views/admin/pages/home.blade.php | 9 ++++++++- resources/views/site/legal-notice.blade.php | 19 ++++++++++++++++++ routes/web.php | 1 + 7 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 resources/views/site/legal-notice.blade.php diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index 94d149410..a136eda9f 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use Auth, Cache; use App\Page; +use App\Services\ConfigCacheService; class PageController extends Controller { @@ -18,7 +19,8 @@ class PageController extends Controller '/site/about' => 'site:about', '/site/privacy' => 'site:privacy', '/site/terms' => 'site:terms', - '/site/kb/community-guidelines' => 'site:help:community-guidelines' + '/site/kb/community-guidelines' => 'site:help:community-guidelines', + '/site/legal-notice' => 'site:legal-notice' ]; } @@ -60,10 +62,11 @@ class PageController extends Controller $page->title = $request->input('title'); $page->active = (bool) $request->input('active'); $page->save(); - if($page->cached) { - $keys = $this->cacheKeys(); - $key = $keys[$page->slug]; - Cache::forget($key); + $keys = $this->cacheKeys(); + $key = $keys[$page->slug]; + Cache::forget($key); + if($page->slug === '/site/legal-notice') { + ConfigCacheService::put('instance.has_legal_notice', $page->active); } return response()->json(['msg' => 200]); } @@ -75,14 +78,17 @@ class PageController extends Controller ]); $page = Page::findOrFail($request->input('id')); + $keys = $this->cacheKeys(); + $key = $keys[$page->slug]; $page->delete(); + Cache::forget($key); return redirect(route('admin.settings.pages')); } public function generatePage(Request $request) { $this->validate($request, [ - 'page' => 'required|string|in:about,terms,privacy,community_guidelines', + 'page' => 'required|string|in:about,terms,privacy,community_guidelines,legal_notice', ]); $page = $request->input('page'); @@ -103,6 +109,10 @@ class PageController extends Controller case 'community_guidelines': Page::firstOrCreate(['slug' => '/site/kb/community-guidelines']); break; + + case 'legal_notice': + Page::firstOrCreate(['slug' => '/site/legal-notice']); + break; } return redirect(route('admin.settings.pages')); diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index f4cac26be..379b24505 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -154,4 +154,14 @@ class SiteController extends Controller return redirect($url); } + + public function legalNotice(Request $request) + { + $page = Cache::remember('site:legal-notice', now()->addDays(120), function() { + $slug = '/site/legal-notice'; + return Page::whereSlug($slug)->whereActive(true)->first(); + }); + abort_if(!$page, 404); + return View::make('site.legal-notice')->with(compact('page'))->render(); + } } diff --git a/app/Services/ConfigCacheService.php b/app/Services/ConfigCacheService.php index 91d644ee7..b334e9e33 100644 --- a/app/Services/ConfigCacheService.php +++ b/app/Services/ConfigCacheService.php @@ -53,6 +53,8 @@ class ConfigCacheService 'account.autofollow', 'account.autofollow_usernames', 'config.discover.features', + + 'instance.has_legal_notice', // 'system.user_mode' ]; diff --git a/config/instance.php b/config/instance.php index 15ce670f8..d2bf9231a 100644 --- a/config/instance.php +++ b/config/instance.php @@ -84,4 +84,6 @@ return [ ], 'enable_cc' => env('ENABLE_CONFIG_CACHE', false), + + 'has_legal_notice' => env('INSTANCE_LEGAL_NOTICE', false), ]; diff --git a/resources/views/admin/pages/home.blade.php b/resources/views/admin/pages/home.blade.php index bab294647..1f48d540c 100644 --- a/resources/views/admin/pages/home.blade.php +++ b/resources/views/admin/pages/home.blade.php @@ -11,7 +11,7 @@

Manage public and custom page content

- @if($pages->count() < 4) + @if($pages->count() < 5)

@@ -43,6 +43,13 @@ @endif + @if(!$pages->contains('slug', '=', '/site/legal-notice')) +
+ @csrf + + +
+ @endif
@endif diff --git a/resources/views/site/legal-notice.blade.php b/resources/views/site/legal-notice.blade.php new file mode 100644 index 000000000..18e7d92cd --- /dev/null +++ b/resources/views/site/legal-notice.blade.php @@ -0,0 +1,19 @@ +@extends('layouts.app') + +@section('content') +
+
+

{{ $page->title ?? 'Legal Notice' }}

+
+
+ @if($page && $page->content) + {!! $page->content !!} + @endif +
+
+
+
+@endsection +@push('meta') + +@endpush diff --git a/routes/web.php b/routes/web.php index ab9aa03a0..14e30da02 100644 --- a/routes/web.php +++ b/routes/web.php @@ -513,6 +513,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact Route::get('newsroom/archive', 'NewsroomController@archive'); Route::get('newsroom/search', 'NewsroomController@search'); Route::get('newsroom', 'NewsroomController@index'); + Route::get('legal-notice', 'SiteController@legalNotice'); }); Route::group(['prefix' => 'timeline'], function () { From 1e72683a9ec02a28eb27f962d90728bc8573b57a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Aug 2022 23:41:35 -0600 Subject: [PATCH 3/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d40ff6f4..e784878fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### New Features - Custom content warnings/spoiler text ([d4864213](https://github.com/pixelfed/pixelfed/commit/d4864213)) - Add NetworkTimelineService cache ([1310d95c](https://github.com/pixelfed/pixelfed/commit/1310d95c)) +- Customizable Legal Notice page ([0b7d0a96](https://github.com/pixelfed/pixelfed/commit/0b7d0a96)) ### Breaking - Replaced `predis` with `phpredis` as default redis driver due to predis being deprecated, install [phpredis](https://github.com/phpredis/phpredis/blob/develop/INSTALL.markdown) if you're still using predis. From 1b9e50f39b0dd1333bb698daa134b3ddd50f0006 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 15 Aug 2022 23:52:40 -0600 Subject: [PATCH 4/6] Update blade views --- resources/views/admin/pages/home.blade.php | 2 +- resources/views/layouts/partial/footer.blade.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/resources/views/admin/pages/home.blade.php b/resources/views/admin/pages/home.blade.php index 1f48d540c..f4125bc42 100644 --- a/resources/views/admin/pages/home.blade.php +++ b/resources/views/admin/pages/home.blade.php @@ -37,7 +37,7 @@ @endif @if(!$pages->contains('slug', '=', '/site/kb/community-guidelines')) -
+ @csrf diff --git a/resources/views/layouts/partial/footer.blade.php b/resources/views/layouts/partial/footer.blade.php index 86ef1de02..5fb4e27dc 100644 --- a/resources/views/layouts/partial/footer.blade.php +++ b/resources/views/layouts/partial/footer.blade.php @@ -7,6 +7,9 @@ {{__('site.terms')}} {{__('site.privacy')}} {{__('site.language')}} + @if(config_cache('instance.has_legal_notice')) + Legal Notice + @endif

© {{date('Y')}} {{config('pixelfed.domain.app')}} From 7734dc033bac7dbeec20dbadf958b11dab231cd9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 16 Aug 2022 02:57:52 -0600 Subject: [PATCH 5/6] Add instance post/profile embed config setting --- app/Http/Controllers/ProfileController.php | 4 ++++ app/Http/Controllers/StatusController.php | 5 +++++ config/instance.php | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 179db033d..30957cf28 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -243,6 +243,10 @@ class ProfileController extends Controller { $res = view('profile.embed-removed'); + if(!config('instance.embed.profile')) { + return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); + } + if(strlen($username) > 15 || strlen($username) < 2) { return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); } diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php index db57d7a7b..7bfac3aa6 100644 --- a/app/Http/Controllers/StatusController.php +++ b/app/Http/Controllers/StatusController.php @@ -106,6 +106,11 @@ class StatusController extends Controller public function showEmbed(Request $request, $username, int $id) { + if(!config('instance.embed.post')) { + $res = view('status.embed-removed'); + return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); + } + $profile = Profile::whereNull(['domain','status']) ->whereIsPrivate(false) ->whereUsername($username) diff --git a/config/instance.php b/config/instance.php index d2bf9231a..3347e8f83 100644 --- a/config/instance.php +++ b/config/instance.php @@ -86,4 +86,9 @@ return [ 'enable_cc' => env('ENABLE_CONFIG_CACHE', false), 'has_legal_notice' => env('INSTANCE_LEGAL_NOTICE', false), + + 'embed' => [ + 'profile' => env('INSTANCE_PROFILE_EMBEDS', true), + 'post' => env('INSTANCE_POST_EMBEDS', true), + ], ]; From 7718daa1fc03d32e4b67b4d65e9fc3c7e65136aa Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 16 Aug 2022 02:58:21 -0600 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e784878fa..d0ee5b2e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ - Fix AdminStatService cache key, fixes #3612 ([d1dbed89](https://github.com/pixelfed/pixelfed/commit/d1dbed89)) - Improve mute/block v1 api endpoints, fixes #3540 ([c3e8a0e4](https://github.com/pixelfed/pixelfed/commit/c3e8a0e4)) - Set Last-Modified header for atom feeds, fixes #2988 ([c18dcde3](https://github.com/pixelfed/pixelfed/commit/c18dcde3)) +- Add instance post/profile embed config setting ([7734dc03](https://github.com/pixelfed/pixelfed/commit/7734dc03)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3)