mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 22:41:27 +00:00
Fix regression in comment mutes/blocks
This commit is contained in:
parent
2cd389e229
commit
60e9d547ae
3 changed files with 36 additions and 1 deletions
|
@ -13,6 +13,7 @@ use App\Jobs\StatusPipeline\NewStatusPipeline;
|
||||||
use App\Util\Lexer\Autolink;
|
use App\Util\Lexer\Autolink;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
|
use App\UserFilter;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
use App\Transformer\Api\StatusTransformer;
|
use App\Transformer\Api\StatusTransformer;
|
||||||
use League\Fractal\Serializer\ArraySerializer;
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
@ -57,6 +58,16 @@ class CommentController extends Controller
|
||||||
return;
|
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) {
|
$reply = DB::transaction(function() use($comment, $status, $profile) {
|
||||||
$autolink = Autolink::create()->autolink($comment);
|
$autolink = Autolink::create()->autolink($comment);
|
||||||
$reply = new Status();
|
$reply = new Status();
|
||||||
|
|
|
@ -113,10 +113,22 @@ class PublicApiController extends Controller
|
||||||
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
|
||||||
$status = Status::whereProfileId($profile->id)->whereCommentsDisabled(false)->findOrFail($postId);
|
$status = Status::whereProfileId($profile->id)->whereCommentsDisabled(false)->findOrFail($postId);
|
||||||
$this->scopeCheck($profile, $status);
|
$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') || $request->filled('max_id')) {
|
||||||
if($request->filled('min_id')) {
|
if($request->filled('min_id')) {
|
||||||
$replies = $status->comments()
|
$replies = $status->comments()
|
||||||
->whereNull('reblog_of_id')
|
->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')
|
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||||
->where('id', '>=', $request->min_id)
|
->where('id', '>=', $request->min_id)
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
|
@ -125,6 +137,7 @@ class PublicApiController extends Controller
|
||||||
if($request->filled('max_id')) {
|
if($request->filled('max_id')) {
|
||||||
$replies = $status->comments()
|
$replies = $status->comments()
|
||||||
->whereNull('reblog_of_id')
|
->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')
|
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||||
->where('id', '<=', $request->max_id)
|
->where('id', '<=', $request->max_id)
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
|
@ -133,6 +146,7 @@ class PublicApiController extends Controller
|
||||||
} else {
|
} else {
|
||||||
$replies = $status->comments()
|
$replies = $status->comments()
|
||||||
->whereNull('reblog_of_id')
|
->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')
|
->select('id', 'caption', 'is_nsfw', 'rendered', 'profile_id', 'in_reply_to_id', 'type', 'reply_count', 'created_at')
|
||||||
->orderBy('id', 'desc')
|
->orderBy('id', 'desc')
|
||||||
->paginate($limit);
|
->paginate($limit);
|
||||||
|
|
|
@ -4,7 +4,8 @@ namespace App\Jobs\CommentPipeline;
|
||||||
|
|
||||||
use App\{
|
use App\{
|
||||||
Notification,
|
Notification,
|
||||||
Status
|
Status,
|
||||||
|
UserFilter
|
||||||
};
|
};
|
||||||
use App\Services\NotificationService;
|
use App\Services\NotificationService;
|
||||||
use DB, Cache, Log, Redis;
|
use DB, Cache, Log, Redis;
|
||||||
|
@ -56,6 +57,15 @@ class CommentPipeline implements ShouldQueue
|
||||||
if ($actor->id === $target->id || $status->comments_disabled == true) {
|
if ($actor->id === $target->id || $status->comments_disabled == true) {
|
||||||
return 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) {
|
DB::transaction(function() use($target, $actor, $comment) {
|
||||||
$notification = new Notification();
|
$notification = new Notification();
|
||||||
|
|
Loading…
Reference in a new issue