From 259e648f706c05614af01c3c8aa660e0ef0d11ad Mon Sep 17 00:00:00 2001 From: Jim Mason Date: Wed, 11 Dec 2024 11:57:06 +0000 Subject: [PATCH] omit hashtags from private reviews --- engine/impl/ReviewImpl.php | 4 ++-- ui/Search.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/impl/ReviewImpl.php b/engine/impl/ReviewImpl.php index d54af965..7bad1682 100644 --- a/engine/impl/ReviewImpl.php +++ b/engine/impl/ReviewImpl.php @@ -192,7 +192,7 @@ protected function syncHashtags(int $tag, string $user, ?string $review = null) public function insertReview($tag, $private, $airname, $review, $user) { // we must do this first, as caller depends on lastInsertId from INSERT - $this->syncHashtags($tag, $user, $review); + $this->syncHashtags($tag, $user, $private ? null : $review); $query = "INSERT INTO reviews " . "(tag, user, created, private, review, airname) VALUES (" . @@ -233,7 +233,7 @@ public function updateReview($tag, $private, $airname, $review, $user) { $count = $stmt->execute() ? $stmt->rowCount() : 0; if($count) - $this->syncHashtags($tag, $user, $review); + $this->syncHashtags($tag, $user, $private ? null : $review); return $count; } diff --git a/ui/Search.php b/ui/Search.php index e5d88fa5..d94d9bf1 100644 --- a/ui/Search.php +++ b/ui/Search.php @@ -132,7 +132,7 @@ public function searchByAlbumKey($key = null) { // hashtags $hashtags = array_reduce(array_reverse($reviews), function($carry, $review) { - return preg_match_all('/#\pL\w*/u', $review['review'], $matches) ? + return !$review['private'] && preg_match_all('/#\pL\w*/u', $review['review'], $matches) ? array_merge($carry, $matches[0]) : $carry; }, []); $normalized = array_unique(array_map('strtolower', $hashtags));