mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Don't notify about dominating private messages.
This commit is contained in:
parent
3be822f97e
commit
2f38316bfc
3 changed files with 15 additions and 9 deletions
|
@ -18,7 +18,7 @@ class UserHistory < ActiveRecord::Base
|
|||
:checked_for_custom_avatar,
|
||||
:notified_about_avatar,
|
||||
:notified_about_sequential_replies,
|
||||
:notitied_about_dominating_topic,
|
||||
:notified_about_dominating_topic,
|
||||
:suspend_user,
|
||||
:unsuspend_user)
|
||||
end
|
||||
|
|
|
@ -97,12 +97,13 @@ class ComposerMessagesFinder
|
|||
return unless replying? &&
|
||||
@details[:topic_id] &&
|
||||
(@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
|
||||
return if topic.blank? ||
|
||||
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
|
||||
|
||||
|
@ -110,7 +111,7 @@ class ComposerMessagesFinder
|
|||
return if ratio < (SiteSetting.dominating_topic_minimum_percent.to_f / 100.0)
|
||||
|
||||
# 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,
|
||||
topic_id: @details[:topic_id])
|
||||
|
||||
|
|
|
@ -232,12 +232,12 @@ describe ComposerMessagesFinder do
|
|||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
|
@ -256,6 +256,11 @@ describe ComposerMessagesFinder do
|
|||
finder.check_dominating_topic.should be_blank
|
||||
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
|
||||
let!(:message) { finder.check_dominating_topic }
|
||||
|
||||
|
@ -263,8 +268,8 @@ describe ComposerMessagesFinder do
|
|||
message.should be_present
|
||||
end
|
||||
|
||||
it "creates a notitied_about_dominating_topic log" do
|
||||
UserHistory.exists_for_user?(user, :notitied_about_dominating_topic).should be_true
|
||||
it "creates a notified_about_dominating_topic log" do
|
||||
UserHistory.exists_for_user?(user, :notified_about_dominating_topic).should be_true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue