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)
->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))");
if (!empty($_GET['q']) && is_string($_GET['q'])) {
$tags = explode(',', $_GET['q']);
$pastes = $pastes->whereHas('tags', function($query) use ($tags) {
$query->where('name', $tags);
});
}
// if (!empty($_GET['q']) && is_string($_GET['q'])) {
// $tags = explode(',', $_GET['q']);
// $pastes = $pastes->whereHas('tags', function($query) use ($tags) {
// $query->where('name', $tags);
// });
// }
$pastes = $pastes->orderBy('id', 'desc')->get();

View file

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