2013-08-26 16:15:59 -04:00
|
|
|
require_dependency 'admin_user_index_query'
|
|
|
|
|
|
|
|
module Jobs
|
|
|
|
|
|
|
|
class PendingUsersReminder < Jobs::Scheduled
|
2014-02-05 18:14:41 -05:00
|
|
|
every 9.hours
|
2013-08-26 16:15:59 -04:00
|
|
|
|
|
|
|
def execute(args)
|
|
|
|
if SiteSetting.must_approve_users
|
|
|
|
count = AdminUserIndexQuery.new({query: 'pending'}).find_users_query.count
|
|
|
|
if count > 0
|
2014-07-16 17:53:44 -04:00
|
|
|
target_usernames = Group[:moderators].users.map do |u|
|
|
|
|
u.id > 0 && u.notifications.joins(:topic)
|
|
|
|
.where("notifications.id > ?", u.seen_notification_id)
|
|
|
|
.where("notifications.read = false")
|
|
|
|
.where("topics.subtype = '#{TopicSubtype.pending_users_reminder}'")
|
|
|
|
.count == 0 ? u.username : nil
|
|
|
|
end.compact
|
|
|
|
|
|
|
|
unless target_usernames.empty?
|
|
|
|
PostCreator.create(
|
|
|
|
Discourse.system_user,
|
|
|
|
target_usernames: target_usernames,
|
|
|
|
archetype: Archetype.private_message,
|
|
|
|
subtype: TopicSubtype.pending_users_reminder,
|
|
|
|
title: I18n.t("system_messages.pending_users_reminder.subject_template", {count: count}),
|
|
|
|
raw: I18n.t("system_messages.pending_users_reminder.text_body_template", {count: count, base_url: Discourse.base_url})
|
|
|
|
)
|
|
|
|
end
|
2013-08-26 16:15:59 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|