2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-03-19 23:18:00 -04:00
|
|
|
class AdminDashboardData
|
2015-07-07 00:52:19 -04:00
|
|
|
include StatsCacheable
|
2013-03-19 23:18:00 -04:00
|
|
|
|
2023-11-05 19:57:02 -05:00
|
|
|
cattr_reader :problem_syms,
|
|
|
|
:problem_blocks,
|
|
|
|
:problem_messages,
|
|
|
|
:problem_scheduled_check_blocks,
|
|
|
|
:problem_scheduled_check_klasses
|
2021-12-19 18:59:11 -05:00
|
|
|
|
|
|
|
class Problem
|
|
|
|
VALID_PRIORITIES = %w[low high].freeze
|
|
|
|
|
|
|
|
attr_reader :message, :priority, :identifier
|
|
|
|
|
|
|
|
def initialize(message, priority: "low", identifier: nil)
|
|
|
|
@message = message
|
|
|
|
@priority = VALID_PRIORITIES.include?(priority) ? priority : "low"
|
|
|
|
@identifier = identifier
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
@message
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_h
|
|
|
|
{ message: message, priority: priority, identifier: identifier }
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.from_h(h)
|
|
|
|
h = h.with_indifferent_access
|
|
|
|
return if h[:message].blank?
|
|
|
|
new(h[:message], priority: h[:priority], identifier: h[:identifier])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-04-01 08:35:09 -04:00
|
|
|
# kept for backward compatibility
|
|
|
|
GLOBAL_REPORTS ||= []
|
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
PROBLEM_MESSAGE_PREFIX = "admin-problem:"
|
2023-11-02 21:05:29 -04:00
|
|
|
SCHEDULED_PROBLEM_STORAGE_KEY = "admin-found-scheduled-problems-list"
|
2021-12-19 18:59:11 -05:00
|
|
|
|
2019-04-01 06:39:49 -04:00
|
|
|
def initialize(opts = {})
|
|
|
|
@opts = opts
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_json
|
|
|
|
{}
|
|
|
|
end
|
|
|
|
|
|
|
|
def as_json(_options = nil)
|
|
|
|
@json ||= get_json
|
|
|
|
end
|
|
|
|
|
2013-04-25 17:53:31 -04:00
|
|
|
def problems
|
2015-08-25 20:07:40 -04:00
|
|
|
problems = []
|
2021-12-19 18:59:11 -05:00
|
|
|
self.class.problem_syms.each do |sym|
|
|
|
|
message = public_send(sym)
|
|
|
|
problems << Problem.new(message) if message.present?
|
2015-08-25 20:07:40 -04:00
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
self.class.problem_blocks.each do |blk|
|
|
|
|
message = instance_exec(&blk)
|
|
|
|
problems << Problem.new(message) if message.present?
|
2015-08-25 20:07:40 -04:00
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
self.class.problem_messages.each do |i18n_key|
|
|
|
|
message = self.class.problem_message_check(i18n_key)
|
|
|
|
problems << Problem.new(message) if message.present?
|
2016-04-05 14:42:24 -04:00
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
problems += self.class.load_found_scheduled_check_problems
|
2016-04-08 16:44:04 -04:00
|
|
|
problems.compact!
|
|
|
|
|
|
|
|
if problems.empty?
|
|
|
|
self.class.clear_problems_started
|
|
|
|
else
|
|
|
|
self.class.set_problems_started
|
|
|
|
end
|
|
|
|
|
|
|
|
problems
|
|
|
|
end
|
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
def self.add_problem_check(*syms, &blk)
|
|
|
|
@@problem_syms.push(*syms) if syms
|
|
|
|
@@problem_blocks << blk if blk
|
2016-04-08 16:44:04 -04:00
|
|
|
end
|
|
|
|
|
2023-11-05 19:57:02 -05:00
|
|
|
def self.add_scheduled_problem_check(check_identifier, klass = nil, &blk)
|
|
|
|
@@problem_scheduled_check_klasses[check_identifier] = klass
|
2021-12-19 18:59:11 -05:00
|
|
|
@@problem_scheduled_check_blocks[check_identifier] = blk
|
2016-04-08 16:44:04 -04:00
|
|
|
end
|
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
def self.add_found_scheduled_check_problem(problem)
|
|
|
|
problems = load_found_scheduled_check_problems
|
|
|
|
if problem.identifier.present?
|
|
|
|
return if problems.find { |p| p.identifier == problem.identifier }
|
|
|
|
end
|
2023-11-02 21:05:29 -04:00
|
|
|
set_found_scheduled_check_problem(problem)
|
2016-04-08 16:44:04 -04:00
|
|
|
end
|
|
|
|
|
2023-11-02 21:05:29 -04:00
|
|
|
def self.set_found_scheduled_check_problem(problem)
|
|
|
|
Discourse.redis.rpush(SCHEDULED_PROBLEM_STORAGE_KEY, JSON.dump(problem.to_h))
|
2015-08-25 20:07:40 -04:00
|
|
|
end
|
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
def self.clear_found_scheduled_check_problems
|
|
|
|
Discourse.redis.del(SCHEDULED_PROBLEM_STORAGE_KEY)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.clear_found_problem(identifier)
|
|
|
|
problems = load_found_scheduled_check_problems
|
2023-11-02 21:05:29 -04:00
|
|
|
problem = problems.find { |p| p.identifier == identifier }
|
|
|
|
Discourse.redis.lrem(SCHEDULED_PROBLEM_STORAGE_KEY, 1, JSON.dump(problem.to_h))
|
2021-12-19 18:59:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.load_found_scheduled_check_problems
|
2023-11-02 21:05:29 -04:00
|
|
|
found_problems = Discourse.redis.lrange(SCHEDULED_PROBLEM_STORAGE_KEY, 0, -1)
|
|
|
|
|
|
|
|
return [] if found_problems.blank?
|
|
|
|
|
|
|
|
found_problems.filter_map do |problem|
|
|
|
|
begin
|
|
|
|
Problem.from_h(JSON.parse(problem))
|
|
|
|
rescue JSON::ParserError => err
|
|
|
|
Discourse.warn_exception(
|
|
|
|
err,
|
|
|
|
message: "Error parsing found problem JSON in admin dashboard: #{problem}",
|
|
|
|
)
|
|
|
|
nil
|
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.register_default_scheduled_problem_checks
|
2023-11-05 19:57:02 -05:00
|
|
|
add_scheduled_problem_check(:group_smtp_credentials, GroupEmailCredentialsCheck) do
|
2022-01-03 19:14:33 -05:00
|
|
|
problems = GroupEmailCredentialsCheck.run
|
|
|
|
problems.map do |p|
|
|
|
|
problem_message =
|
|
|
|
I18n.t(
|
|
|
|
"dashboard.group_email_credentials_warning",
|
|
|
|
{
|
|
|
|
base_path: Discourse.base_path,
|
|
|
|
group_name: p[:group_name],
|
|
|
|
group_full_name: p[:group_full_name],
|
|
|
|
error: p[:message],
|
|
|
|
},
|
2023-01-09 07:20:10 -05:00
|
|
|
)
|
2022-01-03 19:14:33 -05:00
|
|
|
Problem.new(
|
|
|
|
problem_message,
|
|
|
|
priority: "high",
|
|
|
|
identifier: "group_#{p[:group_id]}_email_credentials",
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.execute_scheduled_checks
|
2023-11-02 21:05:29 -04:00
|
|
|
problem_scheduled_check_blocks.keys.each do |check_identifier|
|
|
|
|
Jobs.enqueue(:problem_check, check_identifier: check_identifier.to_s)
|
|
|
|
end
|
|
|
|
end
|
2021-12-19 18:59:11 -05:00
|
|
|
|
2023-11-02 21:05:29 -04:00
|
|
|
def self.execute_scheduled_check(identifier)
|
|
|
|
check = problem_scheduled_check_blocks[identifier]
|
2021-12-19 18:59:11 -05:00
|
|
|
|
2023-11-02 21:05:29 -04:00
|
|
|
problems = instance_exec(&check)
|
2021-12-19 18:59:11 -05:00
|
|
|
|
2023-11-05 19:57:02 -05:00
|
|
|
yield(problems) if block_given? && problems.present?
|
|
|
|
|
2023-11-02 21:05:29 -04:00
|
|
|
Array
|
|
|
|
.wrap(problems)
|
|
|
|
.compact
|
|
|
|
.each do |problem|
|
|
|
|
next if !problem.is_a?(Problem)
|
|
|
|
|
|
|
|
add_found_scheduled_check_problem(problem)
|
|
|
|
end
|
|
|
|
rescue StandardError => err
|
|
|
|
Discourse.warn_exception(
|
|
|
|
err,
|
|
|
|
message: "A scheduled admin dashboard problem check (#{identifier}) errored.",
|
|
|
|
)
|
2021-12-19 18:59:11 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# We call this method in the class definition below
|
|
|
|
# so all of the problem checks in this class are registered on
|
|
|
|
# boot. These problem checks are run when the problems are loaded in
|
|
|
|
# the admin dashboard controller.
|
|
|
|
#
|
|
|
|
# This method also can be used in testing to reset checks between
|
|
|
|
# tests. It will also fire multiple times in development mode because
|
|
|
|
# classes are not cached.
|
2015-09-01 16:32:35 -04:00
|
|
|
def self.reset_problem_checks
|
2021-12-19 18:59:11 -05:00
|
|
|
@@problem_syms = []
|
|
|
|
@@problem_blocks = []
|
|
|
|
@@problem_scheduled_check_blocks = {}
|
2023-11-05 19:57:02 -05:00
|
|
|
@@problem_scheduled_check_klasses = {}
|
2016-04-08 17:33:47 -04:00
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
@@problem_messages = %w[
|
2016-04-08 17:33:47 -04:00
|
|
|
dashboard.bad_favicon_url
|
|
|
|
dashboard.poll_pop3_timeout
|
2019-11-07 18:58:19 -05:00
|
|
|
dashboard.poll_pop3_auth_error
|
2016-04-08 17:33:47 -04:00
|
|
|
]
|
2015-09-01 16:32:35 -04:00
|
|
|
|
2018-01-11 01:46:10 -05:00
|
|
|
add_problem_check :rails_env_check,
|
|
|
|
:host_names_check,
|
|
|
|
:force_https_check,
|
2016-05-25 07:08:48 -04:00
|
|
|
:ram_check,
|
|
|
|
:google_oauth2_config_check,
|
2015-09-01 16:32:35 -04:00
|
|
|
:facebook_config_check,
|
|
|
|
:twitter_config_check,
|
2020-12-28 10:43:48 -05:00
|
|
|
:github_config_check,
|
|
|
|
:s3_config_check,
|
|
|
|
:s3_cdn_check,
|
2019-01-08 19:46:11 -05:00
|
|
|
:image_magick_check,
|
|
|
|
:failing_emails_check,
|
2016-10-05 12:14:56 -04:00
|
|
|
:subfolder_ends_in_slash_check,
|
2021-12-19 18:59:11 -05:00
|
|
|
:email_polling_errored_recently,
|
2019-07-31 13:33:49 -04:00
|
|
|
:out_of_date_themes,
|
|
|
|
:unreachable_themes,
|
2023-04-04 08:14:20 -04:00
|
|
|
:watched_words_check,
|
2023-07-09 22:06:40 -04:00
|
|
|
:google_analytics_version_check,
|
2023-11-13 10:46:15 -05:00
|
|
|
:translation_overrides_check
|
2015-09-01 16:32:35 -04:00
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
register_default_scheduled_problem_checks
|
|
|
|
|
2015-09-01 16:32:35 -04:00
|
|
|
add_problem_check { sidekiq_check || queue_size_check }
|
2013-04-25 17:53:31 -04:00
|
|
|
end
|
2015-09-01 16:32:35 -04:00
|
|
|
reset_problem_checks
|
2014-05-21 18:19:40 -04:00
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
def self.fetch_stats
|
|
|
|
new.as_json
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.reports(source)
|
|
|
|
source.map { |type| Report.find(type).as_json }
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.stats_cache_key
|
|
|
|
"dashboard-data-#{Report::SCHEMA_VERSION}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.problems_started_key
|
|
|
|
"dash-problems-started-at"
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.set_problems_started
|
|
|
|
existing_time = Discourse.redis.get(problems_started_key)
|
|
|
|
Discourse.redis.setex(problems_started_key, 14.days.to_i, existing_time || Time.zone.now.to_s)
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.clear_problems_started
|
|
|
|
Discourse.redis.del problems_started_key
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.problems_started_at
|
|
|
|
s = Discourse.redis.get(problems_started_key)
|
|
|
|
s ? Time.zone.parse(s) : nil
|
|
|
|
end
|
|
|
|
|
2018-01-11 01:46:10 -05:00
|
|
|
def self.fetch_problems(opts = {})
|
2021-12-19 18:59:11 -05:00
|
|
|
new(opts).problems
|
2013-03-29 15:48:26 -04:00
|
|
|
end
|
|
|
|
|
2016-04-05 14:42:24 -04:00
|
|
|
def self.problem_message_check(i18n_key)
|
2019-12-03 04:05:53 -05:00
|
|
|
if Discourse.redis.get(problem_message_key(i18n_key))
|
|
|
|
I18n.t(i18n_key, base_path: Discourse.base_path)
|
2023-01-09 07:20:10 -05:00
|
|
|
else
|
2019-12-03 04:05:53 -05:00
|
|
|
nil
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2016-04-05 14:42:24 -04:00
|
|
|
end
|
|
|
|
|
2021-12-19 18:59:11 -05:00
|
|
|
##
|
|
|
|
# Arbitrary messages cannot be added here, they must already be defined
|
|
|
|
# in the @problem_messages array which is defined in reset_problem_checks.
|
|
|
|
# The array is iterated over and each key that exists in redis will be added
|
|
|
|
# to the final problems output in #problems.
|
2016-04-05 14:42:24 -04:00
|
|
|
def self.add_problem_message(i18n_key, expire_seconds = nil)
|
|
|
|
if expire_seconds.to_i > 0
|
2019-12-03 04:05:53 -05:00
|
|
|
Discourse.redis.setex problem_message_key(i18n_key), expire_seconds.to_i, 1
|
2016-04-05 14:42:24 -04:00
|
|
|
else
|
2019-12-03 04:05:53 -05:00
|
|
|
Discourse.redis.set problem_message_key(i18n_key), 1
|
2016-04-05 14:42:24 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.clear_problem_message(i18n_key)
|
2019-12-03 04:05:53 -05:00
|
|
|
Discourse.redis.del problem_message_key(i18n_key)
|
2016-04-05 14:42:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.problem_message_key(i18n_key)
|
2021-12-19 18:59:11 -05:00
|
|
|
"#{PROBLEM_MESSAGE_PREFIX}#{i18n_key}"
|
2016-04-05 14:42:24 -04:00
|
|
|
end
|
|
|
|
|
2013-03-19 23:18:00 -04:00
|
|
|
def rails_env_check
|
2014-08-18 02:42:48 -04:00
|
|
|
I18n.t("dashboard.rails_env_warning", env: Rails.env) unless Rails.env.production?
|
2013-03-19 23:18:00 -04:00
|
|
|
end
|
2013-03-20 15:38:28 -04:00
|
|
|
|
|
|
|
def host_names_check
|
|
|
|
if %w[localhost production.localhost].include?(Discourse.current_hostname)
|
|
|
|
I18n.t("dashboard.host_names_warning")
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2013-03-20 15:38:28 -04:00
|
|
|
end
|
2013-03-20 16:16:23 -04:00
|
|
|
|
2013-03-22 11:35:32 -04:00
|
|
|
def sidekiq_check
|
|
|
|
last_job_performed_at = Jobs.last_job_performed_at
|
2017-02-15 03:21:17 -05:00
|
|
|
if Jobs.queued > 0 && (last_job_performed_at.nil? || last_job_performed_at < 2.minutes.ago)
|
|
|
|
I18n.t("dashboard.sidekiq_warning")
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2013-03-22 11:35:32 -04:00
|
|
|
end
|
|
|
|
|
2015-08-06 16:46:49 -04:00
|
|
|
def queue_size_check
|
|
|
|
queue_size = Jobs.queued
|
2023-02-16 04:40:11 -05:00
|
|
|
I18n.t("dashboard.queue_size_warning", queue_size: queue_size) if queue_size >= 100_000
|
2015-08-06 16:46:49 -04:00
|
|
|
end
|
|
|
|
|
2013-03-22 15:47:25 -04:00
|
|
|
def ram_check
|
2019-04-11 19:44:29 -04:00
|
|
|
I18n.t("dashboard.memory_warning") if MemInfo.new.mem_total && MemInfo.new.mem_total < 950_000
|
2013-03-22 15:47:25 -04:00
|
|
|
end
|
2013-03-29 13:31:00 -04:00
|
|
|
|
2014-05-21 18:19:40 -04:00
|
|
|
def google_oauth2_config_check
|
2018-11-07 11:59:42 -05:00
|
|
|
if SiteSetting.enable_google_oauth2_logins &&
|
|
|
|
(
|
|
|
|
SiteSetting.google_oauth2_client_id.blank? ||
|
|
|
|
SiteSetting.google_oauth2_client_secret.blank?
|
|
|
|
)
|
|
|
|
I18n.t("dashboard.google_oauth2_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
2014-05-21 18:19:40 -04:00
|
|
|
end
|
|
|
|
|
2013-03-29 13:31:00 -04:00
|
|
|
def facebook_config_check
|
2018-11-07 11:59:42 -05:00
|
|
|
if SiteSetting.enable_facebook_logins &&
|
|
|
|
(SiteSetting.facebook_app_id.blank? || SiteSetting.facebook_app_secret.blank?)
|
|
|
|
I18n.t("dashboard.facebook_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
2013-03-29 13:31:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def twitter_config_check
|
2018-11-07 11:59:42 -05:00
|
|
|
if SiteSetting.enable_twitter_logins &&
|
|
|
|
(SiteSetting.twitter_consumer_key.blank? || SiteSetting.twitter_consumer_secret.blank?)
|
|
|
|
I18n.t("dashboard.twitter_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
2013-03-29 13:31:00 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def github_config_check
|
2018-11-07 11:59:42 -05:00
|
|
|
if SiteSetting.enable_github_logins &&
|
|
|
|
(SiteSetting.github_client_id.blank? || SiteSetting.github_client_secret.blank?)
|
|
|
|
I18n.t("dashboard.github_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
2013-06-19 16:11:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def s3_config_check
|
2018-07-09 01:38:06 -04:00
|
|
|
# if set via global setting it is validated during the `use_s3?` call
|
|
|
|
if !GlobalSetting.use_s3?
|
|
|
|
bad_keys =
|
|
|
|
(SiteSetting.s3_access_key_id.blank? || SiteSetting.s3_secret_access_key.blank?) &&
|
|
|
|
!SiteSetting.s3_use_iam_profile
|
2014-07-05 18:16:13 -04:00
|
|
|
|
2018-11-07 11:59:42 -05:00
|
|
|
if SiteSetting.enable_s3_uploads && (bad_keys || SiteSetting.s3_upload_bucket.blank?)
|
|
|
|
return I18n.t("dashboard.s3_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
if SiteSetting.backup_location == BackupLocationSiteSetting::S3 &&
|
|
|
|
(bad_keys || SiteSetting.s3_backup_bucket.blank?)
|
|
|
|
return I18n.t("dashboard.s3_backup_config_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
2018-07-09 01:38:06 -04:00
|
|
|
end
|
2014-03-17 15:56:59 -04:00
|
|
|
nil
|
2013-03-29 13:31:00 -04:00
|
|
|
end
|
2013-04-22 13:37:16 -04:00
|
|
|
|
2020-12-28 10:43:48 -05:00
|
|
|
def s3_cdn_check
|
|
|
|
if (GlobalSetting.use_s3? || SiteSetting.enable_s3_uploads) &&
|
|
|
|
SiteSetting.Upload.s3_cdn_url.blank?
|
2020-12-29 12:09:55 -05:00
|
|
|
I18n.t("dashboard.s3_cdn_warning")
|
2020-12-28 10:43:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-07-09 22:06:40 -04:00
|
|
|
def translation_overrides_check
|
|
|
|
if TranslationOverride.exists?(status: %i[outdated invalid_interpolation_keys])
|
|
|
|
I18n.t("dashboard.outdated_translations_warning", base_path: Discourse.base_path)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-19 16:36:56 -04:00
|
|
|
def image_magick_check
|
2017-02-15 03:21:17 -05:00
|
|
|
if SiteSetting.create_thumbnails && !system("command -v convert >/dev/null;")
|
|
|
|
I18n.t("dashboard.image_magick_warning")
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2013-06-19 16:36:56 -04:00
|
|
|
end
|
|
|
|
|
2013-04-22 13:37:16 -04:00
|
|
|
def failing_emails_check
|
|
|
|
num_failed_jobs = Jobs.num_email_retry_jobs
|
2018-11-07 11:59:42 -05:00
|
|
|
if num_failed_jobs > 0
|
|
|
|
I18n.t(
|
|
|
|
"dashboard.failing_emails_warning",
|
|
|
|
num_failed_jobs: num_failed_jobs,
|
|
|
|
base_path: Discourse.base_path,
|
|
|
|
)
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2013-04-22 13:37:16 -04:00
|
|
|
end
|
2013-04-22 15:38:48 -04:00
|
|
|
|
2015-09-06 23:20:59 -04:00
|
|
|
def subfolder_ends_in_slash_check
|
2023-01-20 13:52:49 -05:00
|
|
|
I18n.t("dashboard.subfolder_ends_in_slash") if Discourse.base_path =~ %r{/\z}
|
2015-09-06 23:20:59 -04:00
|
|
|
end
|
|
|
|
|
2023-04-04 08:14:20 -04:00
|
|
|
def google_analytics_version_check
|
|
|
|
I18n.t("dashboard.v3_analytics_deprecated") if SiteSetting.ga_version == "v3_analytics"
|
|
|
|
end
|
|
|
|
|
2016-03-16 16:17:48 -04:00
|
|
|
def email_polling_errored_recently
|
|
|
|
errors = Jobs::PollMailbox.errors_in_past_24_hours
|
2018-11-07 11:59:42 -05:00
|
|
|
if errors > 0
|
|
|
|
I18n.t(
|
|
|
|
"dashboard.email_polling_errored_recently",
|
|
|
|
count: errors,
|
|
|
|
base_path: Discourse.base_path,
|
|
|
|
)
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2016-03-16 16:17:48 -04:00
|
|
|
end
|
|
|
|
|
2016-05-30 11:11:17 -04:00
|
|
|
def missing_mailgun_api_key
|
|
|
|
return unless SiteSetting.reply_by_email_enabled
|
2019-04-01 06:39:49 -04:00
|
|
|
return unless ActionMailer::Base.smtp_settings[:address]["smtp.mailgun.org"]
|
2016-05-30 11:11:17 -04:00
|
|
|
return unless SiteSetting.mailgun_api_key.blank?
|
|
|
|
I18n.t("dashboard.missing_mailgun_api_key")
|
|
|
|
end
|
|
|
|
|
2018-01-11 01:46:10 -05:00
|
|
|
def force_https_check
|
|
|
|
return unless @opts[:check_force_https]
|
2018-11-07 11:59:42 -05:00
|
|
|
unless SiteSetting.force_https
|
|
|
|
I18n.t("dashboard.force_https_warning", base_path: Discourse.base_path)
|
2023-01-09 07:20:10 -05:00
|
|
|
end
|
2018-01-11 01:46:10 -05:00
|
|
|
end
|
|
|
|
|
2019-07-31 13:33:49 -04:00
|
|
|
def watched_words_check
|
|
|
|
WatchedWord.actions.keys.each do |action|
|
|
|
|
begin
|
2023-11-01 10:41:10 -04:00
|
|
|
WordWatcher.compiled_regexps_for_action(action, raise_errors: true)
|
2019-07-31 13:33:49 -04:00
|
|
|
rescue RegexpError => e
|
2021-07-09 09:34:08 -04:00
|
|
|
translated_action = I18n.t("admin_js.admin.watched_words.actions.#{action}")
|
|
|
|
I18n.t(
|
|
|
|
"dashboard.watched_word_regexp_error",
|
|
|
|
base_path: Discourse.base_path,
|
|
|
|
action: translated_action,
|
|
|
|
)
|
2019-07-31 13:33:49 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2018-08-02 19:53:48 -04:00
|
|
|
def out_of_date_themes
|
|
|
|
old_themes = RemoteTheme.out_of_date_themes
|
|
|
|
return unless old_themes.present?
|
|
|
|
|
2019-04-01 06:39:49 -04:00
|
|
|
themes_html_format(old_themes, "dashboard.out_of_date_themes")
|
2018-09-08 09:24:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def unreachable_themes
|
|
|
|
themes = RemoteTheme.unreachable_themes
|
|
|
|
return unless themes.present?
|
|
|
|
|
2019-04-01 06:39:49 -04:00
|
|
|
themes_html_format(themes, "dashboard.unreachable_themes")
|
2018-09-08 09:24:11 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def themes_html_format(themes, i18n_key)
|
|
|
|
html =
|
|
|
|
themes
|
|
|
|
.map do |name, id|
|
2018-08-02 19:53:48 -04:00
|
|
|
"<li><a href=\"/admin/customize/themes/#{id}\">#{CGI.escapeHTML(name)}</a></li>"
|
|
|
|
end
|
|
|
|
.join("\n")
|
|
|
|
|
2019-04-01 06:39:49 -04:00
|
|
|
"#{I18n.t(i18n_key)}<ul>#{html}</ul>"
|
2018-08-02 19:53:48 -04:00
|
|
|
end
|
2013-06-19 16:11:11 -04:00
|
|
|
end
|