mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 01:47:22 +08:00
FIX: Remove limit on dismissing unread and new messages.
Follow-up to 2c046cc670
This commit is contained in:
parent
bfe24f74e1
commit
3f59ccefd7
|
@ -958,6 +958,7 @@ class TopicsController < ApplicationController
|
||||||
params.require(:inbox)
|
params.require(:inbox)
|
||||||
inbox = params[:inbox].to_s
|
inbox = params[:inbox].to_s
|
||||||
filter = private_message_filter(topic_query, inbox)
|
filter = private_message_filter(topic_query, inbox)
|
||||||
|
topic_query.options[:limit] = false
|
||||||
topic_scope = topic_query.filter_private_message_new(current_user, filter)
|
topic_scope = topic_query.filter_private_message_new(current_user, filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1233,6 +1234,7 @@ class TopicsController < ApplicationController
|
||||||
|
|
||||||
if inbox = params[:private_message_inbox]
|
if inbox = params[:private_message_inbox]
|
||||||
filter = private_message_filter(topic_query, inbox)
|
filter = private_message_filter(topic_query, inbox)
|
||||||
|
topic_query.options[:limit] = false
|
||||||
topics = topic_query.filter_private_messages_unread(current_user, filter)
|
topics = topic_query.filter_private_messages_unread(current_user, filter)
|
||||||
else
|
else
|
||||||
topics = TopicQuery.unread_filter(topic_query.joined_topic_user, staff: guardian.is_staff?).listable_topics
|
topics = TopicQuery.unread_filter(topic_query.joined_topic_user, staff: guardian.is_staff?).listable_topics
|
||||||
|
|
|
@ -2863,6 +2863,14 @@ RSpec.describe TopicsController do
|
||||||
).topic
|
).topic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fab!(:private_message_2) do
|
||||||
|
create_post(
|
||||||
|
user: user,
|
||||||
|
target_usernames: [user_2.username],
|
||||||
|
archetype: Archetype.private_message
|
||||||
|
).topic
|
||||||
|
end
|
||||||
|
|
||||||
fab!(:group_pm_topic_user) do
|
fab!(:group_pm_topic_user) do
|
||||||
TopicUser.find_by(user: user_2, topic: group_message).tap do |tu|
|
TopicUser.find_by(user: user_2, topic: group_message).tap do |tu|
|
||||||
tu.update!(last_read_post_number: 1)
|
tu.update!(last_read_post_number: 1)
|
||||||
|
@ -2875,9 +2883,16 @@ RSpec.describe TopicsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fab!(:regular_pm_topic_user_2) do
|
||||||
|
TopicUser.find_by(user: user_2, topic: private_message_2).tap do |tu|
|
||||||
|
tu.update!(last_read_post_number: 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
create_post(user: user, topic: group_message)
|
create_post(user: user, topic: group_message)
|
||||||
create_post(user: user, topic: private_message)
|
create_post(user: user, topic: private_message)
|
||||||
|
create_post(user: user, topic: private_message_2)
|
||||||
sign_in(user_2)
|
sign_in(user_2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2895,17 +2910,20 @@ RSpec.describe TopicsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can dismiss all user unread private message topics" do
|
it "can dismiss all user unread private message topics" do
|
||||||
expect do
|
stub_const(TopicQuery, "DEFAULT_PER_PAGE_COUNT", 1) do
|
||||||
put "/topics/bulk.json", params: {
|
expect do
|
||||||
filter: "unread",
|
put "/topics/bulk.json", params: {
|
||||||
operation: { type: 'dismiss_posts' },
|
filter: "unread",
|
||||||
private_message_inbox: "user"
|
operation: { type: 'dismiss_posts' },
|
||||||
}
|
private_message_inbox: "user"
|
||||||
|
}
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
end.to change { regular_pm_topic_user.reload.last_read_post_number }.from(1).to(2)
|
end.to change { regular_pm_topic_user.reload.last_read_post_number }.from(1).to(2)
|
||||||
|
.and change { regular_pm_topic_user_2.reload.last_read_post_number }.from(1).to(2)
|
||||||
|
|
||||||
expect(group_pm_topic_user.reload.last_read_post_number).to eq(1)
|
expect(group_pm_topic_user.reload.last_read_post_number).to eq(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the right response when trying to dismiss private messages of an invalid group" do
|
it "returns the right response when trying to dismiss private messages of an invalid group" do
|
||||||
|
@ -4217,6 +4235,14 @@ RSpec.describe TopicsController do
|
||||||
).topic
|
).topic
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fab!(:private_message_2) do
|
||||||
|
create_post(
|
||||||
|
user: user,
|
||||||
|
target_usernames: [user_2.username],
|
||||||
|
archetype: Archetype.private_message
|
||||||
|
).topic
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
sign_in(user_2)
|
sign_in(user_2)
|
||||||
end
|
end
|
||||||
|
@ -4268,26 +4294,30 @@ RSpec.describe TopicsController do
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
expect(DismissedTopicUser.count).to eq(1)
|
expect(DismissedTopicUser.count).to eq(2)
|
||||||
|
|
||||||
expect(DismissedTopicUser.exists?(topic: private_message, user: user_2))
|
expect(DismissedTopicUser.exists?(user: user_2, topic: [
|
||||||
.to eq(true)
|
private_message,
|
||||||
|
private_message_2
|
||||||
|
])).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can reset new personal and group private messages' do
|
it 'can reset new personal and group private messages' do
|
||||||
put "/topics/pm-reset-new.json", params: {
|
stub_const(TopicQuery, "DEFAULT_PER_PAGE_COUNT", 1) do
|
||||||
inbox: "all",
|
put "/topics/pm-reset-new.json", params: {
|
||||||
}
|
inbox: "all",
|
||||||
|
}
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
expect(DismissedTopicUser.count).to eq(2)
|
expect(DismissedTopicUser.count).to eq(3)
|
||||||
|
|
||||||
expect(DismissedTopicUser.exists?(topic: private_message, user: user_2))
|
expect(DismissedTopicUser.exists?(user: user_2, topic: [
|
||||||
.to eq(true)
|
private_message,
|
||||||
|
private_message_2,
|
||||||
expect(DismissedTopicUser.exists?(topic: group_message, user: user_2))
|
group_message
|
||||||
.to eq(true)
|
])).to eq(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns the right response is topic_ids params is not valid' do
|
it 'returns the right response is topic_ids params is not valid' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user