From 69851f36f8c624237b0172dc039353413d18e943 Mon Sep 17 00:00:00 2001 From: nanaya Date: Thu, 26 Sep 2024 20:13:36 +0900 Subject: [PATCH] Don't send user ids for announcement channels --- app/Models/Chat/Channel.php | 6 +----- app/Transformers/Chat/ChannelTransformer.php | 9 +-------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/app/Models/Chat/Channel.php b/app/Models/Chat/Channel.php index c59ee595d9a..b7c5dc5cd3f 100644 --- a/app/Models/Chat/Channel.php +++ b/app/Models/Chat/Channel.php @@ -293,11 +293,7 @@ public function users(): Collection public function visibleUsers(?User $user) { - if ($this->isPM() || $this->isAnnouncement() && priv_check_user($user, 'ChatAnnounce', $this)->can()) { - return $this->users(); - } - - return new Collection(); + return $this->isPM() ? $this->users() : new Collection(); } public function scopePublic($query) diff --git a/app/Transformers/Chat/ChannelTransformer.php b/app/Transformers/Chat/ChannelTransformer.php index e7126739534..c0e636ab7c2 100644 --- a/app/Transformers/Chat/ChannelTransformer.php +++ b/app/Transformers/Chat/ChannelTransformer.php @@ -99,14 +99,7 @@ public function includeRecentMessages(Channel $channel) public function includeUsers(Channel $channel) { - if ( - $channel->isPM() - || $channel->isAnnouncement() && priv_check_user($this->user, 'ChatAnnounce', $channel)->can() - ) { - return $this->primitive($channel->userIds()); - } - - return $this->primitive([]); + return $this->primitive($channel->isPM() ? $channel->userIds() : []); } public function includeUuid(Channel $channel)