mirror of
https://github.com/discourse/discourse.git
synced 2025-04-11 14:50:49 +08:00
Merge pull request #1916 from vikhyat/pm-dominating
Don't notify about dominating private messages
This commit is contained in:
commit
e47f462f54
@ -18,7 +18,7 @@ class UserHistory < ActiveRecord::Base
|
|||||||
:checked_for_custom_avatar,
|
:checked_for_custom_avatar,
|
||||||
:notified_about_avatar,
|
:notified_about_avatar,
|
||||||
:notified_about_sequential_replies,
|
:notified_about_sequential_replies,
|
||||||
:notitied_about_dominating_topic,
|
:notified_about_dominating_topic,
|
||||||
:suspend_user,
|
:suspend_user,
|
||||||
:unsuspend_user)
|
:unsuspend_user)
|
||||||
end
|
end
|
||||||
|
@ -97,12 +97,13 @@ class ComposerMessagesFinder
|
|||||||
return unless replying? &&
|
return unless replying? &&
|
||||||
@details[:topic_id] &&
|
@details[:topic_id] &&
|
||||||
(@user.post_count >= SiteSetting.educate_until_posts) &&
|
(@user.post_count >= SiteSetting.educate_until_posts) &&
|
||||||
!UserHistory.exists_for_user?(@user, :notitied_about_dominating_topic, topic_id: @details[:topic_id])
|
!UserHistory.exists_for_user?(@user, :notified_about_dominating_topic, topic_id: @details[:topic_id])
|
||||||
|
|
||||||
topic = Topic.where(id: @details[:topic_id]).first
|
topic = Topic.where(id: @details[:topic_id]).first
|
||||||
return if topic.blank? ||
|
return if topic.blank? ||
|
||||||
topic.user_id == @user.id ||
|
topic.user_id == @user.id ||
|
||||||
topic.posts_count < SiteSetting.summary_posts_required
|
topic.posts_count < SiteSetting.summary_posts_required ||
|
||||||
|
topic.archetype == Archetype.private_message
|
||||||
|
|
||||||
posts_by_user = @user.posts.where(topic_id: topic.id).count
|
posts_by_user = @user.posts.where(topic_id: topic.id).count
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ class ComposerMessagesFinder
|
|||||||
return if ratio < (SiteSetting.dominating_topic_minimum_percent.to_f / 100.0)
|
return if ratio < (SiteSetting.dominating_topic_minimum_percent.to_f / 100.0)
|
||||||
|
|
||||||
# Log the topic notification
|
# Log the topic notification
|
||||||
UserHistory.create!(action: UserHistory.actions[:notitied_about_dominating_topic],
|
UserHistory.create!(action: UserHistory.actions[:notified_about_dominating_topic],
|
||||||
target_user_id: @user.id,
|
target_user_id: @user.id,
|
||||||
topic_id: @details[:topic_id])
|
topic_id: @details[:topic_id])
|
||||||
|
|
||||||
@ -130,4 +131,4 @@ class ComposerMessagesFinder
|
|||||||
return @details[:composerAction] == "reply"
|
return @details[:composerAction] == "reply"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -232,12 +232,12 @@ describe ComposerMessagesFinder do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't notify a user it has already notified in this topic" do
|
it "doesn't notify a user it has already notified in this topic" do
|
||||||
UserHistory.create!(action: UserHistory.actions[:notitied_about_dominating_topic], topic_id: topic.id, target_user_id: user.id )
|
UserHistory.create!(action: UserHistory.actions[:notified_about_dominating_topic], topic_id: topic.id, target_user_id: user.id )
|
||||||
finder.check_dominating_topic.should be_blank
|
finder.check_dominating_topic.should be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
it "notifies a user if the topic is different" do
|
it "notifies a user if the topic is different" do
|
||||||
UserHistory.create!(action: UserHistory.actions[:notitied_about_dominating_topic], topic_id: topic.id+1, target_user_id: user.id )
|
UserHistory.create!(action: UserHistory.actions[:notified_about_dominating_topic], topic_id: topic.id+1, target_user_id: user.id )
|
||||||
finder.check_dominating_topic.should be_present
|
finder.check_dominating_topic.should be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -256,6 +256,11 @@ describe ComposerMessagesFinder do
|
|||||||
finder.check_dominating_topic.should be_blank
|
finder.check_dominating_topic.should be_blank
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't notify you in a private message" do
|
||||||
|
topic.update_column(:archetype, Archetype.private_message)
|
||||||
|
finder.check_dominating_topic.should be_blank
|
||||||
|
end
|
||||||
|
|
||||||
context "success" do
|
context "success" do
|
||||||
let!(:message) { finder.check_dominating_topic }
|
let!(:message) { finder.check_dominating_topic }
|
||||||
|
|
||||||
@ -263,8 +268,8 @@ describe ComposerMessagesFinder do
|
|||||||
message.should be_present
|
message.should be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a notitied_about_dominating_topic log" do
|
it "creates a notified_about_dominating_topic log" do
|
||||||
UserHistory.exists_for_user?(user, :notitied_about_dominating_topic).should be_true
|
UserHistory.exists_for_user?(user, :notified_about_dominating_topic).should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user