fix: fix private pastes sometimes showing in archive

This commit is contained in:
Floorb 2024-04-27 00:43:09 -04:00
parent c42b22123e
commit 353991a6a8
2 changed files with 12 additions and 11 deletions

View file

@ -23,12 +23,12 @@ $pastes = Paste::with([
->where('hidden', false) ->where('hidden', false)
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))"); ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
if (!empty($_GET['q']) && is_string($_GET['q'])) { // if (!empty($_GET['q']) && is_string($_GET['q'])) {
$tags = explode(',', $_GET['q']); // $tags = explode(',', $_GET['q']);
$pastes = $pastes->whereHas('tags', function($query) use ($tags) { // $pastes = $pastes->whereHas('tags', function($query) use ($tags) {
$query->where('name', $tags); // $query->where('name', $tags);
}); // });
} // }
$pastes = $pastes->orderBy('id', 'desc')->get(); $pastes = $pastes->orderBy('id', 'desc')->get();

View file

@ -33,15 +33,16 @@ $pastes = Paste::with([
->where('hidden', false) ->where('hidden', false)
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))"); ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
if (!empty($filter_value)) { if (!empty($filter_value)) {
if ($filter_value === 'untagged') { if ($filter_value === 'untagged') {
$pastes = $pastes->doesntHave('tags'); $pastes = $pastes->doesntHave('tags');
} else { } else {
$pastes = $pastes->where('title', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%') $pastes = $paste->where(function($query) {
->orWhereHas('tags', function($q) use ($filter_value) { $query->where('title', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%')
$q->where('name', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%'); ->orWhereHas('tags', function($q) use ($filter_value) {
}); $q->where('name', 'LIKE', '%' . escapeLikeQuery($filter_value) . '%');
});
});
} }
} }