mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 08:18:18 +08:00
DEV: Remove logical OR assignment of constants (#29201)
Constants should always be only assigned once. The logical OR assignment of a constant is a relic of the past before we used zeitwerk for autoloading and had bugs where a file could be loaded twice resulting in constant redefinition warnings.
This commit is contained in:
parent
f3f37c9019
commit
322a3be2db
|
@ -40,7 +40,7 @@ class Admin::ThemesController < Admin::AdminController
|
|||
render json: { public_key: k.ssh_public_key }
|
||||
end
|
||||
|
||||
THEME_CONTENT_TYPES ||= %w[
|
||||
THEME_CONTENT_TYPES = %w[
|
||||
application/gzip
|
||||
application/x-gzip
|
||||
application/x-zip-compressed
|
||||
|
|
|
@ -56,8 +56,8 @@ class ApplicationController < ActionController::Base
|
|||
after_action :clean_xml, if: :is_feed_response?
|
||||
after_action :add_early_hint_header, if: -> { spa_boot_request? }
|
||||
|
||||
HONEYPOT_KEY ||= "HONEYPOT_KEY"
|
||||
CHALLENGE_KEY ||= "CHALLENGE_KEY"
|
||||
HONEYPOT_KEY = "HONEYPOT_KEY"
|
||||
CHALLENGE_KEY = "CHALLENGE_KEY"
|
||||
|
||||
layout :set_layout
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ class ExtraLocalesController < ApplicationController
|
|||
:redirect_to_profile_if_required,
|
||||
:verify_authenticity_token
|
||||
|
||||
OVERRIDES_BUNDLE ||= "overrides"
|
||||
MD5_HASH_LENGTH ||= 32
|
||||
OVERRIDES_BUNDLE = "overrides"
|
||||
MD5_HASH_LENGTH = 32
|
||||
MF_BUNDLE = "mf"
|
||||
BUNDLES = [OVERRIDES_BUNDLE, MF_BUNDLE]
|
||||
|
||||
|
|
|
@ -595,7 +595,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
MAX_NOTIFIED_OWNERS ||= 20
|
||||
MAX_NOTIFIED_OWNERS = 20
|
||||
|
||||
def request_membership
|
||||
params.require(:reason)
|
||||
|
|
|
@ -27,7 +27,7 @@ class PostsController < ApplicationController
|
|||
:check_xhr,
|
||||
only: %i[markdown_id markdown_num short_link latest user_posts_feed]
|
||||
|
||||
MARKDOWN_TOPIC_PAGE_SIZE ||= 100
|
||||
MARKDOWN_TOPIC_PAGE_SIZE = 100
|
||||
|
||||
def markdown_id
|
||||
markdown Post.find_by(id: params[:id].to_i)
|
||||
|
@ -429,7 +429,7 @@ class PostsController < ApplicationController
|
|||
render_json_error(e.message)
|
||||
end
|
||||
|
||||
MAX_POST_REPLIES ||= 20
|
||||
MAX_POST_REPLIES = 20
|
||||
|
||||
def replies
|
||||
params.permit(:after)
|
||||
|
|
|
@ -5,7 +5,7 @@ class PresenceController < ApplicationController
|
|||
before_action :ensure_logged_in, only: [:update]
|
||||
before_action :skip_persist_session
|
||||
|
||||
MAX_CHANNELS_PER_REQUEST ||= 50
|
||||
MAX_CHANNELS_PER_REQUEST = 50
|
||||
|
||||
def get
|
||||
names = params.require(:channels)
|
||||
|
|
|
@ -10,7 +10,7 @@ class RobotsTxtController < ApplicationController
|
|||
OVERRIDDEN_HEADER = "# This robots.txt file has been customized at /admin/customize/robots\n"
|
||||
|
||||
# NOTE: order is important!
|
||||
DISALLOWED_PATHS ||= %w[
|
||||
DISALLOWED_PATHS = %w[
|
||||
/admin/
|
||||
/auth/
|
||||
/assets/browser-update*.js
|
||||
|
@ -21,7 +21,7 @@ class RobotsTxtController < ApplicationController
|
|||
/*?*api_key*
|
||||
]
|
||||
|
||||
DISALLOWED_WITH_HEADER_PATHS ||= %w[/badges /u/ /my /search /tag/*/l /g /t/*/*.rss /c/*.rss]
|
||||
DISALLOWED_WITH_HEADER_PATHS = %w[/badges /u/ /my /search /tag/*/l /g /t/*/*.rss /c/*.rss]
|
||||
|
||||
def index
|
||||
if (overridden = SiteSetting.overridden_robots_txt.dup).present?
|
||||
|
|
|
@ -145,7 +145,7 @@ class StaticController < ApplicationController
|
|||
redirect_to(destination, allow_other_host: false)
|
||||
end
|
||||
|
||||
FAVICON ||= -"favicon"
|
||||
FAVICON = -"favicon"
|
||||
|
||||
# We need to be able to draw our favicon on a canvas, this happens when you enable the feature
|
||||
# that draws the notification count on top of favicon (per user default off)
|
||||
|
|
|
@ -9,7 +9,7 @@ class UserApiKeysController < ApplicationController
|
|||
only: %i[new otp]
|
||||
skip_before_action :check_xhr, :preload_json
|
||||
|
||||
AUTH_API_VERSION ||= 4
|
||||
AUTH_API_VERSION = 4
|
||||
|
||||
def new
|
||||
if request.head?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Users::AssociateAccountsController < ApplicationController
|
||||
SECURE_SESSION_PREFIX ||= "omniauth_reconnect"
|
||||
SECURE_SESSION_PREFIX = "omniauth_reconnect"
|
||||
|
||||
before_action :ensure_logged_in
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ module Jobs
|
|||
attr_accessor :current_user
|
||||
attr_accessor :entity
|
||||
|
||||
HEADER_ATTRS_FOR ||=
|
||||
HEADER_ATTRS_FOR =
|
||||
HashWithIndifferentAccess.new(
|
||||
user_list: %w[
|
||||
id
|
||||
|
|
|
@ -10,7 +10,7 @@ module Jobs
|
|||
# note: contents provided entirely by user
|
||||
attr_accessor :extra
|
||||
|
||||
COMPONENTS ||= %w[
|
||||
COMPONENTS = %w[
|
||||
user_archive
|
||||
preferences
|
||||
auth_tokens
|
||||
|
@ -25,7 +25,7 @@ module Jobs
|
|||
visits
|
||||
]
|
||||
|
||||
HEADER_ATTRS_FOR ||=
|
||||
HEADER_ATTRS_FOR =
|
||||
HashWithIndifferentAccess.new(
|
||||
user_archive: %w[
|
||||
topic_title
|
||||
|
|
|
@ -93,8 +93,7 @@ module Jobs
|
|||
@skip_context = { type: type, user_id: user_id, to_address: to_address, post_id: post_id }
|
||||
end
|
||||
|
||||
NOTIFICATIONS_SENT_BY_MAILING_LIST ||=
|
||||
Set.new %w[posted replied mentioned group_mentioned quoted]
|
||||
NOTIFICATIONS_SENT_BY_MAILING_LIST = Set.new %w[posted replied mentioned group_mentioned quoted]
|
||||
|
||||
def message_for_email(user, post, type, notification, args = nil)
|
||||
args ||= {}
|
||||
|
|
|
@ -4,7 +4,7 @@ module Jobs
|
|||
class UpdateAnimatedUploads < ::Jobs::Scheduled
|
||||
every 1.hour
|
||||
|
||||
MAX_PROCESSED_GIF_IMAGES ||= 200
|
||||
MAX_PROCESSED_GIF_IMAGES = 200
|
||||
|
||||
def execute(args)
|
||||
Upload
|
||||
|
|
|
@ -6,7 +6,7 @@ class AdminDashboardData
|
|||
cattr_reader :problem_messages, default: []
|
||||
|
||||
# kept for backward compatibility
|
||||
GLOBAL_REPORTS ||= []
|
||||
GLOBAL_REPORTS = []
|
||||
|
||||
PROBLEM_MESSAGE_PREFIX = "admin-problem:"
|
||||
SCHEDULED_PROBLEM_STORAGE_KEY = "admin-found-scheduled-problems-list"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BackupLocationSiteSetting < EnumSiteSetting
|
||||
LOCAL ||= "local"
|
||||
S3 ||= "s3"
|
||||
LOCAL = "local"
|
||||
S3 = "s3"
|
||||
|
||||
def self.valid_value?(val)
|
||||
values.any? { |v| v[:value] == val }
|
||||
|
|
|
@ -4,7 +4,7 @@ module HasCustomFields
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
module Helpers
|
||||
CUSTOM_FIELD_TRUE ||= %w[1 t true T True TRUE].freeze
|
||||
CUSTOM_FIELD_TRUE = %w[1 t true T True TRUE].freeze
|
||||
end
|
||||
|
||||
class FieldDescriptor < Struct.new(:type, :max_length)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Draft < ActiveRecord::Base
|
||||
NEW_TOPIC ||= "new_topic"
|
||||
NEW_PRIVATE_MESSAGE ||= "new_private_message"
|
||||
EXISTING_TOPIC ||= "topic_"
|
||||
NEW_TOPIC = "new_topic"
|
||||
NEW_PRIVATE_MESSAGE = "new_private_message"
|
||||
EXISTING_TOPIC = "topic_"
|
||||
|
||||
belongs_to :user
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class EmailLog < ActiveRecord::Base
|
||||
CRITICAL_EMAIL_TYPES ||=
|
||||
CRITICAL_EMAIL_TYPES =
|
||||
Set.new %w[
|
||||
account_created
|
||||
admin_login
|
||||
|
|
|
@ -4,9 +4,9 @@ class Emoji
|
|||
# update this to clear the cache
|
||||
EMOJI_VERSION = "12"
|
||||
|
||||
FITZPATRICK_SCALE ||= %w[1f3fb 1f3fc 1f3fd 1f3fe 1f3ff]
|
||||
FITZPATRICK_SCALE = %w[1f3fb 1f3fc 1f3fd 1f3fe 1f3ff]
|
||||
|
||||
DEFAULT_GROUP ||= "default"
|
||||
DEFAULT_GROUP = "default"
|
||||
|
||||
include ActiveModel::SerializerSupport
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ class GlobalSetting
|
|||
define_singleton_method(key) { provider.lookup(key, default) }
|
||||
end
|
||||
|
||||
VALID_SECRET_KEY ||= /\A[0-9a-f]{128}\z/
|
||||
VALID_SECRET_KEY = /\A[0-9a-f]{128}\z/
|
||||
# this is named SECRET_TOKEN as opposed to SECRET_KEY_BASE
|
||||
# for legacy reasons
|
||||
REDIS_SECRET_KEY ||= "SECRET_TOKEN"
|
||||
REDIS_SECRET_KEY = "SECRET_TOKEN"
|
||||
|
||||
REDIS_VALIDATE_SECONDS ||= 30
|
||||
REDIS_VALIDATE_SECONDS = 30
|
||||
|
||||
# In Rails secret_key_base is used to encrypt the cookie store
|
||||
# the cookie store contains session data
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ImapSyncLog < ActiveRecord::Base
|
||||
RETAIN_LOGS_DAYS ||= 5
|
||||
RETAIN_LOGS_DAYS = 5
|
||||
|
||||
belongs_to :group
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class LocaleSiteSetting < EnumSiteSetting
|
|||
@lock.synchronize { @values = @language_names = @supported_locales = nil }
|
||||
end
|
||||
|
||||
FALLBACKS ||= { en_GB: :en }
|
||||
FALLBACKS = { en_GB: :en }
|
||||
|
||||
def self.fallback_locale(locale)
|
||||
fallback_locale = FALLBACKS[locale.to_sym]
|
||||
|
|
|
@ -6,7 +6,7 @@ class OptimizedImage < ActiveRecord::Base
|
|||
|
||||
# BUMP UP if optimized image algorithm changes
|
||||
VERSION = 2
|
||||
URL_REGEX ||= %r{(/optimized/\dX[/\.\w]*/([a-zA-Z0-9]+)[\.\w]*)}
|
||||
URL_REGEX = %r{(/optimized/\dX[/\.\w]*/([a-zA-Z0-9]+)[\.\w]*)}
|
||||
|
||||
def self.lock(upload_id, width, height)
|
||||
@hostname ||= Discourse.os_hostname
|
||||
|
@ -185,7 +185,7 @@ class OptimizedImage < ActiveRecord::Base
|
|||
paths.each { |path| raise Discourse::InvalidAccess unless safe_path?(path) }
|
||||
end
|
||||
|
||||
IM_DECODERS ||= /\A(jpe?g|png|ico|gif|webp|avif)\z/i
|
||||
IM_DECODERS = /\A(jpe?g|png|ico|gif|webp|avif)\z/i
|
||||
|
||||
def self.prepend_decoder!(path, ext_path = nil, opts = nil)
|
||||
opts ||= {}
|
||||
|
|
|
@ -77,11 +77,11 @@ class Post < ActiveRecord::Base
|
|||
:skip_unique_check,
|
||||
:skip_validation
|
||||
|
||||
MISSING_UPLOADS ||= "missing uploads"
|
||||
MISSING_UPLOADS_IGNORED ||= "missing uploads ignored"
|
||||
NOTICE ||= "notice"
|
||||
MISSING_UPLOADS = "missing uploads"
|
||||
MISSING_UPLOADS_IGNORED = "missing uploads ignored"
|
||||
NOTICE = "notice"
|
||||
|
||||
SHORT_POST_CHARS ||= 1200
|
||||
SHORT_POST_CHARS = 1200
|
||||
|
||||
register_custom_field_type(MISSING_UPLOADS, :json)
|
||||
register_custom_field_type(MISSING_UPLOADS_IGNORED, :boolean)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveMutedTagsFromLatestSiteSetting < EnumSiteSetting
|
||||
ALWAYS ||= "always"
|
||||
ONLY_MUTED ||= "only_muted"
|
||||
NEVER ||= "never"
|
||||
ALWAYS = "always"
|
||||
ONLY_MUTED = "only_muted"
|
||||
NEVER = "never"
|
||||
|
||||
def self.valid_value?(val)
|
||||
values.any? { |v| v[:value] == val }
|
||||
|
|
|
@ -697,7 +697,7 @@ class Topic < ActiveRecord::Base
|
|||
!self.closed?
|
||||
end
|
||||
|
||||
MAX_SIMILAR_BODY_LENGTH ||= 200
|
||||
MAX_SIMILAR_BODY_LENGTH = 200
|
||||
|
||||
def self.similar_to(title, raw, user = nil)
|
||||
return [] if SiteSetting.max_similar_results == 0
|
||||
|
@ -1728,7 +1728,7 @@ class Topic < ActiveRecord::Base
|
|||
DB.exec(sql, user_id: user.id, topic_id: id) > 0
|
||||
end
|
||||
|
||||
TIME_TO_FIRST_RESPONSE_SQL ||= <<-SQL
|
||||
TIME_TO_FIRST_RESPONSE_SQL = <<-SQL
|
||||
SELECT AVG(t.hours)::float AS "hours", t.created_at AS "date"
|
||||
FROM (
|
||||
SELECT t.id, t.created_at::date AS created_at, EXTRACT(EPOCH FROM MIN(p.created_at) - t.created_at)::float / 3600.0 AS "hours"
|
||||
|
@ -1741,7 +1741,7 @@ class Topic < ActiveRecord::Base
|
|||
ORDER BY t.created_at
|
||||
SQL
|
||||
|
||||
TIME_TO_FIRST_RESPONSE_TOTAL_SQL ||= <<-SQL
|
||||
TIME_TO_FIRST_RESPONSE_TOTAL_SQL = <<-SQL
|
||||
SELECT AVG(t.hours)::float AS "hours"
|
||||
FROM (
|
||||
SELECT t.id, EXTRACT(EPOCH FROM MIN(p.created_at) - t.created_at)::float / 3600.0 AS "hours"
|
||||
|
@ -1787,7 +1787,7 @@ class Topic < ActiveRecord::Base
|
|||
total.first["hours"].to_f.round(2)
|
||||
end
|
||||
|
||||
WITH_NO_RESPONSE_SQL ||= <<-SQL
|
||||
WITH_NO_RESPONSE_SQL = <<-SQL
|
||||
SELECT COUNT(*) as count, tt.created_at AS "date"
|
||||
FROM (
|
||||
SELECT t.id, t.created_at::date AS created_at, MIN(p.post_number) first_reply
|
||||
|
@ -1822,7 +1822,7 @@ class Topic < ActiveRecord::Base
|
|||
builder.query_hash
|
||||
end
|
||||
|
||||
WITH_NO_RESPONSE_TOTAL_SQL ||= <<-SQL
|
||||
WITH_NO_RESPONSE_TOTAL_SQL = <<-SQL
|
||||
SELECT COUNT(*) as count
|
||||
FROM (
|
||||
SELECT t.id, MIN(p.post_number) first_reply
|
||||
|
|
|
@ -364,7 +364,7 @@ class User < ActiveRecord::Base
|
|||
LAST_VISIT = -2
|
||||
end
|
||||
|
||||
MAX_STAFF_DELETE_POST_COUNT ||= 5
|
||||
MAX_STAFF_DELETE_POST_COUNT = 5
|
||||
|
||||
def self.user_tips
|
||||
@user_tips ||=
|
||||
|
@ -1568,7 +1568,7 @@ class User < ActiveRecord::Base
|
|||
result
|
||||
end
|
||||
|
||||
USER_FIELD_PREFIX ||= "user_field_"
|
||||
USER_FIELD_PREFIX = "user_field_"
|
||||
|
||||
def user_fields(field_ids = nil)
|
||||
field_ids = (@all_user_field_ids ||= UserField.pluck(:id)) if field_ids.nil?
|
||||
|
@ -1711,7 +1711,7 @@ class User < ActiveRecord::Base
|
|||
.pluck(:new_email)
|
||||
end
|
||||
|
||||
RECENT_TIME_READ_THRESHOLD ||= 60.days
|
||||
RECENT_TIME_READ_THRESHOLD = 60.days
|
||||
|
||||
def self.preload_recent_time_read(users)
|
||||
times =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class UserSearch
|
||||
MAX_SIZE_PRIORITY_MENTION ||= 500
|
||||
MAX_SIZE_PRIORITY_MENTION = 500
|
||||
|
||||
def initialize(term, opts = {})
|
||||
@term = term.downcase
|
||||
|
|
|
@ -79,7 +79,7 @@ class UserSummary
|
|||
user_counts(liked_users)
|
||||
end
|
||||
|
||||
REPLY_ACTIONS ||= [UserAction::RESPONSE, UserAction::QUOTE, UserAction::MENTION]
|
||||
REPLY_ACTIONS = [UserAction::RESPONSE, UserAction::QUOTE, UserAction::MENTION]
|
||||
|
||||
def most_replied_to_users
|
||||
replied_users = {}
|
||||
|
|
|
@ -40,10 +40,10 @@ class UsernameValidator
|
|||
errors.empty?
|
||||
end
|
||||
|
||||
CONFUSING_EXTENSIONS ||= /\.(js|json|css|htm|html|xml|jpg|jpeg|png|gif|bmp|ico|tif|tiff|woff)\z/i
|
||||
MAX_CHARS ||= 60
|
||||
CONFUSING_EXTENSIONS = /\.(js|json|css|htm|html|xml|jpg|jpeg|png|gif|bmp|ico|tif|tiff|woff)\z/i
|
||||
MAX_CHARS = 60
|
||||
|
||||
ASCII_INVALID_CHAR_PATTERN ||= /[^\w.-]/
|
||||
ASCII_INVALID_CHAR_PATTERN = /[^\w.-]/
|
||||
# All Unicode characters except for alphabetic and numeric character, marks and underscores are invalid.
|
||||
# In addition to that, the following letters and nonspacing marks are invalid:
|
||||
# (U+034F) Combining Grapheme Joiner
|
||||
|
@ -56,7 +56,7 @@ class UsernameValidator
|
|||
# (U+FFA0) Halfwidth Hangul Filler
|
||||
# (U+FE00 - U+FE0F) "Variation Selectors" block
|
||||
# (U+E0100 - U+E01EF) "Variation Selectors Supplement" block
|
||||
UNICODE_INVALID_CHAR_PATTERN ||=
|
||||
UNICODE_INVALID_CHAR_PATTERN =
|
||||
/
|
||||
[^\p{Alnum}\p{M}._-]|
|
||||
[
|
||||
|
@ -72,9 +72,9 @@ class UsernameValidator
|
|||
\p{In Variation Selectors Supplement}
|
||||
]
|
||||
/x
|
||||
INVALID_LEADING_CHAR_PATTERN ||= /\A[^\p{Alnum}\p{M}_]+/
|
||||
INVALID_TRAILING_CHAR_PATTERN ||= /[^\p{Alnum}\p{M}]+\z/
|
||||
REPEATED_SPECIAL_CHAR_PATTERN ||= /[-_.]{2,}/
|
||||
INVALID_LEADING_CHAR_PATTERN = /\A[^\p{Alnum}\p{M}_]+/
|
||||
INVALID_TRAILING_CHAR_PATTERN = /[^\p{Alnum}\p{M}]+\z/
|
||||
REPEATED_SPECIAL_CHAR_PATTERN = /[-_.]{2,}/
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class PostSerializer < BasicPostSerializer
|
||||
# To pass in additional information we might need
|
||||
INSTANCE_VARS ||= %i[
|
||||
INSTANCE_VARS = %i[
|
||||
parent_post
|
||||
add_raw
|
||||
add_title
|
||||
|
|
|
@ -379,7 +379,7 @@ class BadgeGranter
|
|||
{ errors: e.message }
|
||||
end
|
||||
|
||||
MAX_ITEMS_FOR_DELTA ||= 200
|
||||
MAX_ITEMS_FOR_DELTA = 200
|
||||
def self.backfill(badge, opts = nil)
|
||||
return unless SiteSetting.enable_badges
|
||||
return unless badge.enabled
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PushNotificationPusher
|
||||
TOKEN_VALID_FOR_SECONDS ||= 5 * 60
|
||||
TOKEN_VALID_FOR_SECONDS = 5 * 60
|
||||
CONNECTION_TIMEOUT_SECONDS = 5
|
||||
|
||||
def self.push(user, payload)
|
||||
|
@ -108,8 +108,8 @@ class PushNotificationPusher
|
|||
end
|
||||
end
|
||||
|
||||
MAX_ERRORS ||= 3
|
||||
MIN_ERROR_DURATION ||= 86_400 # 1 day
|
||||
MAX_ERRORS = 3
|
||||
MIN_ERROR_DURATION = 86_400 # 1 day
|
||||
|
||||
def self.handle_generic_error(subscription, error, user, endpoint, message)
|
||||
subscription.error_count += 1
|
||||
|
|
|
@ -405,8 +405,8 @@ class SearchIndexer
|
|||
html_scrubber.scrubbed.squish
|
||||
end
|
||||
|
||||
MENTION_CLASSES ||= %w[mention mention-group]
|
||||
ATTRIBUTES ||= %w[alt title href data-video-title]
|
||||
MENTION_CLASSES = %w[mention mention-group]
|
||||
ATTRIBUTES = %w[alt title href data-video-title]
|
||||
|
||||
def start_element(_name, attributes = [])
|
||||
attributes = Hash[*attributes.flatten]
|
||||
|
|
|
@ -11,7 +11,7 @@ class StaffActionLogger
|
|||
raise Discourse::InvalidParameters.new(:admin) unless @admin && @admin.is_a?(User)
|
||||
end
|
||||
|
||||
USER_FIELDS ||= %i[id username name created_at trust_level last_seen_at last_emailed_at]
|
||||
USER_FIELDS = %i[id username name created_at trust_level last_seen_at last_emailed_at]
|
||||
|
||||
def log_user_deletion(deleted_user, opts = {})
|
||||
unless deleted_user && deleted_user.is_a?(User)
|
||||
|
@ -410,7 +410,7 @@ class StaffActionLogger
|
|||
)
|
||||
end
|
||||
|
||||
BADGE_FIELDS ||= %i[
|
||||
BADGE_FIELDS = %i[
|
||||
id
|
||||
name
|
||||
description
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class WordWatcher
|
||||
REPLACEMENT_LETTER ||= CGI.unescape_html("■")
|
||||
CACHE_VERSION ||= 3
|
||||
REPLACEMENT_LETTER = CGI.unescape_html("■")
|
||||
CACHE_VERSION = 3
|
||||
|
||||
def initialize(raw)
|
||||
@raw = raw
|
||||
|
|
|
@ -4,7 +4,7 @@ require "migration/column_dropper"
|
|||
require "badge_posts_view_manager"
|
||||
|
||||
class RemoveSuperfluousColumns < ActiveRecord::Migration[5.2]
|
||||
DROPPED_COLUMNS ||= {
|
||||
DROPPED_COLUMNS = {
|
||||
user_profiles: %i[card_image_badge_id],
|
||||
categories: %i[logo_url background_url suppress_from_homepage],
|
||||
groups: %i[visible public alias_level],
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/table_dropper"
|
||||
|
||||
class RemoveSuperfluousTables < ActiveRecord::Migration[5.2]
|
||||
DROPPED_TABLES ||= %i[category_featured_users versions topic_status_updates]
|
||||
DROPPED_TABLES = %i[category_featured_users versions topic_status_updates]
|
||||
|
||||
def up
|
||||
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class RemoveUploadedMetaIdFromCategory < ActiveRecord::Migration[5.2]
|
||||
DROPPED_COLUMNS ||= { categories: %i[uploaded_meta_id] }
|
||||
DROPPED_COLUMNS = { categories: %i[uploaded_meta_id] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class DropEmailUserOptionsColumns < ActiveRecord::Migration[5.2]
|
||||
DROPPED_COLUMNS ||= { user_options: %i[email_direct email_private_messages email_always] }
|
||||
DROPPED_COLUMNS = { user_options: %i[email_direct email_private_messages email_always] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class RemoveViaEmailFromInvite < ActiveRecord::Migration[5.2]
|
||||
DROPPED_COLUMNS ||= { invites: %i[via_email] }
|
||||
DROPPED_COLUMNS = { invites: %i[via_email] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveSuppressFromLatestFromCategory < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { categories: %i[suppress_from_latest] }
|
||||
DROPPED_COLUMNS = { categories: %i[suppress_from_latest] }
|
||||
|
||||
def up
|
||||
ids = DB.query_single("SELECT id::text FROM categories WHERE suppress_from_latest = TRUE")
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/table_dropper"
|
||||
|
||||
class DropUnusedGoogleInstagramAuthTables < ActiveRecord::Migration[6.0]
|
||||
DROPPED_TABLES ||= %i[google_user_infos instagram_user_infos]
|
||||
DROPPED_TABLES = %i[google_user_infos instagram_user_infos]
|
||||
|
||||
def up
|
||||
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
class RemoveKeyFromApiKeys < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { api_keys: %i[key] }
|
||||
DROPPED_COLUMNS = { api_keys: %i[key] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropUnusedColumns < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= {
|
||||
DROPPED_COLUMNS = {
|
||||
post_replies: %i[reply_id],
|
||||
user_profiles: %i[card_background profile_background],
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveKeyFromUserApiKey < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { user_api_keys: %i[key] }
|
||||
DROPPED_COLUMNS = { user_api_keys: %i[key] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropAutomaticMembershipRetroactiveFromGroup < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { groups: %i[automatic_membership_retroactive] }
|
||||
DROPPED_COLUMNS = { groups: %i[automatic_membership_retroactive] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropTopicReplyCount < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { user_stats: %i[topic_reply_count] }
|
||||
DROPPED_COLUMNS = { user_stats: %i[topic_reply_count] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropPathWhitelistFromEmbeddableHosts < ActiveRecord::Migration[6.0]
|
||||
DROPPED_COLUMNS ||= { embeddable_hosts: %i[path_whitelist] }
|
||||
DROPPED_COLUMNS = { embeddable_hosts: %i[path_whitelist] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropDurationColumnFromTopicTimers < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { topic_timers: %i[duration] }
|
||||
DROPPED_COLUMNS = { topic_timers: %i[duration] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropDisableJumpReplyColumnFromUserOptions < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { user_options: %i[disable_jump_reply] }
|
||||
DROPPED_COLUMNS = { user_options: %i[disable_jump_reply] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropUploadsVerified < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { uploads: %i[verified] }
|
||||
DROPPED_COLUMNS = { uploads: %i[verified] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropTokenFromEmailTokens < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { email_tokens: %i[token] }
|
||||
DROPPED_COLUMNS = { email_tokens: %i[token] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class DropOldBookmarkColumns < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { bookmarks: %i[topic_id reminder_type] }
|
||||
DROPPED_COLUMNS = { bookmarks: %i[topic_id reminder_type] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropCategoryRequiredTagGroupColumns < ActiveRecord::Migration[6.1]
|
||||
DROPPED_COLUMNS ||= { categories: %i[required_tag_group_id min_tags_from_required_group] }
|
||||
DROPPED_COLUMNS = { categories: %i[required_tag_group_id min_tags_from_required_group] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropFlairUrlFromGroups < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { groups: %i[flair_url] }
|
||||
DROPPED_COLUMNS = { groups: %i[flair_url] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class DropOldBookmarkColumnsV2 < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { bookmarks: %i[post_id for_topic] }
|
||||
DROPPED_COLUMNS = { bookmarks: %i[post_id for_topic] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/column_dropper"
|
||||
|
||||
class RemoveTopicCountFromTags < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { tags: %i[topic_count] }
|
||||
DROPPED_COLUMNS = { tags: %i[topic_count] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropBadgeGrantedTitleColumn < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { user_profiles: %i[badge_granted_title] }
|
||||
DROPPED_COLUMNS = { user_profiles: %i[badge_granted_title] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropPostUploadsTable < ActiveRecord::Migration[7.0]
|
||||
DROPPED_TABLES ||= %i[post_uploads]
|
||||
DROPPED_TABLES = %i[post_uploads]
|
||||
|
||||
def up
|
||||
DROPPED_TABLES.each { |table| Migration::TableDropper.execute_drop(table) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropBadgeImageColumn < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { badges: %i[image] }
|
||||
DROPPED_COLUMNS = { badges: %i[image] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropDeprecatedColumns < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= {
|
||||
DROPPED_COLUMNS = {
|
||||
categories: %i[suppress_from_latest required_tag_group_id min_tags_from_required_group],
|
||||
directory_columns: %i[automatic],
|
||||
email_tokens: %i[token],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SwapFieldTypeWithFieldTypeEnumOnUserFields < ActiveRecord::Migration[7.0]
|
||||
# DROPPED_COLUMNS ||= { user_fields: %i[field_type] }
|
||||
# DROPPED_COLUMNS = { user_fields: %i[field_type] }
|
||||
|
||||
# def up
|
||||
# # WARNING: Swapping in a column of a different type in a post-migration will break the AR
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropCompiledJsFromTranslationOverrides < ActiveRecord::Migration[7.1]
|
||||
DROPPED_COLUMNS ||= { translation_overrides: %i[compiled_js] }
|
||||
DROPPED_COLUMNS = { translation_overrides: %i[compiled_js] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropCustomTypeFromFlags < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { flags: %i[custom_type] }
|
||||
DROPPED_COLUMNS = { flags: %i[custom_type] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropGroupsSmtpSsl < ActiveRecord::Migration[7.1]
|
||||
DROPPED_COLUMNS ||= { groups: %i[smtp_ssl] }
|
||||
DROPPED_COLUMNS = { groups: %i[smtp_ssl] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
|
@ -23,28 +23,28 @@ require_relative "../route_matcher"
|
|||
# We'll drop support for v0 after Discourse 2.9 is released.
|
||||
|
||||
class Auth::DefaultCurrentUserProvider
|
||||
CURRENT_USER_KEY ||= "_DISCOURSE_CURRENT_USER"
|
||||
USER_TOKEN_KEY ||= "_DISCOURSE_USER_TOKEN"
|
||||
API_KEY ||= "api_key"
|
||||
API_USERNAME ||= "api_username"
|
||||
HEADER_API_KEY ||= "HTTP_API_KEY"
|
||||
HEADER_API_USERNAME ||= "HTTP_API_USERNAME"
|
||||
HEADER_API_USER_EXTERNAL_ID ||= "HTTP_API_USER_EXTERNAL_ID"
|
||||
HEADER_API_USER_ID ||= "HTTP_API_USER_ID"
|
||||
PARAMETER_USER_API_KEY ||= "user_api_key"
|
||||
USER_API_KEY ||= "HTTP_USER_API_KEY"
|
||||
USER_API_CLIENT_ID ||= "HTTP_USER_API_CLIENT_ID"
|
||||
API_KEY_ENV ||= "_DISCOURSE_API"
|
||||
USER_API_KEY_ENV ||= "_DISCOURSE_USER_API"
|
||||
TOKEN_COOKIE ||= ENV["DISCOURSE_TOKEN_COOKIE"] || "_t"
|
||||
PATH_INFO ||= "PATH_INFO"
|
||||
COOKIE_ATTEMPTS_PER_MIN ||= 10
|
||||
BAD_TOKEN ||= "_DISCOURSE_BAD_TOKEN"
|
||||
CURRENT_USER_KEY = "_DISCOURSE_CURRENT_USER"
|
||||
USER_TOKEN_KEY = "_DISCOURSE_USER_TOKEN"
|
||||
API_KEY = "api_key"
|
||||
API_USERNAME = "api_username"
|
||||
HEADER_API_KEY = "HTTP_API_KEY"
|
||||
HEADER_API_USERNAME = "HTTP_API_USERNAME"
|
||||
HEADER_API_USER_EXTERNAL_ID = "HTTP_API_USER_EXTERNAL_ID"
|
||||
HEADER_API_USER_ID = "HTTP_API_USER_ID"
|
||||
PARAMETER_USER_API_KEY = "user_api_key"
|
||||
USER_API_KEY = "HTTP_USER_API_KEY"
|
||||
USER_API_CLIENT_ID = "HTTP_USER_API_CLIENT_ID"
|
||||
API_KEY_ENV = "_DISCOURSE_API"
|
||||
USER_API_KEY_ENV = "_DISCOURSE_USER_API"
|
||||
TOKEN_COOKIE = ENV["DISCOURSE_TOKEN_COOKIE"] || "_t"
|
||||
PATH_INFO = "PATH_INFO"
|
||||
COOKIE_ATTEMPTS_PER_MIN = 10
|
||||
BAD_TOKEN = "_DISCOURSE_BAD_TOKEN"
|
||||
DECRYPTED_AUTH_COOKIE = "_DISCOURSE_DECRYPTED_AUTH_COOKIE"
|
||||
|
||||
TOKEN_SIZE = 32
|
||||
|
||||
PARAMETER_API_PATTERNS ||= [
|
||||
PARAMETER_API_PATTERNS = [
|
||||
RouteMatcher.new(
|
||||
methods: :get,
|
||||
actions: [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Auth::FacebookAuthenticator < Auth::ManagedAuthenticator
|
||||
AVATAR_SIZE ||= 480
|
||||
AVATAR_SIZE = 480
|
||||
|
||||
def name
|
||||
"facebook"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Auth::GoogleOAuth2Authenticator < Auth::ManagedAuthenticator
|
||||
GROUPS_SCOPE ||= "https://www.googleapis.com/auth/admin.directory.group.readonly"
|
||||
GROUPS_DOMAIN ||= "admin.googleapis.com"
|
||||
GROUPS_PATH ||= "/admin/directory/v1/groups"
|
||||
OAUTH2_BASE_URL ||= "https://oauth2.googleapis.com"
|
||||
GROUPS_SCOPE = "https://www.googleapis.com/auth/admin.directory.group.readonly"
|
||||
GROUPS_DOMAIN = "admin.googleapis.com"
|
||||
GROUPS_PATH = "/admin/directory/v1/groups"
|
||||
OAUTH2_BASE_URL = "https://oauth2.googleapis.com"
|
||||
|
||||
def name
|
||||
"google_oauth2"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module BackupRestore
|
||||
class S3BackupStore < BackupStore
|
||||
UPLOAD_URL_EXPIRES_AFTER_SECONDS ||= 6.hours.to_i
|
||||
UPLOAD_URL_EXPIRES_AFTER_SECONDS = 6.hours.to_i
|
||||
|
||||
delegate :abort_multipart,
|
||||
:presign_multipart_part,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require "migration/base_dropper"
|
||||
|
||||
class DbHelper
|
||||
REMAP_SQL ||= <<~SQL
|
||||
REMAP_SQL = <<~SQL
|
||||
SELECT table_name::text, column_name::text, character_maximum_length
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'public'
|
||||
|
@ -12,13 +12,13 @@ class DbHelper
|
|||
ORDER BY table_name, column_name
|
||||
SQL
|
||||
|
||||
TRIGGERS_SQL ||= <<~SQL
|
||||
TRIGGERS_SQL = <<~SQL
|
||||
SELECT trigger_name::text
|
||||
FROM information_schema.triggers
|
||||
WHERE trigger_name LIKE '%_readonly'
|
||||
SQL
|
||||
|
||||
TRUNCATABLE_COLUMNS ||= ["topic_links.url"]
|
||||
TRUNCATABLE_COLUMNS = ["topic_links.url"]
|
||||
|
||||
def self.remap(
|
||||
from,
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
require "demon/base"
|
||||
|
||||
class Demon::EmailSync < ::Demon::Base
|
||||
HEARTBEAT_KEY ||= "email_sync_heartbeat"
|
||||
HEARTBEAT_INTERVAL ||= 60.seconds
|
||||
HEARTBEAT_KEY = "email_sync_heartbeat"
|
||||
HEARTBEAT_INTERVAL = 60.seconds
|
||||
|
||||
def self.prefix
|
||||
"email_sync"
|
||||
|
|
|
@ -7,15 +7,15 @@ require "version"
|
|||
require "git_utils"
|
||||
|
||||
module Discourse
|
||||
DB_POST_MIGRATE_PATH ||= "db/post_migrate"
|
||||
REQUESTED_HOSTNAME ||= "REQUESTED_HOSTNAME"
|
||||
DB_POST_MIGRATE_PATH = "db/post_migrate"
|
||||
REQUESTED_HOSTNAME = "REQUESTED_HOSTNAME"
|
||||
MAX_METADATA_FILE_SIZE = 64.kilobytes
|
||||
|
||||
class Utils
|
||||
URI_REGEXP ||= URI.regexp(%w[http https])
|
||||
URI_REGEXP = URI.regexp(%w[http https])
|
||||
|
||||
# TODO: Remove this once we drop support for Ruby 2.
|
||||
EMPTY_KEYWORDS ||= {}
|
||||
EMPTY_KEYWORDS = {}
|
||||
|
||||
# Usage:
|
||||
# Discourse::Utils.execute_command("pwd", chdir: 'mydirectory')
|
||||
|
@ -658,17 +658,17 @@ module Discourse
|
|||
|
||||
LAST_POSTGRES_READONLY_KEY = "postgres:last_readonly"
|
||||
|
||||
READONLY_MODE_KEY_TTL ||= 60
|
||||
READONLY_MODE_KEY ||= "readonly_mode"
|
||||
PG_READONLY_MODE_KEY ||= "readonly_mode:postgres"
|
||||
PG_READONLY_MODE_KEY_TTL ||= 300
|
||||
USER_READONLY_MODE_KEY ||= "readonly_mode:user"
|
||||
PG_FORCE_READONLY_MODE_KEY ||= "readonly_mode:postgres_force"
|
||||
READONLY_MODE_KEY_TTL = 60
|
||||
READONLY_MODE_KEY = "readonly_mode"
|
||||
PG_READONLY_MODE_KEY = "readonly_mode:postgres"
|
||||
PG_READONLY_MODE_KEY_TTL = 300
|
||||
USER_READONLY_MODE_KEY = "readonly_mode:user"
|
||||
PG_FORCE_READONLY_MODE_KEY = "readonly_mode:postgres_force"
|
||||
|
||||
# Pseudo readonly mode, where staff can still write
|
||||
STAFF_WRITES_ONLY_MODE_KEY ||= "readonly_mode:staff_writes_only"
|
||||
STAFF_WRITES_ONLY_MODE_KEY = "readonly_mode:staff_writes_only"
|
||||
|
||||
READONLY_KEYS ||= [
|
||||
READONLY_KEYS = [
|
||||
READONLY_MODE_KEY,
|
||||
PG_READONLY_MODE_KEY,
|
||||
USER_READONLY_MODE_KEY,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module DiscourseTagging
|
||||
TAGS_FIELD_NAME ||= "tags"
|
||||
TAGS_FILTER_REGEXP ||= /[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/ # /?#[]@!$&'()*+,;=.%\`^|{}"<>
|
||||
TAGS_STAFF_CACHE_KEY ||= "staff_tag_names"
|
||||
TAGS_FIELD_NAME = "tags"
|
||||
TAGS_FILTER_REGEXP = /[\/\?#\[\]@!\$&'\(\)\*\+,;=\.%\\`^\s|\{\}"<>]+/ # /?#[]@!$&'()*+,;=.%\`^|{}"<>
|
||||
TAGS_STAFF_CACHE_KEY = "staff_tag_names"
|
||||
|
||||
TAG_GROUP_TAG_IDS_SQL ||= <<-SQL
|
||||
TAG_GROUP_TAG_IDS_SQL = <<-SQL
|
||||
SELECT tag_id
|
||||
FROM tag_group_memberships tgm
|
||||
INNER JOIN tag_groups tg
|
||||
|
@ -370,7 +370,7 @@ module DiscourseTagging
|
|||
tags_by_group_map.select { |_, group_tags| group_tags.size > 1 }
|
||||
end
|
||||
|
||||
TAG_GROUP_RESTRICTIONS_SQL ||= <<~SQL
|
||||
TAG_GROUP_RESTRICTIONS_SQL = <<~SQL
|
||||
tag_group_restrictions AS (
|
||||
SELECT t.id as tag_id, tgm.id as tgm_id, tg.id as tag_group_id, tg.parent_tag_id as parent_tag_id,
|
||||
tg.one_per_topic as one_per_topic
|
||||
|
@ -380,7 +380,7 @@ module DiscourseTagging
|
|||
)
|
||||
SQL
|
||||
|
||||
CATEGORY_RESTRICTIONS_SQL ||= <<~SQL
|
||||
CATEGORY_RESTRICTIONS_SQL = <<~SQL
|
||||
category_restrictions AS (
|
||||
SELECT t.id as tag_id, ct.id as ct_id, ct.category_id as category_id, NULL AS category_tag_group_id
|
||||
FROM tags t
|
||||
|
@ -395,7 +395,7 @@ module DiscourseTagging
|
|||
)
|
||||
SQL
|
||||
|
||||
PERMITTED_TAGS_SQL ||= <<~SQL
|
||||
PERMITTED_TAGS_SQL = <<~SQL
|
||||
permitted_tag_groups AS (
|
||||
SELECT tg.id as tag_group_id, tgp.group_id as group_id, tgp.permission_type as permission_type
|
||||
FROM tags t
|
||||
|
|
|
@ -95,7 +95,7 @@ module Email
|
|||
attr_reader :mail
|
||||
attr_reader :message_id
|
||||
|
||||
COMMON_ENCODINGS ||= [-"utf-8", -"windows-1252", -"iso-8859-1"]
|
||||
COMMON_ENCODINGS = [-"utf-8", -"windows-1252", -"iso-8859-1"]
|
||||
|
||||
def self.formats
|
||||
@formats ||= Enum.new(plaintext: 1, markdown: 2)
|
||||
|
@ -527,7 +527,7 @@ module Email
|
|||
[EmailReplyTrimmer.trim(markdown), elided_markdown]
|
||||
end
|
||||
|
||||
HTML_EXTRACTERS ||= [
|
||||
HTML_EXTRACTERS = [
|
||||
[:gmail, /class="gmail_(signature|extra)/],
|
||||
[:outlook, /id="(divRplyFwdMsg|Signature)"/],
|
||||
[:word, /class="WordSection1"/],
|
||||
|
|
|
@ -5,9 +5,9 @@ module FileStore
|
|||
end
|
||||
|
||||
class BaseStore
|
||||
UPLOAD_PATH_REGEX ||= %r{/(original/\d+X/.*)}
|
||||
OPTIMIZED_IMAGE_PATH_REGEX ||= %r{/(optimized/\d+X/.*)}
|
||||
TEMPORARY_UPLOAD_PREFIX ||= "temp/"
|
||||
UPLOAD_PATH_REGEX = %r{/(original/\d+X/.*)}
|
||||
OPTIMIZED_IMAGE_PATH_REGEX = %r{/(optimized/\d+X/.*)}
|
||||
TEMPORARY_UPLOAD_PREFIX = "temp/"
|
||||
|
||||
def store_upload(file, upload, content_type = nil)
|
||||
upload.url = nil
|
||||
|
|
|
@ -8,7 +8,7 @@ require "file_helper"
|
|||
|
||||
module FileStore
|
||||
class S3Store < BaseStore
|
||||
TOMBSTONE_PREFIX ||= "tombstone/"
|
||||
TOMBSTONE_PREFIX = "tombstone/"
|
||||
|
||||
delegate :abort_multipart,
|
||||
:presign_multipart_part,
|
||||
|
|
|
@ -6,8 +6,8 @@ module FileStore
|
|||
ToS3MigrationError = Class.new(RuntimeError)
|
||||
|
||||
class ToS3Migration
|
||||
MISSING_UPLOADS_RAKE_TASK_NAME ||= "posts:missing_uploads"
|
||||
UPLOAD_CONCURRENCY ||= 20
|
||||
MISSING_UPLOADS_RAKE_TASK_NAME = "posts:missing_uploads"
|
||||
UPLOAD_CONCURRENCY = 20
|
||||
|
||||
def initialize(s3_options:, dry_run: false, migrate_to_multisite: false)
|
||||
@s3_bucket = s3_options[:bucket]
|
||||
|
|
|
@ -157,7 +157,7 @@ class HtmlToMarkdown
|
|||
send(visitor, node) if respond_to?(visitor, true)
|
||||
end
|
||||
|
||||
ALLOWED_IMG_SRCS ||= %w[http:// https:// www.]
|
||||
ALLOWED_IMG_SRCS = %w[http:// https:// www.]
|
||||
|
||||
def allowed_hrefs
|
||||
@allowed_hrefs ||=
|
||||
|
@ -195,7 +195,7 @@ class HtmlToMarkdown
|
|||
end
|
||||
end
|
||||
|
||||
ALLOWED ||= %w[kbd del ins small big sub sup dl dd dt mark]
|
||||
ALLOWED = %w[kbd del ins small big sub sup dl dd dt mark]
|
||||
ALLOWED.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
"<#{tag}>#{traverse(node, within_html_block: true)}</#{tag}>"
|
||||
|
@ -210,7 +210,7 @@ class HtmlToMarkdown
|
|||
"\n\n#{text}\n\n"
|
||||
end
|
||||
|
||||
BLOCKS ||= %w[div tr]
|
||||
BLOCKS = %w[div tr]
|
||||
BLOCKS.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
prefix = block?(node.previous_element) ? "" : "\n"
|
||||
|
@ -222,7 +222,7 @@ class HtmlToMarkdown
|
|||
"\n\n#{traverse(node)}\n\n"
|
||||
end
|
||||
|
||||
TRAVERSABLES ||= %w[aside font span thead tbody tfoot u center]
|
||||
TRAVERSABLES = %w[aside font span thead tbody tfoot u center]
|
||||
TRAVERSABLES.each { |tag| define_method("visit_#{tag}") { |node| traverse(node) } }
|
||||
|
||||
def visit_tt(node)
|
||||
|
@ -290,7 +290,7 @@ class HtmlToMarkdown
|
|||
@within_html_block ? "<tr>\n#{text}</tr>\n" : text
|
||||
end
|
||||
|
||||
TABLE_CELLS ||= %w[th td]
|
||||
TABLE_CELLS = %w[th td]
|
||||
TABLE_CELLS.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
text = traverse(node)
|
||||
|
@ -306,7 +306,7 @@ class HtmlToMarkdown
|
|||
end
|
||||
end
|
||||
|
||||
LISTS ||= %w[ul ol]
|
||||
LISTS = %w[ul ol]
|
||||
LISTS.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
prefix = block?(node.previous_element) ? "" : "\n"
|
||||
|
@ -330,7 +330,7 @@ class HtmlToMarkdown
|
|||
"#{marker}#{text}#{suffix}"
|
||||
end
|
||||
|
||||
EMPHASES ||= %w[i em]
|
||||
EMPHASES = %w[i em]
|
||||
EMPHASES.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
text = traverse(node)
|
||||
|
@ -347,7 +347,7 @@ class HtmlToMarkdown
|
|||
end
|
||||
end
|
||||
|
||||
STRONGS ||= %w[b strong]
|
||||
STRONGS = %w[b strong]
|
||||
STRONGS.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
text = traverse(node)
|
||||
|
@ -364,7 +364,7 @@ class HtmlToMarkdown
|
|||
end
|
||||
end
|
||||
|
||||
STRIKES ||= %w[s strike]
|
||||
STRIKES = %w[s strike]
|
||||
STRIKES.each do |tag|
|
||||
define_method("visit_#{tag}") do |node|
|
||||
text = traverse(node)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module Migration
|
||||
class BaseDropper
|
||||
FUNCTION_SCHEMA_NAME ||= "discourse_functions"
|
||||
FUNCTION_SCHEMA_NAME = "discourse_functions"
|
||||
|
||||
def self.create_readonly_function(table_name, column_name = nil)
|
||||
DB.exec <<~SQL
|
||||
|
|
|
@ -10,8 +10,8 @@ module Onebox
|
|||
requires_iframe_origins "https://www.youtube.com"
|
||||
always_https
|
||||
|
||||
WIDTH ||= 480
|
||||
HEIGHT ||= 360
|
||||
WIDTH = 480
|
||||
HEIGHT = 360
|
||||
|
||||
def parse_embed_response
|
||||
return unless video_id
|
||||
|
|
|
@ -7,7 +7,7 @@ module Onebox
|
|||
class DownloadTooLarge < StandardError
|
||||
end
|
||||
|
||||
IGNORE_CANONICAL_DOMAINS ||= %w[www.instagram.com medium.com youtube.com]
|
||||
IGNORE_CANONICAL_DOMAINS = %w[www.instagram.com medium.com youtube.com]
|
||||
|
||||
def self.clean(html)
|
||||
html.gsub(/<[^>]+>/, " ").gsub(/\n/, "")
|
||||
|
|
|
@ -5,7 +5,7 @@ module Onebox
|
|||
# see https://bugs.ruby-lang.org/issues/14688
|
||||
client_exception =
|
||||
defined?(Net::HTTPClientException) ? Net::HTTPClientException : Net::HTTPServerException
|
||||
WEB_EXCEPTIONS ||= [
|
||||
WEB_EXCEPTIONS = [
|
||||
client_exception,
|
||||
OpenURI::HTTPError,
|
||||
Timeout::Error,
|
||||
|
|
|
@ -107,7 +107,7 @@ module Onebox
|
|||
),
|
||||
)
|
||||
|
||||
DISCOURSE_ONEBOX ||=
|
||||
DISCOURSE_ONEBOX =
|
||||
Sanitize::Config.freeze_config(
|
||||
Sanitize::Config.merge(
|
||||
ONEBOX,
|
||||
|
|
|
@ -153,9 +153,9 @@ class PlainTextToMarkdown
|
|||
converted_text
|
||||
end
|
||||
|
||||
URL_REGEX ||= URI.regexp(%w[http https ftp mailto])
|
||||
BEFORE ||= Regexp.escape(%Q|([<«"“'‘|)
|
||||
AFTER ||= Regexp.escape(%Q|)]>»"”'’|)
|
||||
URL_REGEX = URI.regexp(%w[http https ftp mailto])
|
||||
BEFORE = Regexp.escape(%Q|([<«"“'‘|)
|
||||
AFTER = Regexp.escape(%Q|)]>»"”'’|)
|
||||
|
||||
def replace_duplicate_links(text)
|
||||
urls = Set.new
|
||||
|
|
|
@ -6,7 +6,8 @@ require "plugin/metadata"
|
|||
require "auth"
|
||||
|
||||
class Plugin::CustomEmoji
|
||||
CACHE_KEY ||= "plugin-emoji"
|
||||
CACHE_KEY = "plugin-emoji"
|
||||
|
||||
def self.cache_key
|
||||
@@cache_key ||= CACHE_KEY
|
||||
end
|
||||
|
|
|
@ -5,7 +5,7 @@ module Plugin
|
|||
end
|
||||
|
||||
class Plugin::Metadata
|
||||
OFFICIAL_PLUGINS ||=
|
||||
OFFICIAL_PLUGINS =
|
||||
Set.new(
|
||||
%w[
|
||||
discourse-adplugin
|
||||
|
@ -97,10 +97,10 @@ class Plugin::Metadata
|
|||
],
|
||||
)
|
||||
|
||||
FIELDS ||= %i[name about version authors contact_emails url required_version meta_topic_id label]
|
||||
FIELDS = %i[name about version authors contact_emails url required_version meta_topic_id label]
|
||||
attr_accessor(*FIELDS)
|
||||
|
||||
MAX_FIELD_LENGTHS ||= {
|
||||
MAX_FIELD_LENGTHS = {
|
||||
name: 75,
|
||||
about: 350,
|
||||
authors: 200,
|
||||
|
|
|
@ -42,7 +42,7 @@ class PresenceChannel
|
|||
# allowed_group_ids: array of group_ids that can view, and become present in, the channel (default [])
|
||||
# count_only: boolean. If true, user identities are never revealed to clients. (default [])
|
||||
class Config
|
||||
NOT_FOUND ||= "notfound"
|
||||
NOT_FOUND = "notfound"
|
||||
|
||||
attr_accessor :public, :allowed_user_ids, :allowed_group_ids, :count_only, :timeout
|
||||
|
||||
|
@ -76,11 +76,11 @@ class PresenceChannel
|
|||
end
|
||||
end
|
||||
|
||||
DEFAULT_TIMEOUT ||= 60
|
||||
CONFIG_CACHE_SECONDS ||= 10
|
||||
GC_SECONDS ||= 24.hours.to_i
|
||||
MUTEX_TIMEOUT_SECONDS ||= 10
|
||||
MUTEX_LOCKED_ERROR ||= "PresenceChannel mutex is locked"
|
||||
DEFAULT_TIMEOUT = 60
|
||||
CONFIG_CACHE_SECONDS = 10
|
||||
GC_SECONDS = 24.hours.to_i
|
||||
MUTEX_TIMEOUT_SECONDS = 10
|
||||
MUTEX_LOCKED_ERROR = "PresenceChannel mutex is locked"
|
||||
|
||||
@@configuration_blocks ||= {}
|
||||
|
||||
|
@ -469,7 +469,7 @@ class PresenceChannel
|
|||
end
|
||||
LUA
|
||||
|
||||
LUA_SCRIPTS ||= {}
|
||||
LUA_SCRIPTS = {}
|
||||
|
||||
LUA_SCRIPTS[:present] = DiscourseRedis::EvalHelper.new <<~LUA
|
||||
#{COMMON_PRESENT_LEAVE_LUA}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RouteMatcher
|
||||
PATH_PARAMETERS ||= "_DISCOURSE_REQUEST_PATH_PARAMETERS"
|
||||
PATH_PARAMETERS = "_DISCOURSE_REQUEST_PATH_PARAMETERS"
|
||||
|
||||
attr_reader :actions, :params, :methods, :aliases, :formats, :allowed_param_values
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ require "weakref"
|
|||
|
||||
module Scheduler
|
||||
module Deferrable
|
||||
DEFAULT_TIMEOUT ||= 90
|
||||
STATS_CACHE_SIZE ||= 100
|
||||
DEFAULT_TIMEOUT = 90
|
||||
STATS_CACHE_SIZE = 100
|
||||
|
||||
def initialize
|
||||
@async = !Rails.env.test?
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Search
|
||||
DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
|
||||
DIACRITICS = /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
|
||||
HIGHLIGHT_CSS_CLASS = "search-highlight"
|
||||
|
||||
cattr_accessor :preloaded_topic_custom_fields
|
||||
|
|
|
@ -438,7 +438,7 @@ module SiteSettingExtension
|
|||
refresh_settings.include?(name.to_sym)
|
||||
end
|
||||
|
||||
HOSTNAME_SETTINGS ||= %w[
|
||||
HOSTNAME_SETTINGS = %w[
|
||||
disabled_image_download_domains
|
||||
blocked_onebox_domains
|
||||
exclude_rel_nofollow_domains
|
||||
|
|
|
@ -6,7 +6,7 @@ module Stylesheet
|
|||
class Importer
|
||||
include GlobalPath
|
||||
|
||||
THEME_TARGETS ||= %w[embedded_theme mobile_theme desktop_theme]
|
||||
THEME_TARGETS = %w[embedded_theme mobile_theme desktop_theme]
|
||||
|
||||
def self.plugin_assets
|
||||
@plugin_assets ||= {}
|
||||
|
|
|
@ -12,9 +12,9 @@ class Stylesheet::Manager
|
|||
CACHE_PATH = "tmp/stylesheet-cache"
|
||||
private_constant :CACHE_PATH
|
||||
|
||||
MANIFEST_DIR ||= "#{Rails.root}/tmp/cache/assets/#{Rails.env}"
|
||||
THEME_REGEX ||= /_theme\z/
|
||||
COLOR_SCHEME_STYLESHEET ||= "color_definitions"
|
||||
MANIFEST_DIR = "#{Rails.root}/tmp/cache/assets/#{Rails.env}"
|
||||
THEME_REGEX = /_theme\z/
|
||||
COLOR_SCHEME_STYLESHEET = "color_definitions"
|
||||
|
||||
@@lock = Mutex.new
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class TextSentinel
|
||||
attr_accessor :text
|
||||
|
||||
ENTROPY_SCALE ||= 0.7
|
||||
ENTROPY_SCALE = 0.7
|
||||
|
||||
def initialize(text, opts = nil)
|
||||
@opts = opts || {}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
require "fastimage"
|
||||
|
||||
class UploadCreator
|
||||
TYPES_TO_CROP ||= %w[avatar card_background custom_emoji profile_background].each(&:freeze)
|
||||
TYPES_TO_CROP = %w[avatar card_background custom_emoji profile_background].each(&:freeze)
|
||||
|
||||
ALLOWED_SVG_ELEMENTS ||= %w[
|
||||
ALLOWED_SVG_ELEMENTS = %w[
|
||||
circle
|
||||
clipPath
|
||||
defs
|
||||
|
@ -312,7 +312,7 @@ class UploadCreator
|
|||
end
|
||||
end
|
||||
|
||||
MIN_PIXELS_TO_CONVERT_TO_JPEG ||= 1280 * 720
|
||||
MIN_PIXELS_TO_CONVERT_TO_JPEG = 1280 * 720
|
||||
|
||||
def convert_png_to_jpeg?
|
||||
return false unless @image_info.type == :png
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Discourse
|
||||
VERSION_REGEXP ||= /\A\d+\.\d+\.\d+(\.beta\d+)?\z/
|
||||
VERSION_COMPATIBILITY_FILENAME ||= ".discourse-compatibility"
|
||||
VERSION_REGEXP = /\A\d+\.\d+\.\d+(\.beta\d+)?\z/
|
||||
VERSION_COMPATIBILITY_FILENAME = ".discourse-compatibility"
|
||||
# work around reloader
|
||||
unless defined?(::Discourse::VERSION)
|
||||
module VERSION #:nodoc:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Chat::Api::ChannelsController < Chat::ApiController
|
||||
CHANNEL_EDITABLE_PARAMS ||= %i[name description slug threading_enabled]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS ||= %i[auto_join_users allow_channel_wide_mentions]
|
||||
CHANNEL_EDITABLE_PARAMS = %i[name description slug threading_enabled]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS = %i[auto_join_users allow_channel_wide_mentions]
|
||||
|
||||
def index
|
||||
permitted = params.permit(:filter, :limit, :offset, :status)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DropOldChatMessagePostIdActionCodeColumns < ActiveRecord::Migration[7.0]
|
||||
DROPPED_COLUMNS ||= { chat_messages: %i[post_id action_code] }
|
||||
DROPPED_COLUMNS = { chat_messages: %i[post_id action_code] }
|
||||
|
||||
def up
|
||||
DROPPED_COLUMNS.each { |table, columns| Migration::ColumnDropper.execute_drop(table, columns) }
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user