FEATURE: Only list watching group messages in messages notifications panel (#20630)

Why is this change required?

Prior to this change, we would list all group messages that a user
has access to in the user menu messages notifications panel dropdown.
However, this did not respect the topic's notification level setting and
group messages which the user has set to 'normal' notification level were
being displayed

What does this commit do?

With this commit, we no longer display all group messages that a user
has access to. Instead, we only display group messages that a user is
watching in the user menu messages notifications panel dropdown.

Internal Ref: /t/94392
This commit is contained in:
Alan Guo Xiang Tan
2023-03-13 08:09:38 +08:00
committed by GitHub
parent 44bc284e0f
commit e4b11e7643
4 changed files with 168 additions and 77 deletions

View File

@ -6526,24 +6526,31 @@ RSpec.describe UsersController do
)
end
it "responds with an array of PM topics that are not associated with any of the unread private_message notifications" do
it "responds with an array of personal messages and user watching group messages that are not associated with any of the unread private_message notifications" do
group_message1.update!(bumped_at: 1.minutes.ago)
message_without_notification.update!(bumped_at: 3.minutes.ago)
group_message2.update!(bumped_at: 6.minutes.ago)
message_with_read_notification.update!(bumped_at: 10.minutes.ago)
read_group_message_summary_notification.destroy!
TopicUser.create!(
user: user,
topic: group_message1,
notification_level: TopicUser.notification_levels[:watching],
)
TopicUser.create!(
user: user,
topic: group_message2,
notification_level: TopicUser.notification_levels[:regular],
)
get "/u/#{user.username}/user-menu-private-messages"
expect(response.status).to eq(200)
topics = response.parsed_body["topics"]
expect(topics.map { |topic| topic["id"] }).to eq(
[
group_message1.id,
message_without_notification.id,
group_message2.id,
message_with_read_notification.id,
],
[group_message1.id, message_without_notification.id, message_with_read_notification.id],
)
end