FIX: no notification was being sent when a post is hidden by community flags

This commit is contained in:
Neil Lalonde 2017-09-12 15:43:03 -04:00
parent 9b3b39d8a2
commit 6831efe2e9
3 changed files with 10 additions and 3 deletions

View File

@ -13,7 +13,7 @@ module Jobs
return if user.blank? return if user.blank?
system_message = SystemMessage.new(user) system_message = SystemMessage.new(user)
system_message.create(args[:message_type]) system_message.create(args[:message_type], args[:message_options]&.symbolize_keys || {})
end end
end end

View File

@ -572,7 +572,8 @@ SQL
edit_delay: SiteSetting.cooldown_minutes_after_hiding_posts, edit_delay: SiteSetting.cooldown_minutes_after_hiding_posts,
flag_reason: I18n.t("flag_reasons.#{post_action_type}"), flag_reason: I18n.t("flag_reasons.#{post_action_type}"),
} }
SystemMessage.create(post.user, :post_hidden, options)
Jobs.enqueue_in(5.seconds, :send_system_message, user_id: post.user.id, message_type: :post_hidden, message_options: options)
end end
end end

View File

@ -16,10 +16,16 @@ describe Jobs::SendSystemMessage do
let(:user) { Fabricate(:user) } let(:user) { Fabricate(:user) }
it "should call SystemMessage.create" do it "should call SystemMessage.create" do
SystemMessage.any_instance.expects(:create).with('welcome_invite') SystemMessage.any_instance.expects(:create).with('welcome_invite', {})
Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'welcome_invite') Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'welcome_invite')
end end
it "can send message parameters" do
options = { url: "/t/no-spammers-please/123", edit_delay: 5, flag_reason: "Flagged by community" }
SystemMessage.any_instance.expects(:create).with('post_hidden', options)
Jobs::SendSystemMessage.new.execute(user_id: user.id, message_type: 'post_hidden', message_options: options)
end
end end
end end