From 6c0f26f20fd9e9ed6de56e48020ce21da48b615b Mon Sep 17 00:00:00 2001 From: Floorb <132411956+Neetpone@users.noreply.github.com> Date: Thu, 18 Jul 2024 05:24:35 -0400 Subject: [PATCH] fix: exclude passworded pastes from discover and archive --- includes/Models/Paste.php | 3 +++ public/api/ajax_pastes.php | 1 + public/archive.php | 1 + 3 files changed, 5 insertions(+) diff --git a/includes/Models/Paste.php b/includes/Models/Paste.php index 04794ee..550aba6 100644 --- a/includes/Models/Paste.php +++ b/includes/Models/Paste.php @@ -80,6 +80,7 @@ class Paste extends Model { ->orderBy('updated_at', 'DESC') ->where('visible', self::VISIBILITY_PUBLIC) ->where('is_hidden', false) + ->where('password', null) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))") ->limit($count)->get(); } @@ -89,6 +90,7 @@ class Paste extends Model { ->orderBy('views') ->where('visible', self::VISIBILITY_PUBLIC) ->where('is_hidden', false) + ->where('password', null) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))") ->limit($count)->get(); } @@ -98,6 +100,7 @@ class Paste extends Model { ->whereRaw('MONTH(created_at) = MONTH(NOW())') ->where('visible', self::VISIBILITY_PUBLIC) ->where('is_hidden', false) + ->where('password', null) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))") ->orderBy('views') ->limit($count)->get(); diff --git a/public/api/ajax_pastes.php b/public/api/ajax_pastes.php index b1ad931..719602a 100644 --- a/public/api/ajax_pastes.php +++ b/public/api/ajax_pastes.php @@ -21,6 +21,7 @@ $pastes = Paste::with([ ])->select(['id', 'user_id', 'title', 'expiry', 'created_at', 'updated_at']) ->where('visible', Paste::VISIBILITY_PUBLIC) ->where('hidden', false) + ->where('password', null) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))"); // if (!empty($_GET['q']) && is_string($_GET['q'])) { diff --git a/public/archive.php b/public/archive.php index 9d2afa0..40cc1d1 100644 --- a/public/archive.php +++ b/public/archive.php @@ -31,6 +31,7 @@ $pastes = Paste::with([ ->select('id', 'user_id', 'title', 'created_at', 'updated_at') ->where('visible', Paste::VISIBILITY_PUBLIC) ->where('hidden', false) + ->where('password', null) ->whereRaw("((expiry IS NULL) OR ((expiry != 'SELF') AND (expiry > NOW())))"); if (!empty($filter_value)) {