From 9b37c439f71c104e9dcc6c4ab14f72e4b27ab19e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Apr 2020 13:10:48 -0600 Subject: [PATCH 1/4] Update InternalApiController, update modAction method --- .../Controllers/InternalApiController.php | 99 +++++++++++-------- 1 file changed, 56 insertions(+), 43 deletions(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 9d127ba0..4ad1fd8a 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -30,6 +30,7 @@ use League\Fractal\Serializer\ArraySerializer; use League\Fractal\Pagination\IlluminatePaginatorAdapter; use Illuminate\Validation\Rule; use Illuminate\Support\Str; +use App\Services\ModLogService; class InternalApiController extends Controller { @@ -161,24 +162,23 @@ class InternalApiController extends Controller public function modAction(Request $request) { - abort_unless(Auth::user()->is_admin, 403); + abort_unless(Auth::user()->is_admin, 400); $this->validate($request, [ 'action' => [ 'required', 'string', Rule::in([ - 'autocw', - 'noautolink', - 'unlisted', - 'disable', - 'suspend' + 'addcw', + 'remcw', + 'unlist' + ]) ], 'item_id' => 'required|integer|min:1', 'item_type' => [ 'required', 'string', - Rule::in(['status']) + Rule::in(['profile', 'status']) ] ]); @@ -187,48 +187,61 @@ class InternalApiController extends Controller $item_type = $request->input('item_type'); switch($action) { - case 'autocw': - $profile = $item_type == 'status' ? Status::findOrFail($item_id)->profile : null; - $profile->cw = true; - $profile->save(); + case 'addcw': + $status = Status::findOrFail($item_id); + $status->is_nsfw = true; + $status->save(); + ModLogService::boot() + ->user(Auth::user()) + ->objectUid($status->profile->user_id) + ->objectId($status->id) + ->objectType('App\Status::class') + ->action('admin.status.moderate') + ->metadata([ + 'action' => 'cw', + 'message' => 'Success!' + ]) + ->accessLevel('admin') + ->save(); break; - case 'noautolink': - $profile = $item_type == 'status' ? Status::findOrFail($item_id)->profile : null; - $profile->no_autolink = true; - $profile->save(); + case 'remcw': + $status = Status::findOrFail($item_id); + $status->is_nsfw = false; + $status->save(); + ModLogService::boot() + ->user(Auth::user()) + ->objectUid($status->profile->user_id) + ->objectId($status->id) + ->objectType('App\Status::class') + ->action('admin.status.moderate') + ->metadata([ + 'action' => 'remove_cw', + 'message' => 'Success!' + ]) + ->accessLevel('admin') + ->save(); break; - case 'unlisted': - $profile = $item_type == 'status' ? Status::findOrFail($item_id)->profile : null; - $profile->unlisted = true; - $profile->save(); + case 'unlist': + $status = Status::whereScope('public')->findOrFail($item_id); + $status->scope = $status->visibility = 'unlisted'; + $status->save(); + App\Services\PublicTimelineService::del($status->id); + ModLogService::boot() + ->user(Auth::user()) + ->objectUid($status->profile->user_id) + ->objectId($status->id) + ->objectType('App\Status::class') + ->action('admin.status.moderate') + ->metadata([ + 'action' => 'unlist', + 'message' => 'Success!' + ]) + ->accessLevel('admin') + ->save(); break; - - case 'disable': - $profile = $item_type == 'status' ? Status::findOrFail($item_id)->profile : null; - $user = $profile->user; - $profile->status = 'disabled'; - $user->status = 'disabled'; - $profile->save(); - $user->save(); - break; - - - case 'suspend': - $profile = $item_type == 'status' ? Status::findOrFail($item_id)->profile : null; - $user = $profile->user; - $profile->status = 'suspended'; - $user->status = 'suspended'; - $profile->save(); - $user->save(); - break; - - default: - # code... - break; } - Cache::forget('profiles:private'); return ['msg' => 200]; } From b1d5eb05561af7185c71eb510c7ac109ec1d054d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Apr 2020 13:53:47 -0600 Subject: [PATCH 2/4] Update Timeline component, fix mod tools --- .../Controllers/InternalApiController.php | 3 +- resources/assets/js/components/Timeline.vue | 168 +++++++----------- 2 files changed, 66 insertions(+), 105 deletions(-) diff --git a/app/Http/Controllers/InternalApiController.php b/app/Http/Controllers/InternalApiController.php index 4ad1fd8a..5463c895 100644 --- a/app/Http/Controllers/InternalApiController.php +++ b/app/Http/Controllers/InternalApiController.php @@ -31,6 +31,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter; use Illuminate\Validation\Rule; use Illuminate\Support\Str; use App\Services\ModLogService; +use App\Services\PublicTimelineService; class InternalApiController extends Controller { @@ -227,7 +228,7 @@ class InternalApiController extends Controller $status = Status::whereScope('public')->findOrFail($item_id); $status->scope = $status->visibility = 'unlisted'; $status->save(); - App\Services\PublicTimelineService::del($status->id); + PublicTimelineService::del($status->id); ModLogService::boot() ->user(Auth::user()) ->objectUid($status->profile->user_id) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index f9e6db66..1432a9dd 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -399,55 +399,56 @@ body-class="list-group-flush p-0 rounded">
Unlist from Timelines
-
Add Content Warning
+
Remove Content Warning
+
Add Content Warning
Cancel
- - -
Email
-
Facebook
-
Mastodon
-
Pinterest
-
Pixelfed
-
Twitter
-
VK
-
Cancel
-
- + + +
Email
+
Facebook
+
Mastodon
+
Pinterest
+
Pixelfed
+
Twitter
+
VK
+
Cancel
+
+

By using this embed, you agree to our Terms of Use

-
- -
- -
-
+ + +
+ +
+
{ - swal('Success', 'Successfully enforced CW for ' + username, 'success'); + swal('Success', 'Successfully added content warning', 'success'); + status.sensitive = true; + self.ctxModMenuClose(); }).catch(err => { swal( 'Error', 'Something went wrong, please try again later.', 'error' ); + self.ctxModMenuClose(); }); } }); break; - case 'noautolink': - msg = 'Are you sure you want to disable auto linking for ' + username + ' ?'; + case 'remcw': + msg = 'Are you sure you want to remove the content warning on this post?'; swal({ title: 'Confirm', text: msg, @@ -972,20 +978,23 @@ item_id: status.id, item_type: 'status' }).then(res => { - swal('Success', 'Successfully disabled autolinking for ' + username, 'success'); + swal('Success', 'Successfully added content warning', 'success'); + status.sensitive = false; + self.ctxModMenuClose(); }).catch(err => { swal( 'Error', 'Something went wrong, please try again later.', 'error' ); + self.ctxModMenuClose(); }); } }); break; - case 'unlisted': - msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?'; + case 'unlist': + msg = 'Are you sure you want to unlist this post?'; swal({ title: 'Confirm', text: msg, @@ -999,62 +1008,13 @@ item_id: status.id, item_type: 'status' }).then(res => { - swal('Success', 'Successfully unlisted for ' + username, 'success'); - }).catch(err => { - swal( - 'Error', - 'Something went wrong, please try again later.', - 'error' - ); - }); - } - }); - break; - - case 'disable': - msg = 'Are you sure you want to disable ' + username + '’s account ?'; - swal({ - title: 'Confirm', - text: msg, - icon: 'warning', - buttons: true, - dangerMode: true - }).then(res => { - if(res) { - axios.post('/api/v2/moderator/action', { - action: action, - item_id: status.id, - item_type: 'status' - }).then(res => { - swal('Success', 'Successfully disabled ' + username + '’s account', 'success'); - }).catch(err => { - swal( - 'Error', - 'Something went wrong, please try again later.', - 'error' - ); - }); - } - }); - break; - - case 'suspend': - msg = 'Are you sure you want to suspend ' + username + '’s account ?'; - swal({ - title: 'Confirm', - text: msg, - icon: 'warning', - buttons: true, - dangerMode: true - }).then(res => { - if(res) { - axios.post('/api/v2/moderator/action', { - action: action, - item_id: status.id, - item_type: 'status' - }).then(res => { - swal('Success', 'Successfully suspend ' + username + '’s account', 'success'); + this.feed = this.feed.filter(f => { + return f.id != status.id; + }); + swal('Success', 'Successfully unlisted post', 'success'); + self.ctxModMenuClose(); }).catch(err => { + self.ctxModMenuClose(); swal( 'Error', 'Something went wrong, please try again later.', From 2cf823a9f16cf0cce43bd2c527b93f285a52a5f2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 24 Apr 2020 13:54:10 -0600 Subject: [PATCH 3/4] Update compiled assets --- public/js/timeline.js | Bin 118773 -> 118356 bytes public/mix-manifest.json | Bin 1939 -> 1939 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/js/timeline.js b/public/js/timeline.js index 8f71e86b879252a76b437ea50de87b0af14a9f27..82f897ce6682d123cfc071f218c17bfa85f007c1 100644 GIT binary patch delta 929 zcmb`FO=uHA7>4cN8`UWylQ#d`51h`UKwG3im*!^6&gJI}oH{#f;W zT=BhxfSCz&dOVjV&gYlThCJ5_qjP*|d%+wFemS0;(x{|mVoX+4RWA`Hmnbe0rGO=b zL`lgo>w^?6YfPPrVR2qnC`L*yrT*1w~bn)8`yHgjoS-4`H#wpCNW1@YFar|xkU0B zWp=`RchJ|`6y{OuCa64#aV|qS>FePWJsozoe0QidVyFI3oQLEW3N*g7JS46RUN&E+ zH-nz+C>=28$AuBTvf^+1dma4A>dorfJ@E7Kb-!3k7KxQgMY_)9TSg3x)e{~*D8$uz zArSwz7~@eD&ukz6C+kc=MpG-s$j8a(NNL-ukbWO?Z5O)hhrO9DWLraQHL8 zGlv&kaKqs}7chq>-EhX?=WclGF!R8DhoJ>NIQ*#v9y&bjg{=AO-A1=LvgZzX5sTk7 NkbS1juU_cb{tdm~J~{vZ delta 724 zcmcaIhyCk(_6>|8EFM`YA=BfgGOF{ZrRV!AXLqUeFD%Zo`JluD>FHU; zjLRqMT9z}HXjV_YXDKV3nwOSel$@HP;2f?1WGN_V7f;VBWptS=qoXdNscD^5l$w}r zot#*ls+5wlbM%2`Id>CL`r6HVp2}30!UB+B$}C*4l-hTLyUQT9li9%XYey&1EW^O7_PiiqXv(?zq-7JdgW~kL*Q(+DU zdQn^HQNzq)g~a6K{L;LV>2W2DUdS$%hPxO;tr9$R7&WI0lrUNeVkp5dPO7-HxF9tz z1>|2;n-QjMo@2FB0uqHj%#0?J&+pKi9uUvSy7@rxPQS?qmf234F9M3R&3hL!OK}*Q z85^aUT9{1tXJM4x{B*B8(`JVQC%87}U0f#50*d{K4pJ<|NnWKB<2qR~^1aJI=|XP$ z>U>7N%`P7=3xnk*^PCQ6gP1fq^Ym;Olk1EJj2Usp5XS63vkJzvKN|~UE;?HRW6GSf thcOe+9fmQr&bPyu+s|KsF?%oc!I+8{ec6;sw6n^Tz)5$z3oE0*NdV+8{ssU5 diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 252b50c09235f733cd088af3ac27ce793b4c74d2..966872bdd66c205b050e4ed63a248bf0cf0c0f8c 100644 GIT binary patch delta 31 mcmbQtKbe0+4ZC=nkwuzus- Date: Fri, 24 Apr 2020 13:55:22 -0600 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2c9079f..530daff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Updated RemotePost component, fix missing like button on comments ([7ef90565](https://github.com/pixelfed/pixelfed/commit/7ef90565)) - Updated PublicApiControllers, fix block/mutes filtering on public timeline ([08383dd4](https://github.com/pixelfed/pixelfed/commit/08383dd4)) - Updated FixUsernames command, fixes remote username search ([0f943f67](https://github.com/pixelfed/pixelfed/commit/0f943f67)) +- Updated Timeline component, fix mod tools ([b1d5eb05](https://github.com/pixelfed/pixelfed/commit/b1d5eb05)) ## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)