mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 07:38:45 -05:00
FEATURE: pending flags reminder is sent as a group message to staff instead of sending an email to the contact email site setting.
This commit is contained in:
parent
6c684944c5
commit
e8d837269b
3 changed files with 20 additions and 17 deletions
|
@ -11,8 +11,14 @@ module Jobs
|
|||
PostAction.flagged_posts_count > 0 &&
|
||||
FlagQuery.flagged_post_actions('active').where('post_actions.created_at < ?', SiteSetting.notify_about_flags_after.to_i.hours.ago).pluck(:id).count > 0
|
||||
|
||||
message = PendingFlagsMailer.notify
|
||||
Email::Sender.new(message, :pending_flags_reminder).send
|
||||
PostCreator.create(
|
||||
Discourse.system_user,
|
||||
target_group_names: ["staff"],
|
||||
archetype: Archetype.private_message,
|
||||
subtype: TopicSubtype.system_message,
|
||||
title: I18n.t('flags_reminder.subject_template', { count: PostAction.flagged_posts_count }),
|
||||
raw: I18n.t('flags_reminder.flags_were_submitted', { count: SiteSetting.notify_about_flags_after })
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1409,6 +1409,14 @@ en:
|
|||
blocked: "New registrations are not allowed from your IP address."
|
||||
max_new_accounts_per_registration_ip: "New registrations are not allowed from your IP address (maximum limit reached). Contact a staff member."
|
||||
|
||||
flags_reminder:
|
||||
flags_were_submitted:
|
||||
one: "Flags were submitted over 1 hour ago. Please review them."
|
||||
other: "Flags were submitted over %{count} hours ago. Please review them."
|
||||
subject_template:
|
||||
one: "1 flag waiting to be handled"
|
||||
other: "%{count} flags waiting to be handled"
|
||||
|
||||
unsubscribe_mailer:
|
||||
subject_template: "Confirm you no longer want to receive email updates from %{site_title}"
|
||||
text_body_template: |
|
||||
|
@ -1543,17 +1551,6 @@ en:
|
|||
|
||||
%{notes}
|
||||
|
||||
flags_reminder:
|
||||
flags_were_submitted:
|
||||
one: "These flags were submitted over 1 hour ago."
|
||||
other: "These flags were submitted over %{count} hours ago."
|
||||
please_review: "Please review them."
|
||||
post_number: "post"
|
||||
how_to_disable: 'You can disable or change the frequency of this email reminder via the "notify about flags after" setting.'
|
||||
subject_template:
|
||||
one: "1 flag waiting to be handled"
|
||||
other: "%{count} flags waiting to be handled"
|
||||
|
||||
queued_posts_reminder:
|
||||
subject_template:
|
||||
one: "[%{site_name}] 1 post waiting to be reviewed"
|
||||
|
|
|
@ -14,17 +14,17 @@ describe Jobs::PendingFlagsReminder do
|
|||
context "notify_about_flags_after is 48" do
|
||||
before { SiteSetting.stubs(:notify_about_flags_after).returns(48) }
|
||||
|
||||
it "doesn't send email when flags are less than 48 hours old" do
|
||||
it "doesn't send message when flags are less than 48 hours old" do
|
||||
Fabricate(:flag, created_at: 47.hours.ago)
|
||||
PostAction.stubs(:flagged_posts_count).returns(1)
|
||||
Email::Sender.any_instance.expects(:send).never
|
||||
PostCreator.expects(:create).never
|
||||
described_class.new.execute({})
|
||||
end
|
||||
|
||||
it "sends email when there is a flag older than 48 hours" do
|
||||
it "sends message when there is a flag older than 48 hours" do
|
||||
Fabricate(:flag, created_at: 49.hours.ago)
|
||||
PostAction.stubs(:flagged_posts_count).returns(1)
|
||||
Email::Sender.any_instance.expects(:send).once.returns(true)
|
||||
PostCreator.expects(:create).once.returns(true)
|
||||
described_class.new.execute({})
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue