Skip to content

Commit b1d5eb0

Browse files
committed
Update Timeline component, fix mod tools
1 parent 9b37c43 commit b1d5eb0

File tree

2 files changed

+66
-105
lines changed

2 files changed

+66
-105
lines changed

app/Http/Controllers/InternalApiController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Illuminate\Validation\Rule;
3232
use Illuminate\Support\Str;
3333
use App\Services\ModLogService;
34+
use App\Services\PublicTimelineService;
3435

3536
class InternalApiController extends Controller
3637
{
@@ -227,7 +228,7 @@ public function modAction(Request $request)
227228
$status = Status::whereScope('public')->findOrFail($item_id);
228229
$status->scope = $status->visibility = 'unlisted';
229230
$status->save();
230-
App\Services\PublicTimelineService::del($status->id);
231+
PublicTimelineService::del($status->id);
231232
ModLogService::boot()
232233
->user(Auth::user())
233234
->objectUid($status->profile->user_id)

resources/assets/js/components/Timeline.vue

+64-104
Original file line numberDiff line numberDiff line change
@@ -399,55 +399,56 @@
399399
body-class="list-group-flush p-0 rounded">
400400
<div class="list-group text-center">
401401
<div class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'unlist')">Unlist from Timelines</div>
402-
<div class="list-group-item rounded cursor-pointer" @click="">Add Content Warning</div>
402+
<div v-if="ctxMenuStatus.sensitive" class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'remcw')">Remove Content Warning</div>
403+
<div v-else class="list-group-item rounded cursor-pointer" @click="moderatePost(ctxMenuStatus, 'addcw')">Add Content Warning</div>
403404
<div class="list-group-item rounded cursor-pointer text-lighter" @click="ctxModMenuClose()">Cancel</div>
404405
</div>
405-
</b-modal>
406-
<b-modal ref="ctxShareModal"
407-
id="ctx-share-modal"
408-
title="Share"
409-
hide-footer
410-
centered
411-
rounded
412-
size="sm"
413-
body-class="list-group-flush p-0 rounded text-center">
414-
<div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
415-
<div class="list-group-item rounded cursor-pointer">Facebook</div>
416-
<div class="list-group-item rounded cursor-pointer">Mastodon</div>
417-
<div class="list-group-item rounded cursor-pointer">Pinterest</div>
418-
<div class="list-group-item rounded cursor-pointer">Pixelfed</div>
419-
<div class="list-group-item rounded cursor-pointer">Twitter</div>
420-
<div class="list-group-item rounded cursor-pointer">VK</div>
421-
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
422-
</b-modal>
423-
<b-modal ref="ctxEmbedModal"
424-
id="ctx-embed-modal"
425-
hide-header
426-
hide-footer
427-
centered
428-
rounded
429-
size="md"
430-
body-class="p-2 rounded">
406+
</b-modal>
407+
<b-modal ref="ctxShareModal"
408+
id="ctx-share-modal"
409+
title="Share"
410+
hide-footer
411+
centered
412+
rounded
413+
size="sm"
414+
body-class="list-group-flush p-0 rounded text-center">
415+
<div class="list-group-item rounded cursor-pointer border-top-0">Email</div>
416+
<div class="list-group-item rounded cursor-pointer">Facebook</div>
417+
<div class="list-group-item rounded cursor-pointer">Mastodon</div>
418+
<div class="list-group-item rounded cursor-pointer">Pinterest</div>
419+
<div class="list-group-item rounded cursor-pointer">Pixelfed</div>
420+
<div class="list-group-item rounded cursor-pointer">Twitter</div>
421+
<div class="list-group-item rounded cursor-pointer">VK</div>
422+
<div class="list-group-item rounded cursor-pointer text-lighter" @click="closeCtxShareMenu()">Cancel</div>
423+
</b-modal>
424+
<b-modal ref="ctxEmbedModal"
425+
id="ctx-embed-modal"
426+
hide-header
427+
hide-footer
428+
centered
429+
rounded
430+
size="md"
431+
body-class="p-2 rounded">
431432
<div>
432433
<textarea class="form-control disabled" rows="1" style="border: 1px solid #efefef; font-size: 14px; line-height: 12px; height: 37px; margin: 0 0 7px; resize: none; white-space: nowrap;" v-model="ctxEmbedPayload"></textarea>
433434
<hr>
434435
<button :class="copiedEmbed ? 'btn btn-primary btn-block btn-sm py-1 font-weight-bold disabed': 'btn btn-primary btn-block btn-sm py-1 font-weight-bold'" @click="ctxCopyEmbed" :disabled="copiedEmbed">{{copiedEmbed ? 'Embed Code Copied!' : 'Copy Embed Code'}}</button>
435436
<p class="mb-0 px-2 small text-muted">By using this embed, you agree to our <a href="/site/terms">Terms of Use</a></p>
436437
</div>
437-
</b-modal>
438-
<b-modal
439-
id="lightbox"
440-
ref="lightboxModal"
441-
hide-header
442-
hide-footer
443-
centered
444-
size="lg"
445-
body-class="p-0"
446-
>
447-
<div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
448-
<img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%">
449-
</div>
450-
</b-modal>
438+
</b-modal>
439+
<b-modal
440+
id="lightbox"
441+
ref="lightboxModal"
442+
hide-header
443+
hide-footer
444+
centered
445+
size="lg"
446+
body-class="p-0"
447+
>
448+
<div v-if="lightboxMedia" :class="lightboxMedia.filter_class" class="w-100 h-100">
449+
<img :src="lightboxMedia.url" style="max-height: 100%; max-width: 100%">
450+
</div>
451+
</b-modal>
451452
<b-modal ref="replyModal"
452453
id="ctx-reply-modal"
453454
hide-footer
@@ -929,63 +930,11 @@
929930
930931
moderatePost(status, action, $event) {
931932
let username = status.account.username;
933+
let msg = '';
934+
let self = this;
932935
switch(action) {
933-
case 'autocw':
934-
let msg = 'Are you sure you want to enforce CW for ' + username + ' ?';
935-
swal({
936-
title: 'Confirm',
937-
text: msg,
938-
icon: 'warning',
939-
buttons: true,
940-
dangerMode: true
941-
}).then(res => {
942-
if(res) {
943-
axios.post('/api/v2/moderator/action', {
944-
action: action,
945-
item_id: status.id,
946-
item_type: 'status'
947-
}).then(res => {
948-
swal('Success', 'Successfully enforced CW for ' + username, 'success');
949-
}).catch(err => {
950-
swal(
951-
'Error',
952-
'Something went wrong, please try again later.',
953-
'error'
954-
);
955-
});
956-
}
957-
});
958-
break;
959-
960-
case 'noautolink':
961-
msg = 'Are you sure you want to disable auto linking for ' + username + ' ?';
962-
swal({
963-
title: 'Confirm',
964-
text: msg,
965-
icon: 'warning',
966-
buttons: true,
967-
dangerMode: true
968-
}).then(res => {
969-
if(res) {
970-
axios.post('/api/v2/moderator/action', {
971-
action: action,
972-
item_id: status.id,
973-
item_type: 'status'
974-
}).then(res => {
975-
swal('Success', 'Successfully disabled autolinking for ' + username, 'success');
976-
}).catch(err => {
977-
swal(
978-
'Error',
979-
'Something went wrong, please try again later.',
980-
'error'
981-
);
982-
});
983-
}
984-
});
985-
break;
986-
987-
case 'unlisted':
988-
msg = 'Are you sure you want to unlist from timelines for ' + username + ' ?';
936+
case 'addcw':
937+
msg = 'Are you sure you want to add a content warning to this post?';
989938
swal({
990939
title: 'Confirm',
991940
text: msg,
@@ -999,20 +948,23 @@
999948
item_id: status.id,
1000949
item_type: 'status'
1001950
}).then(res => {
1002-
swal('Success', 'Successfully unlisted for ' + username, 'success');
951+
swal('Success', 'Successfully added content warning', 'success');
952+
status.sensitive = true;
953+
self.ctxModMenuClose();
1003954
}).catch(err => {
1004955
swal(
1005956
'Error',
1006957
'Something went wrong, please try again later.',
1007958
'error'
1008959
);
960+
self.ctxModMenuClose();
1009961
});
1010962
}
1011963
});
1012964
break;
1013965
1014-
case 'disable':
1015-
msg = 'Are you sure you want to disable ' + username + '’s account ?';
966+
case 'remcw':
967+
msg = 'Are you sure you want to remove the content warning on this post?';
1016968
swal({
1017969
title: 'Confirm',
1018970
text: msg,
@@ -1026,20 +978,23 @@
1026978
item_id: status.id,
1027979
item_type: 'status'
1028980
}).then(res => {
1029-
swal('Success', 'Successfully disabled ' + username + '’s account', 'success');
981+
swal('Success', 'Successfully added content warning', 'success');
982+
status.sensitive = false;
983+
self.ctxModMenuClose();
1030984
}).catch(err => {
1031985
swal(
1032986
'Error',
1033987
'Something went wrong, please try again later.',
1034988
'error'
1035989
);
990+
self.ctxModMenuClose();
1036991
});
1037992
}
1038993
});
1039994
break;
1040995
1041-
case 'suspend':
1042-
msg = 'Are you sure you want to suspend ' + username + '’s account ?';
996+
case 'unlist':
997+
msg = 'Are you sure you want to unlist this post?';
1043998
swal({
1044999
title: 'Confirm',
10451000
text: msg,
@@ -1053,8 +1008,13 @@
10531008
item_id: status.id,
10541009
item_type: 'status'
10551010
}).then(res => {
1056-
swal('Success', 'Successfully suspend ' + username + '’s account', 'success');
1011+
this.feed = this.feed.filter(f => {
1012+
return f.id != status.id;
1013+
});
1014+
swal('Success', 'Successfully unlisted post', 'success');
1015+
self.ctxModMenuClose();
10571016
}).catch(err => {
1017+
self.ctxModMenuClose();
10581018
swal(
10591019
'Error',
10601020
'Something went wrong, please try again later.',

0 commit comments

Comments
 (0)