From ebe97d05f71180f2c64119b694bf5669c77349f1 Mon Sep 17 00:00:00 2001 From: Bofh Date: Thu, 8 Dec 2022 21:50:47 +0100 Subject: [PATCH] Fix older/newer than filter on accounts search API method --- api/v1/database/mastodon/accounts/search/mod.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/api/v1/database/mastodon/accounts/search/mod.php b/api/v1/database/mastodon/accounts/search/mod.php index db9d6ae..3557a69 100644 --- a/api/v1/database/mastodon/accounts/search/mod.php +++ b/api/v1/database/mastodon/accounts/search/mod.php @@ -90,13 +90,15 @@ switch ($user_filter) { break; } -if (isset($_GET['older_than_days'])) - $sql_all = str_replace('{olderThanNDays}', "(acs.updated_at IS NULL OR acs.updated_at <= (NOW() - INTERVAL '".intval($_GET['older_than_days'])." days')) AND", $sql_all); -else $sql_all = str_replace('{olderThanNDays}', '', $sql_all); +if (isset($_GET['older_than_days'])) { + $_str_interval = "(NOW() - INTERVAL '".intval($_GET['older_than_days'])." days')"; + $sql_all = str_replace('{olderThanNDays}', "a.created_at <= $_str_interval AND (acs.updated_at IS NULL OR acs.updated_at <= $_str_interval) AND", $sql_all); +} else $sql_all = str_replace('{olderThanNDays}', '', $sql_all); -if (isset($_GET['newer_than_days'])) - $sql_all = str_replace('{newerThanNDays}', "(NOT acs.updated_at IS NULL AND acs.updated_at >= (NOW() - INTERVAL '".intval($_GET['newer_than_days'])." days')) AND", $sql_all); -else $sql_all = str_replace('{newerThanNDays}', '', $sql_all); +if (isset($_GET['newer_than_days'])) { + $_str_interval = "(NOW() - INTERVAL '".intval($_GET['newer_than_days'])." days')"; + $sql_all = str_replace('{newerThanNDays}', "a.created_at >= $_str_interval AND (acs.updated_at IS NULL OR acs.updated_at >= $_str_interval) AND", $sql_all); +} else $sql_all = str_replace('{newerThanNDays}', '', $sql_all); if (isset($_GET['no_avatar'])) $sql_all = str_replace('{noAvatarWhere}', 'a.avatar_file_name IS NULL AND', $sql_all);