From c1f66b968ec874b9bc89fef1719368e530da0965 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 Aug 2018 18:38:07 -0600 Subject: [PATCH 1/4] Add oauth to User model --- app/User.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/User.php b/app/User.php index 68af7ea3..3060cabd 100644 --- a/app/User.php +++ b/app/User.php @@ -2,13 +2,14 @@ namespace App; +use Laravel\Passport\HasApiTokens; +use Illuminate\Notifications\Notifiable; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; -use Illuminate\Notifications\Notifiable; class User extends Authenticatable { - use Notifiable, SoftDeletes; + use Notifiable, SoftDeletes, HasApiTokens; /** * The attributes that should be mutated to dates. From bfa04b7ad792d2e18b4d2d15c0ccda320ce813d8 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 Aug 2018 18:54:50 -0600 Subject: [PATCH 2/4] Update BaseApiController@accountStatuses, handle visibility scope properly --- app/Http/Controllers/Api/BaseApiController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/BaseApiController.php b/app/Http/Controllers/Api/BaseApiController.php index 04be48af..f55c15ce 100644 --- a/app/Http/Controllers/Api/BaseApiController.php +++ b/app/Http/Controllers/Api/BaseApiController.php @@ -57,8 +57,14 @@ class BaseApiController extends Controller public function accountStatuses(Request $request, $id) { + $pid = Auth::user()->profile->id; $profile = Profile::findOrFail($id); - $statuses = $profile->statuses()->orderBy('id', 'desc')->paginate(20); + $statuses = $profile->statuses(); + if($pid === $profile->id) { + $statuses = $statuses->orderBy('id', 'desc')->paginate(20); + } else { + $statuses = $statuses->whereVisibility('public')->orderBy('id', 'desc')->paginate(20); + } $resource = new Fractal\Resource\Collection($statuses, new StatusTransformer()); $res = $this->fractal->createData($resource)->toArray(); From 84ba7f4a9c6139e17187de8e66d9d7cb4fc4264a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 Aug 2018 19:50:37 -0600 Subject: [PATCH 3/4] Update timeline logic to filter non public posts --- app/Http/Controllers/SiteController.php | 1 + app/Http/Controllers/TimelineController.php | 1 + 2 files changed, 2 insertions(+) diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index de6e0c87..0a38f30b 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -42,6 +42,7 @@ class SiteController extends Controller $timeline = Status::whereIn('profile_id', $following) ->whereNotIn('profile_id', $filtered) ->whereHas('media') + ->whereVisibility('public') ->orderBy('id', 'desc') ->withCount(['comments', 'likes', 'shares']) ->simplePaginate(20); diff --git a/app/Http/Controllers/TimelineController.php b/app/Http/Controllers/TimelineController.php index 4ccb7870..77b64b3b 100644 --- a/app/Http/Controllers/TimelineController.php +++ b/app/Http/Controllers/TimelineController.php @@ -52,6 +52,7 @@ class TimelineController extends Controller ->whereNotIn('profile_id', $filtered) ->whereNull('in_reply_to_id') ->whereNull('reblog_of_id') + ->whereVisibility('public') ->withCount(['comments', 'likes']) ->orderBy('id', 'desc') ->simplePaginate(20); From 89ced5bdde5721892a6606149dea07cc1b86afc9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 31 Aug 2018 20:26:56 -0600 Subject: [PATCH 4/4] Add admin report views --- app/Http/Controllers/AdminController.php | 18 ++++++++++++++++++ .../views/admin/partial/sidebar.blade.php | 18 +++++++++--------- .../views/admin/partial/template.blade.php | 2 +- resources/views/admin/reports/home.blade.php | 18 ++++++++++++++---- resources/views/admin/reports/show.blade.php | 4 ++-- routes/web.php | 3 +++ 6 files changed, 47 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 91239779..d2f0b067 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -3,12 +3,18 @@ namespace App\Http\Controllers; use App\Media; +use App\Report; use App\Status; use App\User; use Illuminate\Http\Request; +use App\Http\Controllers\Admin\{ + AdminReportController +}; class AdminController extends Controller { + use AdminReportController; + public function __construct() { return $this->middleware('admin'); @@ -46,4 +52,16 @@ class AdminController extends Controller return view('admin.media.home', compact('media')); } + + public function reports(Request $request) + { + $reports = Report::orderBy('created_at','desc')->paginate(12); + return view('admin.reports.home', compact('reports')); + } + + public function showReport(Request $request, $id) + { + $report = Report::findOrFail($id); + return view('admin.reports.show', compact('report')); + } } diff --git a/resources/views/admin/partial/sidebar.blade.php b/resources/views/admin/partial/sidebar.blade.php index 12440a51..7ccbd8dd 100644 --- a/resources/views/admin/partial/sidebar.blade.php +++ b/resources/views/admin/partial/sidebar.blade.php @@ -1,37 +1,37 @@ \ No newline at end of file diff --git a/resources/views/admin/partial/template.blade.php b/resources/views/admin/partial/template.blade.php index e207f6a9..df260f7b 100644 --- a/resources/views/admin/partial/template.blade.php +++ b/resources/views/admin/partial/template.blade.php @@ -8,7 +8,7 @@
@include('admin.partial.sidebar') -
+
@if (session('status'))
{{ session('status')}} diff --git a/resources/views/admin/reports/home.blade.php b/resources/views/admin/reports/home.blade.php index bc1d7228..bb0c3acb 100644 --- a/resources/views/admin/reports/home.blade.php +++ b/resources/views/admin/reports/home.blade.php @@ -1,13 +1,23 @@ @extends('admin.partial.template') @section('section') -
-

Reports

+
+

Reports

+

+ + Open: + {{App\Report::whereNull('admin_seen')->count()}} + + + Closed: + {{App\Report::whereNotNull('admin_seen')->count()}} + +


- +
@@ -22,7 +32,7 @@ @foreach($reports as $report) diff --git a/resources/views/admin/reports/show.blade.php b/resources/views/admin/reports/show.blade.php index e199d00d..e943d713 100644 --- a/resources/views/admin/reports/show.blade.php +++ b/resources/views/admin/reports/show.blade.php @@ -19,9 +19,9 @@ {{-- Request Mod Feedback --}} Add CWUnlist/Hide - Delete +{{-- DeleteShadowban User - Ban User + Ban User --}} @else

Resolved {{$report->admin_seen->diffForHumans()}}

@endif diff --git a/routes/web.php b/routes/web.php index 7405c98e..9f8bb6b1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,9 @@ Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(functio Route::redirect('/', '/dashboard'); Route::redirect('timeline', config('app.url').'/timeline'); Route::get('dashboard', 'AdminController@home')->name('admin.home'); + Route::get('reports', 'AdminController@reports')->name('admin.reports'); + Route::get('reports/show/{id}', 'AdminController@showReport'); + Route::post('reports/show/{id}', 'AdminController@updateReport'); Route::redirect('statuses', '/statuses/list'); Route::get('statuses/list', 'AdminController@statuses')->name('admin.statuses'); Route::get('statuses/show/{id}', 'AdminController@showStatus');
#
- + {{$report->id}}