Skip to content

Commit

Permalink
omit hashtags from private reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketMan committed Dec 11, 2024
1 parent cb8c4f3 commit 259e648
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions engine/impl/ReviewImpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (" .
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ui/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 259e648

Please sign in to comment.