2014-04-04 02:34:21 +08:00
|
|
|
require_dependency 'flag_query'
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class PendingFlagsReminder < Jobs::Scheduled
|
|
|
|
|
|
|
|
every 1.day
|
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
if SiteSetting.notify_about_flags_after > 0 &&
|
|
|
|
PostAction.flagged_posts_count > 0 &&
|
2016-04-01 05:33:25 +08:00
|
|
|
FlagQuery.flagged_post_actions('active').where('post_actions.created_at < ?', SiteSetting.notify_about_flags_after.to_i.hours.ago).pluck(:id).count > 0
|
2014-04-04 02:34:21 +08:00
|
|
|
|
2016-04-01 05:33:25 +08:00
|
|
|
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 })
|
|
|
|
)
|
2014-04-04 02:34:21 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|