forked from mirror/pixelfed
Merge pull request #1535 from pixelfed/frontend-ui-refactor
Fix regression in comment mutes/blocks
This commit is contained in:
commit
b1dc74f760
8 changed files with 74 additions and 9 deletions
|
@ -13,6 +13,7 @@ use App\Jobs\StatusPipeline\NewStatusPipeline;
|
|||
use App\Util\Lexer\Autolink;
|
||||
use App\Profile;
|
||||
use App\Status;
|
||||
use App\UserFilter;
|
||||
use League\Fractal;
|
||||
use App\Transformer\Api\StatusTransformer;
|
||||
use League\Fractal\Serializer\ArraySerializer;
|
||||
|
@ -57,6 +58,16 @@ class CommentController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$filtered = UserFilter::whereUserId($status->profile_id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
->whereFilterableId($profile->id)
|
||||
->exists();
|
||||
|
||||
if($filtered == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reply = DB::transaction(function() use($comment, $status, $profile) {
|
||||
$autolink = Autolink::create()->autolink($comment);
|
||||
$reply = new Status();
|
||||
|
|
|
@ -113,10 +113,22 @@ class PublicApiController extends Controller
|
|||
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||
$status = Status::whereProfileId($profile->id)->whereCommentsDisabled(false)->findOrFail($postId);
|
||||
$this->scopeCheck($profile, $status);
|
||||
|
||||
if(Auth::check()) {
|
||||
$pid = Auth::user()->profile->id;
|
||||
$filtered = UserFilter::whereUserId($pid)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
->pluck('filterable_id')->toArray();
|
||||
} else {
|
||||
$filtered = [];
|
||||
}
|
||||
|
||||
if($request->filled('min_id') || $request->filled('max_id')) {
|
||||
if($request->filled('min_id')) {
|
||||
$replies = $status->comments()
|
||||
->whereNull('reblog_of_id')
|
||||
->whereNotIn('profile_id', $filtered)
|
||||
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||
->where('id', '>=', $request->min_id)
|
||||
->orderBy('id', 'desc')
|
||||
|
@ -125,6 +137,7 @@ class PublicApiController extends Controller
|
|||
if($request->filled('max_id')) {
|
||||
$replies = $status->comments()
|
||||
->whereNull('reblog_of_id')
|
||||
->whereNotIn('profile_id', $filtered)
|
||||
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||
->where('id', '<=', $request->max_id)
|
||||
->orderBy('id', 'desc')
|
||||
|
@ -133,6 +146,7 @@ class PublicApiController extends Controller
|
|||
} else {
|
||||
$replies = $status->comments()
|
||||
->whereNull('reblog_of_id')
|
||||
->whereNotIn('profile_id', $filtered)
|
||||
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||
->orderBy('id', 'desc')
|
||||
->paginate($limit);
|
||||
|
|
|
@ -4,7 +4,8 @@ namespace App\Jobs\CommentPipeline;
|
|||
|
||||
use App\{
|
||||
Notification,
|
||||
Status
|
||||
Status,
|
||||
UserFilter
|
||||
};
|
||||
use App\Services\NotificationService;
|
||||
use DB, Cache, Log, Redis;
|
||||
|
@ -56,6 +57,15 @@ class CommentPipeline implements ShouldQueue
|
|||
if ($actor->id === $target->id || $status->comments_disabled == true) {
|
||||
return true;
|
||||
}
|
||||
$filtered = UserFilter::whereUserId($target->id)
|
||||
->whereFilterableType('App\Profile')
|
||||
->whereIn('filter_type', ['mute', 'block'])
|
||||
->whereFilterableId($actor->id)
|
||||
->exists();
|
||||
|
||||
if($filtered == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::transaction(function() use($target, $actor, $comment) {
|
||||
$notification = new Notification();
|
||||
|
|
2
public/js/profile.js
vendored
2
public/js/profile.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/status.js
vendored
2
public/js/status.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/timeline.js
vendored
2
public/js/timeline.js
vendored
File diff suppressed because one or more lines are too long
|
@ -17,10 +17,10 @@
|
|||
"/js/hashtag.js": "/js/hashtag.js?id=b4ffe6499880acf0591c",
|
||||
"/js/loops.js": "/js/loops.js?id=214f31fc6c2d990487d8",
|
||||
"/js/mode-dot.js": "/js/mode-dot.js?id=8224e306cf53e3336620",
|
||||
"/js/profile.js": "/js/profile.js?id=61a9ed24eae58ba628bf",
|
||||
"/js/profile.js": "/js/profile.js?id=36634151f0495f1ead50",
|
||||
"/js/quill.js": "/js/quill.js?id=9edfe94c043a1bc68860",
|
||||
"/js/search.js": "/js/search.js?id=b1bd588d07e682f8fce5",
|
||||
"/js/status.js": "/js/status.js?id=248bb6c2bec534e81503",
|
||||
"/js/status.js": "/js/status.js?id=88ff0424ea5962941336",
|
||||
"/js/theme-monokai.js": "/js/theme-monokai.js?id=344fb8527bb66574e4cd",
|
||||
"/js/timeline.js": "/js/timeline.js?id=b894c6fe644d16ffc330"
|
||||
"/js/timeline.js": "/js/timeline.js?id=3662e7d43abcaae71f3b"
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
<a class="dropdown-item font-weight-bold" :href="reportUrl(status)">Report</a>
|
||||
</span>
|
||||
<span v-if="statusOwner(status) == true">
|
||||
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="muteProfile(status)">Mute Profile</a>
|
||||
<a class="dropdown-item font-weight-bold text-decoration-none" v-on:click="blockProfile(status)">Block Profile</a>
|
||||
<a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="muteProfile(status)">Mute Profile</a>
|
||||
<a class="dropdown-item font-weight-bold text-decoration-none" @click.prevent="blockProfile(status)">Block Profile</a>
|
||||
</span>
|
||||
<span v-if="profile.is_admin == true">
|
||||
<div class="dropdown-divider"></div>
|
||||
|
@ -187,6 +187,36 @@
|
|||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
muteProfile(status) {
|
||||
if($('body').hasClass('loggedIn') == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.post('/i/mute', {
|
||||
type: 'user',
|
||||
item: status.account.id
|
||||
}).then(res => {
|
||||
swal('Success', 'You have successfully muted ' + status.account.acct, 'success');
|
||||
}).catch(err => {
|
||||
swal('Error', 'Something went wrong. Please try again later.', 'error');
|
||||
});
|
||||
},
|
||||
|
||||
blockProfile(status) {
|
||||
if($('body').hasClass('loggedIn') == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
axios.post('/i/block', {
|
||||
type: 'user',
|
||||
item: status.account.id
|
||||
}).then(res => {
|
||||
swal('Success', 'You have successfully blocked ' + status.account.acct, 'success');
|
||||
}).catch(err => {
|
||||
swal('Error', 'Something went wrong. Please try again later.', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue