2014-04-03 14:34:21 -04: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-02-12 14:33:13 -05: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-03 14:34:21 -04:00
|
|
|
|
2016-02-19 15:21:05 -05:00
|
|
|
PostCreator.create(
|
|
|
|
Discourse.system_user,
|
2016-08-05 08:38:24 -04:00
|
|
|
target_group_names: Group[:staff].name,
|
2016-02-19 15:21:05 -05:00
|
|
|
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-03 14:34:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|