mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 05:21:50 +08:00
DEV: Update to lastest rubocop-discourse
This commit is contained in:
parent
3b6d4c830f
commit
2a28cda15c
4
.github/workflows/migration-tests.yml
vendored
4
.github/workflows/migration-tests.yml
vendored
|
@ -164,6 +164,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Modify path for libpq
|
||||||
|
if: matrix.os == 'macos-latest'
|
||||||
|
run: echo "/opt/homebrew/opt/libpq/bin" >> $GITHUB_PATH
|
||||||
|
|
||||||
- name: Setup Ruby
|
- name: Setup Ruby
|
||||||
uses: ruby/setup-ruby@v1
|
uses: ruby/setup-ruby@v1
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -429,14 +429,20 @@ GEM
|
||||||
parser (>= 3.3.1.0)
|
parser (>= 3.3.1.0)
|
||||||
rubocop-capybara (2.20.0)
|
rubocop-capybara (2.20.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-discourse (3.7.1)
|
rubocop-discourse (3.8.0)
|
||||||
activesupport (>= 6.1)
|
activesupport (>= 6.1)
|
||||||
rubocop (>= 1.59.0)
|
rubocop (>= 1.59.0)
|
||||||
rubocop-capybara (>= 2.0.0)
|
rubocop-capybara (>= 2.0.0)
|
||||||
rubocop-factory_bot (>= 2.0.0)
|
rubocop-factory_bot (>= 2.0.0)
|
||||||
|
rubocop-rails (>= 2.25.0)
|
||||||
rubocop-rspec (>= 2.25.0)
|
rubocop-rspec (>= 2.25.0)
|
||||||
rubocop-factory_bot (2.25.1)
|
rubocop-factory_bot (2.25.1)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
|
rubocop-rails (2.25.0)
|
||||||
|
activesupport (>= 4.2.0)
|
||||||
|
rack (>= 1.1)
|
||||||
|
rubocop (>= 1.33.0, < 2.0)
|
||||||
|
rubocop-ast (>= 1.31.1, < 2.0)
|
||||||
rubocop-rspec (2.29.2)
|
rubocop-rspec (2.29.2)
|
||||||
rubocop (~> 1.40)
|
rubocop (~> 1.40)
|
||||||
rubocop-capybara (~> 2.17)
|
rubocop-capybara (~> 2.17)
|
||||||
|
|
|
@ -73,7 +73,7 @@ class Admin::EmailTemplatesController < Admin::AdminController
|
||||||
def update
|
def update
|
||||||
et = params[:email_template]
|
et = params[:email_template]
|
||||||
key = params[:id]
|
key = params[:id]
|
||||||
raise Discourse::NotFound unless self.class.email_keys.include?(params[:id])
|
raise Discourse::NotFound if self.class.email_keys.exclude?(params[:id])
|
||||||
|
|
||||||
subject_result = update_key("#{key}.subject_template", et[:subject])
|
subject_result = update_key("#{key}.subject_template", et[:subject])
|
||||||
body_result = update_key("#{key}.text_body_template", et[:body])
|
body_result = update_key("#{key}.text_body_template", et[:body])
|
||||||
|
@ -110,7 +110,7 @@ class Admin::EmailTemplatesController < Admin::AdminController
|
||||||
|
|
||||||
def revert
|
def revert
|
||||||
key = params[:id]
|
key = params[:id]
|
||||||
raise Discourse::NotFound unless self.class.email_keys.include?(params[:id])
|
raise Discourse::NotFound if self.class.email_keys.exclude?(params[:id])
|
||||||
|
|
||||||
revert_and_log("#{key}.subject_template", "#{key}.text_body_template")
|
revert_and_log("#{key}.subject_template", "#{key}.text_body_template")
|
||||||
render_serialized(
|
render_serialized(
|
||||||
|
|
|
@ -137,7 +137,7 @@ class Admin::GroupsController < Admin::StaffController
|
||||||
notify_users
|
notify_users
|
||||||
]
|
]
|
||||||
custom_fields = DiscoursePluginRegistry.editable_group_custom_fields
|
custom_fields = DiscoursePluginRegistry.editable_group_custom_fields
|
||||||
permitted << { custom_fields: custom_fields } unless custom_fields.blank?
|
permitted << { custom_fields: custom_fields } if custom_fields.present?
|
||||||
|
|
||||||
permitted << { associated_group_ids: [] } if guardian.can_associate_groups?
|
permitted << { associated_group_ids: [] } if guardian.can_associate_groups?
|
||||||
|
|
||||||
|
|
|
@ -279,7 +279,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
|
|
||||||
def bulk_destroy
|
def bulk_destroy
|
||||||
themes = Theme.where(id: params[:theme_ids])
|
themes = Theme.where(id: params[:theme_ids])
|
||||||
raise Discourse::InvalidParameters.new(:id) unless themes.present?
|
raise Discourse::InvalidParameters.new(:id) if themes.blank?
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
themes.each { |theme| StaffActionLogger.new(current_user).log_theme_destroy(theme) }
|
themes.each { |theme| StaffActionLogger.new(current_user).log_theme_destroy(theme) }
|
||||||
|
@ -313,7 +313,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
|
|
||||||
def get_translations
|
def get_translations
|
||||||
params.require(:locale)
|
params.require(:locale)
|
||||||
unless I18n.available_locales.include?(params[:locale].to_sym)
|
if I18n.available_locales.exclude?(params[:locale].to_sym)
|
||||||
raise Discourse::InvalidParameters.new(:locale)
|
raise Discourse::InvalidParameters.new(:locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||||
|
|
||||||
locale = theme_params[:locale].presence
|
locale = theme_params[:locale].presence
|
||||||
if locale
|
if locale
|
||||||
unless I18n.available_locales.include?(locale.to_sym)
|
if I18n.available_locales.exclude?(locale.to_sym)
|
||||||
raise Discourse::InvalidParameters.new(:locale)
|
raise Discourse::InvalidParameters.new(:locale)
|
||||||
end
|
end
|
||||||
I18n.locale = locale
|
I18n.locale = locale
|
||||||
|
|
|
@ -619,7 +619,7 @@ class Admin::UsersController < Admin::StaffController
|
||||||
private
|
private
|
||||||
|
|
||||||
def perform_post_action
|
def perform_post_action
|
||||||
return unless params[:post_id].present? && params[:post_action].present?
|
return if params[:post_id].blank? || params[:post_action].blank?
|
||||||
|
|
||||||
if post = Post.where(id: params[:post_id]).first
|
if post = Post.where(id: params[:post_id]).first
|
||||||
case params[:post_action]
|
case params[:post_action]
|
||||||
|
|
|
@ -837,7 +837,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_logged_in
|
def ensure_logged_in
|
||||||
raise Discourse::NotLoggedIn.new unless current_user.present?
|
raise Discourse::NotLoggedIn.new if current_user.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_staff
|
def ensure_staff
|
||||||
|
|
|
@ -269,7 +269,7 @@ class CategoriesController < ApplicationController
|
||||||
@category =
|
@category =
|
||||||
Category.includes(:category_setting).find_by_slug_path(params[:category_slug].split("/"))
|
Category.includes(:category_setting).find_by_slug_path(params[:category_slug].split("/"))
|
||||||
|
|
||||||
raise Discourse::NotFound unless @category.present?
|
raise Discourse::NotFound if @category.blank?
|
||||||
|
|
||||||
if !guardian.can_see?(@category)
|
if !guardian.can_see?(@category)
|
||||||
if SiteSetting.detailed_404 && group = @category.access_category_via_group
|
if SiteSetting.detailed_404 && group = @category.access_category_via_group
|
||||||
|
|
|
@ -144,7 +144,7 @@ class EmbedController < ApplicationController
|
||||||
|
|
||||||
topic_embeds.each do |te|
|
topic_embeds.each do |te|
|
||||||
url = te.embed_url
|
url = te.embed_url
|
||||||
url = "#{url}#discourse-comments" unless params[:embed_url].include?(url)
|
url = "#{url}#discourse-comments" if params[:embed_url].exclude?(url)
|
||||||
if te.topic.present?
|
if te.topic.present?
|
||||||
by_url[url] = I18n.t("embed.replies", count: te.topic.posts_count - 1)
|
by_url[url] = I18n.t("embed.replies", count: te.topic.posts_count - 1)
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,7 +15,7 @@ class FinishInstallationController < ApplicationController
|
||||||
@user = User.new
|
@user = User.new
|
||||||
if request.post?
|
if request.post?
|
||||||
email = params[:email].strip
|
email = params[:email].strip
|
||||||
raise Discourse::InvalidParameters.new unless @allowed_emails.include?(email)
|
raise Discourse::InvalidParameters.new if @allowed_emails.exclude?(email)
|
||||||
|
|
||||||
if existing_user = User.find_by_email(email)
|
if existing_user = User.find_by_email(email)
|
||||||
@user = existing_user
|
@user = existing_user
|
||||||
|
|
|
@ -145,7 +145,7 @@ class ListController < ApplicationController
|
||||||
def category_default
|
def category_default
|
||||||
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
|
canonical_url "#{Discourse.base_url_no_prefix}#{@category.url}"
|
||||||
view_method = @category.default_view
|
view_method = @category.default_view
|
||||||
view_method = "latest" unless %w[latest top].include?(view_method)
|
view_method = "latest" if %w[latest top].exclude?(view_method)
|
||||||
|
|
||||||
self.public_send(view_method, category: @category.id)
|
self.public_send(view_method, category: @category.id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,13 +15,13 @@ class MetadataController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def app_association_android
|
def app_association_android
|
||||||
raise Discourse::NotFound unless SiteSetting.app_association_android.present?
|
raise Discourse::NotFound if SiteSetting.app_association_android.blank?
|
||||||
expires_in 1.minutes
|
expires_in 1.minutes
|
||||||
render plain: SiteSetting.app_association_android, content_type: "application/json"
|
render plain: SiteSetting.app_association_android, content_type: "application/json"
|
||||||
end
|
end
|
||||||
|
|
||||||
def app_association_ios
|
def app_association_ios
|
||||||
raise Discourse::NotFound unless SiteSetting.app_association_ios.present?
|
raise Discourse::NotFound if SiteSetting.app_association_ios.blank?
|
||||||
expires_in 1.minutes
|
expires_in 1.minutes
|
||||||
render plain: SiteSetting.app_association_ios, content_type: "application/json"
|
render plain: SiteSetting.app_association_ios, content_type: "application/json"
|
||||||
end
|
end
|
||||||
|
|
|
@ -477,7 +477,7 @@ class PostsController < ApplicationController
|
||||||
|
|
||||||
post = find_post_from_params
|
post = find_post_from_params
|
||||||
raise Discourse::InvalidParameters.new(:post) if post.blank?
|
raise Discourse::InvalidParameters.new(:post) if post.blank?
|
||||||
raise Discourse::NotFound unless post.revisions.present?
|
raise Discourse::NotFound if post.revisions.blank?
|
||||||
|
|
||||||
RateLimiter.new(
|
RateLimiter.new(
|
||||||
current_user,
|
current_user,
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ReviewablesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
status = (params[:status] || "pending").to_sym
|
status = (params[:status] || "pending").to_sym
|
||||||
raise Discourse::InvalidParameters.new(:status) unless allowed_statuses.include?(status)
|
raise Discourse::InvalidParameters.new(:status) if allowed_statuses.exclude?(status)
|
||||||
|
|
||||||
topic_id = params[:topic_id] ? params[:topic_id].to_i : nil
|
topic_id = params[:topic_id] ? params[:topic_id].to_i : nil
|
||||||
category_id = params[:category_id] ? params[:category_id].to_i : nil
|
category_id = params[:category_id] ? params[:category_id].to_i : nil
|
||||||
|
@ -185,7 +185,7 @@ class ReviewablesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
editable = reviewable.editable_for(guardian)
|
editable = reviewable.editable_for(guardian)
|
||||||
raise Discourse::InvalidAccess.new unless editable.present?
|
raise Discourse::InvalidAccess.new if editable.blank?
|
||||||
|
|
||||||
# Validate parameters are all editable
|
# Validate parameters are all editable
|
||||||
edit_params = params[:reviewable] || {}
|
edit_params = params[:reviewable] || {}
|
||||||
|
|
|
@ -220,7 +220,7 @@ class SearchController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if search_context.present?
|
if search_context.present?
|
||||||
unless SearchController.valid_context_types.include?(search_context[:type])
|
if SearchController.valid_context_types.exclude?(search_context[:type])
|
||||||
raise Discourse::InvalidParameters.new(:search_context)
|
raise Discourse::InvalidParameters.new(:search_context)
|
||||||
end
|
end
|
||||||
raise Discourse::InvalidParameters.new(:search_context) if search_context[:id].blank?
|
raise Discourse::InvalidParameters.new(:search_context) if search_context[:id].blank?
|
||||||
|
|
|
@ -231,7 +231,7 @@ class TagsController < ::ApplicationController
|
||||||
if tag_group_name
|
if tag_group_name
|
||||||
tag_group =
|
tag_group =
|
||||||
TagGroup.find_by(name: tag_group_name) || TagGroup.create!(name: tag_group_name)
|
TagGroup.find_by(name: tag_group_name) || TagGroup.create!(name: tag_group_name)
|
||||||
tag.tag_groups << tag_group unless tag.tag_groups.include?(tag_group)
|
tag.tag_groups << tag_group if tag.tag_groups.exclude?(tag_group)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ class ThemeJavascriptsController < ApplicationController
|
||||||
before_action :is_asset_path, :no_cookies, :apply_cdn_headers, only: %i[show show_map show_tests]
|
before_action :is_asset_path, :no_cookies, :apply_cdn_headers, only: %i[show show_map show_tests]
|
||||||
|
|
||||||
def show
|
def show
|
||||||
raise Discourse::NotFound unless last_modified.present?
|
raise Discourse::NotFound if last_modified.blank?
|
||||||
return render body: nil, status: 304 if not_modified?
|
return render body: nil, status: 304 if not_modified?
|
||||||
|
|
||||||
# Security: safe due to route constraint
|
# Security: safe due to route constraint
|
||||||
|
@ -34,7 +34,7 @@ class ThemeJavascriptsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_map
|
def show_map
|
||||||
raise Discourse::NotFound unless last_modified.present?
|
raise Discourse::NotFound if last_modified.blank?
|
||||||
return render body: nil, status: 304 if not_modified?
|
return render body: nil, status: 304 if not_modified?
|
||||||
|
|
||||||
# Security: safe due to route constraint
|
# Security: safe due to route constraint
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ class TopicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_status_presence(key, attr)
|
def check_for_status_presence(key, attr)
|
||||||
invalid_param(key) unless %w[pinned pinned_globally visible closed archived].include?(attr)
|
invalid_param(key) if %w[pinned pinned_globally visible closed archived].exclude?(attr)
|
||||||
end
|
end
|
||||||
|
|
||||||
def invalid_param(key)
|
def invalid_param(key)
|
||||||
|
|
|
@ -1143,7 +1143,7 @@ class UsersController < ApplicationController
|
||||||
1.hour,
|
1.hour,
|
||||||
).performed!
|
).performed!
|
||||||
@user = User.find_by_username_or_email(params[:username])
|
@user = User.find_by_username_or_email(params[:username])
|
||||||
raise Discourse::InvalidAccess.new unless @user.present?
|
raise Discourse::InvalidAccess.new if @user.blank?
|
||||||
raise Discourse::InvalidAccess.new unless @user.confirm_password?(params[:password])
|
raise Discourse::InvalidAccess.new unless @user.confirm_password?(params[:password])
|
||||||
elsif user_key = session[SessionController::ACTIVATE_USER_KEY]
|
elsif user_key = session[SessionController::ACTIVATE_USER_KEY]
|
||||||
RateLimiter.new(nil, "activate-edit-email-hr-user-key-#{user_key}", 5, 1.hour).performed!
|
RateLimiter.new(nil, "activate-edit-email-hr-user-key-#{user_key}", 5, 1.hour).performed!
|
||||||
|
@ -1342,9 +1342,7 @@ class UsersController < ApplicationController
|
||||||
return render json: failed_json, status: 422
|
return render json: failed_json, status: 422
|
||||||
end
|
end
|
||||||
|
|
||||||
unless SiteSetting.selectable_avatars.include?(upload)
|
return render json: failed_json, status: 422 if SiteSetting.selectable_avatars.exclude?(upload)
|
||||||
return render json: failed_json, status: 422
|
|
||||||
end
|
|
||||||
|
|
||||||
user.uploaded_avatar_id = upload.id
|
user.uploaded_avatar_id = upload.id
|
||||||
|
|
||||||
|
@ -2096,7 +2094,7 @@ class UsersController < ApplicationController
|
||||||
]
|
]
|
||||||
|
|
||||||
editable_custom_fields = User.editable_user_custom_fields(by_staff: current_user.try(:staff?))
|
editable_custom_fields = User.editable_user_custom_fields(by_staff: current_user.try(:staff?))
|
||||||
permitted << { custom_fields: editable_custom_fields } unless editable_custom_fields.blank?
|
permitted << { custom_fields: editable_custom_fields } if editable_custom_fields.present?
|
||||||
permitted.concat UserUpdater::OPTION_ATTR
|
permitted.concat UserUpdater::OPTION_ATTR
|
||||||
permitted.concat UserUpdater::CATEGORY_IDS.keys.map { |k| { k => [] } }
|
permitted.concat UserUpdater::CATEGORY_IDS.keys.map { |k| { k => [] } }
|
||||||
permitted.concat UserUpdater::TAG_NAMES.keys
|
permitted.concat UserUpdater::TAG_NAMES.keys
|
||||||
|
|
|
@ -45,7 +45,7 @@ module UserNotificationsHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result unless result.blank?
|
return result if result.present?
|
||||||
|
|
||||||
# If there is no first paragraph with text, return the first paragraph with
|
# If there is no first paragraph with text, return the first paragraph with
|
||||||
# something else (an image) or div (a onebox).
|
# something else (an image) or div (a onebox).
|
||||||
|
@ -66,7 +66,7 @@ module UserNotificationsHelper
|
||||||
def show_username_on_post(post)
|
def show_username_on_post(post)
|
||||||
return true unless SiteSetting.enable_names?
|
return true unless SiteSetting.enable_names?
|
||||||
return true unless SiteSetting.display_name_on_posts?
|
return true unless SiteSetting.display_name_on_posts?
|
||||||
return true unless post.user.name.present?
|
return true if post.user.name.blank?
|
||||||
|
|
||||||
normalize_name(post.user.name) != normalize_name(post.user.username)
|
normalize_name(post.user.name) != normalize_name(post.user.username)
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Jobs::Onceoff < ::Jobs::Base
|
||||||
.select { |klass| klass < self }
|
.select { |klass| klass < self }
|
||||||
.each do |klass|
|
.each do |klass|
|
||||||
job_name = name_for(klass)
|
job_name = name_for(klass)
|
||||||
Jobs.enqueue(job_name.underscore.to_sym) unless previously_ran.include?(job_name)
|
Jobs.enqueue(job_name.underscore.to_sym) if previously_ran.exclude?(job_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Jobs
|
||||||
def execute(args)
|
def execute(args)
|
||||||
@user = User.find_by(id: args[:user_id])
|
@user = User.find_by(id: args[:user_id])
|
||||||
|
|
||||||
return unless user.present?
|
return if user.blank?
|
||||||
|
|
||||||
# We need to account for the case where the instance allows
|
# We need to account for the case where the instance allows
|
||||||
# name to be empty by falling back to username.
|
# name to be empty by falling back to username.
|
||||||
|
|
|
@ -9,7 +9,7 @@ module Jobs
|
||||||
sidekiq_options queue: "low"
|
sidekiq_options queue: "low"
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:topic_link_id) unless args[:topic_link_id].present?
|
raise Discourse::InvalidParameters.new(:topic_link_id) if args[:topic_link_id].blank?
|
||||||
|
|
||||||
topic_link = TopicLink.find_by(id: args[:topic_link_id], internal: false, crawled_at: nil)
|
topic_link = TopicLink.find_by(id: args[:topic_link_id], internal: false, crawled_at: nil)
|
||||||
return if topic_link.blank?
|
return if topic_link.blank?
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Jobs
|
||||||
class CreateLinkedTopic < ::Jobs::Base
|
class CreateLinkedTopic < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
reference_post = Post.find_by(id: args[:post_id])
|
reference_post = Post.find_by(id: args[:post_id])
|
||||||
return unless reference_post.present?
|
return if reference_post.blank?
|
||||||
parent_topic = reference_post.topic
|
parent_topic = reference_post.topic
|
||||||
return unless parent_topic.present? && parent_topic.regular?
|
return unless parent_topic.present? && parent_topic.regular?
|
||||||
parent_topic_id = parent_topic.id
|
parent_topic_id = parent_topic.id
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Jobs::CreateUserReviewable < ::Jobs::Base
|
||||||
attr_reader :reviewable
|
attr_reader :reviewable
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters unless args[:user_id].present?
|
raise Discourse::InvalidParameters if args[:user_id].blank?
|
||||||
|
|
||||||
reason = nil
|
reason = nil
|
||||||
reason ||= :must_approve_users if SiteSetting.must_approve_users?
|
reason ||= :must_approve_users if SiteSetting.must_approve_users?
|
||||||
|
|
|
@ -38,7 +38,7 @@ module Jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_argument!(key)
|
def validate_argument!(key)
|
||||||
raise Discourse::InvalidParameters.new(key) unless @arguments[key].present?
|
raise Discourse::InvalidParameters.new(key) if @arguments[key].blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_webhook!
|
def send_webhook!
|
||||||
|
|
|
@ -4,14 +4,14 @@ module Jobs
|
||||||
class FeatureTopicUsers < ::Jobs::Base
|
class FeatureTopicUsers < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
topic_id = args[:topic_id]
|
topic_id = args[:topic_id]
|
||||||
raise Discourse::InvalidParameters.new(:topic_id) unless topic_id.present?
|
raise Discourse::InvalidParameters.new(:topic_id) if topic_id.blank?
|
||||||
|
|
||||||
topic = Topic.find_by(id: topic_id)
|
topic = Topic.find_by(id: topic_id)
|
||||||
|
|
||||||
# Topic may be hard deleted due to spam, no point complaining
|
# Topic may be hard deleted due to spam, no point complaining
|
||||||
# we would have to look at the topics table id sequence to find cases
|
# we would have to look at the topics table id sequence to find cases
|
||||||
# where this was called with an invalid id, no point really
|
# where this was called with an invalid id, no point really
|
||||||
return unless topic.present?
|
return if topic.blank?
|
||||||
|
|
||||||
topic.feature_topic_users(args)
|
topic.feature_topic_users(args)
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,10 @@ module Jobs
|
||||||
# Asynchronously send an email
|
# Asynchronously send an email
|
||||||
class InviteEmail < ::Jobs::Base
|
class InviteEmail < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:invite_id) unless args[:invite_id].present?
|
raise Discourse::InvalidParameters.new(:invite_id) if args[:invite_id].blank?
|
||||||
|
|
||||||
invite = Invite.find_by(id: args[:invite_id])
|
invite = Invite.find_by(id: args[:invite_id])
|
||||||
return unless invite.present?
|
return if invite.blank?
|
||||||
|
|
||||||
message = InviteMailer.send_invite(invite, invite_to_topic: args[:invite_to_topic])
|
message = InviteMailer.send_invite(invite, invite_to_topic: args[:invite_to_topic])
|
||||||
Email::Sender.new(message, :invite).send
|
Email::Sender.new(message, :invite).send
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Jobs
|
||||||
# Asynchronously send an email
|
# Asynchronously send an email
|
||||||
class InvitePasswordInstructionsEmail < ::Jobs::Base
|
class InvitePasswordInstructionsEmail < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:username) unless args[:username].present?
|
raise Discourse::InvalidParameters.new(:username) if args[:username].blank?
|
||||||
user = User.find_by_username_or_email(args[:username])
|
user = User.find_by_username_or_email(args[:username])
|
||||||
message = InviteMailer.send_password_instructions(user)
|
message = InviteMailer.send_password_instructions(user)
|
||||||
Email::Sender.new(message, :invite_password_instructions).send
|
Email::Sender.new(message, :invite_password_instructions).send
|
||||||
|
|
|
@ -17,7 +17,7 @@ module Jobs
|
||||||
moved_by = User.find_by(id: args[:moved_by_id])
|
moved_by = User.find_by(id: args[:moved_by_id])
|
||||||
|
|
||||||
posts.each do |p|
|
posts.each do |p|
|
||||||
unless users_notified.include?(p.user_id)
|
if users_notified.exclude?(p.user_id)
|
||||||
p.user.notifications.create(
|
p.user.notifications.create(
|
||||||
notification_type: Notification.types[:moved_post],
|
notification_type: Notification.types[:moved_post],
|
||||||
topic_id: p.topic_id,
|
topic_id: p.topic_id,
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Jobs
|
||||||
DistributedMutex.synchronize("process_post_#{args[:post_id]}", validity: 10.minutes) do
|
DistributedMutex.synchronize("process_post_#{args[:post_id]}", validity: 10.minutes) do
|
||||||
post = Post.find_by(id: args[:post_id])
|
post = Post.find_by(id: args[:post_id])
|
||||||
# two levels of deletion
|
# two levels of deletion
|
||||||
return unless post.present? && post.topic.present?
|
return if post.blank? || post.topic.blank?
|
||||||
|
|
||||||
orig_cooked = post.cooked
|
orig_cooked = post.cooked
|
||||||
recooked = nil
|
recooked = nil
|
||||||
|
|
|
@ -152,7 +152,7 @@ module Jobs
|
||||||
|
|
||||||
def should_download_image?(src, post = nil)
|
def should_download_image?(src, post = nil)
|
||||||
# make sure we actually have a url
|
# make sure we actually have a url
|
||||||
return false unless src.present?
|
return false if src.blank?
|
||||||
|
|
||||||
local_bases =
|
local_bases =
|
||||||
[Discourse.base_url, Discourse.asset_host, SiteSetting.external_emoji_url.presence].compact
|
[Discourse.base_url, Discourse.asset_host, SiteSetting.external_emoji_url.presence].compact
|
||||||
|
|
|
@ -22,7 +22,7 @@ module Jobs
|
||||||
.each do |push_url, group|
|
.each do |push_url, group|
|
||||||
notifications = group.map { |client_id, _| notification.merge(client_id: client_id) }
|
notifications = group.map { |client_id, _| notification.merge(client_id: client_id) }
|
||||||
|
|
||||||
next unless push_url.present?
|
next if push_url.blank?
|
||||||
|
|
||||||
result =
|
result =
|
||||||
Excon.post(
|
Excon.post(
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Jobs
|
||||||
def execute(args)
|
def execute(args)
|
||||||
topic_id = args[:topic_id]
|
topic_id = args[:topic_id]
|
||||||
|
|
||||||
return unless topic_id.present?
|
return if topic_id.blank?
|
||||||
|
|
||||||
topic = Topic.find_by(id: topic_id)
|
topic = Topic.find_by(id: topic_id)
|
||||||
topic.remove_banner!(Discourse.system_user) if topic.present?
|
topic.remove_banner!(Discourse.system_user) if topic.present?
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Jobs
|
||||||
# Asynchronously retrieve a topic from an embedded site
|
# Asynchronously retrieve a topic from an embedded site
|
||||||
class RetrieveTopic < ::Jobs::Base
|
class RetrieveTopic < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:embed_url) unless args[:embed_url].present?
|
raise Discourse::InvalidParameters.new(:embed_url) if args[:embed_url].blank?
|
||||||
|
|
||||||
user = nil
|
user = nil
|
||||||
user = User.find_by(id: args[:user_id]) if args[:user_id]
|
user = User.find_by(id: args[:user_id]) if args[:user_id]
|
||||||
|
|
|
@ -5,8 +5,8 @@ require "image_sizer"
|
||||||
module Jobs
|
module Jobs
|
||||||
class SendSystemMessage < ::Jobs::Base
|
class SendSystemMessage < ::Jobs::Base
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?
|
raise Discourse::InvalidParameters.new(:user_id) if args[:user_id].blank?
|
||||||
raise Discourse::InvalidParameters.new(:message_type) unless args[:message_type].present?
|
raise Discourse::InvalidParameters.new(:message_type) if args[:message_type].blank?
|
||||||
|
|
||||||
user = User.find_by(id: args[:user_id])
|
user = User.find_by(id: args[:user_id])
|
||||||
return if user.blank?
|
return if user.blank?
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
module Jobs
|
module Jobs
|
||||||
class SyncTopicUserBookmarked < ::Jobs::Base
|
class SyncTopicUserBookmarked < ::Jobs::Base
|
||||||
def execute(args = {})
|
def execute(args = {})
|
||||||
raise Discourse::InvalidParameters.new(:topic_id) unless args[:topic_id].present?
|
raise Discourse::InvalidParameters.new(:topic_id) if args[:topic_id].blank?
|
||||||
|
|
||||||
DB.exec(<<~SQL, topic_id: args[:topic_id])
|
DB.exec(<<~SQL, topic_id: args[:topic_id])
|
||||||
SELECT bookmarks.user_id, COUNT(*)
|
SELECT bookmarks.user_id, COUNT(*)
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Jobs::TruncateUserFlagStats < ::Jobs::Base
|
||||||
|
|
||||||
# To give users a chance to improve, we limit their flag stats to the last N flags
|
# To give users a chance to improve, we limit their flag stats to the last N flags
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:user_ids) unless args[:user_ids].present?
|
raise Discourse::InvalidParameters.new(:user_ids) if args[:user_ids].blank?
|
||||||
|
|
||||||
args[:user_ids].each do |u|
|
args[:user_ids].each do |u|
|
||||||
user_stat = UserStat.find_by(user_id: u)
|
user_stat = UserStat.find_by(user_id: u)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Jobs
|
||||||
def execute(args)
|
def execute(args)
|
||||||
topic_id = args[:topic_id]
|
topic_id = args[:topic_id]
|
||||||
|
|
||||||
return unless topic_id.present?
|
return if topic_id.blank?
|
||||||
|
|
||||||
topic = Topic.find_by(id: topic_id)
|
topic = Topic.find_by(id: topic_id)
|
||||||
topic.update_pinned(false) if topic.present?
|
topic.update_pinned(false) if topic.present?
|
||||||
|
|
|
@ -70,7 +70,7 @@ module Jobs
|
||||||
.with_deleted
|
.with_deleted
|
||||||
.joins(quoted("posts.id"))
|
.joins(quoted("posts.id"))
|
||||||
.where("p.user_id = :user_id", user_id: @user_id)
|
.where("p.user_id = :user_id", user_id: @user_id)
|
||||||
.find_each { |post| update_post(post) unless updated_post_ids.include?(post.id) }
|
.find_each { |post| update_post(post) if updated_post_ids.exclude?(post.id) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_revisions
|
def update_revisions
|
||||||
|
|
|
@ -27,8 +27,8 @@ module Jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
raise Discourse::InvalidParameters.new(:user_id) unless args[:user_id].present?
|
raise Discourse::InvalidParameters.new(:user_id) if args[:user_id].blank?
|
||||||
raise Discourse::InvalidParameters.new(:type) unless args[:type].present?
|
raise Discourse::InvalidParameters.new(:type) if args[:type].blank?
|
||||||
|
|
||||||
# This is for performance. Quit out fast without doing a bunch
|
# This is for performance. Quit out fast without doing a bunch
|
||||||
# of extra work when emails are disabled.
|
# of extra work when emails are disabled.
|
||||||
|
|
|
@ -506,7 +506,7 @@ class UserNotifications < ActionMailer::Base
|
||||||
|
|
||||||
if post && SiteSetting.enable_names && SiteSetting.display_name_on_email_from
|
if post && SiteSetting.enable_names && SiteSetting.display_name_on_email_from
|
||||||
name = User.where(id: notification_data[:original_user_id] || post.user_id).pick(:name)
|
name = User.where(id: notification_data[:original_user_id] || post.user_id).pick(:name)
|
||||||
user_name = name unless name.blank?
|
user_name = name if name.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
allow_reply_by_email = opts[:allow_reply_by_email] unless user.suspended?
|
allow_reply_by_email = opts[:allow_reply_by_email] unless user.suspended?
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
class ApplicationRequest < ActiveRecord::Base
|
class ApplicationRequest < ActiveRecord::Base
|
||||||
enum req_type: %i[
|
enum req_type: {
|
||||||
http_total
|
http_total: 0,
|
||||||
http_2xx
|
http_2xx: 1,
|
||||||
http_background
|
http_background: 2,
|
||||||
http_3xx
|
http_3xx: 3,
|
||||||
http_4xx
|
http_4xx: 4,
|
||||||
http_5xx
|
http_5xx: 5,
|
||||||
page_view_crawler
|
page_view_crawler: 6,
|
||||||
page_view_logged_in
|
page_view_logged_in: 7,
|
||||||
page_view_anon
|
page_view_anon: 8,
|
||||||
page_view_logged_in_mobile
|
page_view_logged_in_mobile: 9,
|
||||||
page_view_anon_mobile
|
page_view_anon_mobile: 10,
|
||||||
api
|
api: 11,
|
||||||
user_api
|
user_api: 12,
|
||||||
page_view_anon_browser
|
page_view_anon_browser: 13,
|
||||||
page_view_anon_browser_mobile
|
page_view_anon_browser_mobile: 14,
|
||||||
page_view_logged_in_browser
|
page_view_logged_in_browser: 15,
|
||||||
page_view_logged_in_browser_mobile
|
page_view_logged_in_browser_mobile: 16,
|
||||||
]
|
}
|
||||||
|
|
||||||
include CachedCounting
|
include CachedCounting
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ class Category < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_slug
|
def ensure_slug
|
||||||
return unless name.present?
|
return if name.blank?
|
||||||
|
|
||||||
self.name.strip!
|
self.name.strip!
|
||||||
|
|
||||||
|
@ -948,7 +948,7 @@ class Category < ActiveRecord::Base
|
||||||
|
|
||||||
# If the name changes, try and update the category definition topic too if it's an exact match
|
# If the name changes, try and update the category definition topic too if it's an exact match
|
||||||
def rename_category_definition
|
def rename_category_definition
|
||||||
return unless topic.present?
|
return if topic.blank?
|
||||||
old_name = saved_changes.transform_values(&:first)["name"]
|
old_name = saved_changes.transform_values(&:first)["name"]
|
||||||
if topic.title == I18n.t("category.topic_prefix", category: old_name)
|
if topic.title == I18n.t("category.topic_prefix", category: old_name)
|
||||||
topic.update_attribute(:title, I18n.t("category.topic_prefix", category: name))
|
topic.update_attribute(:title, I18n.t("category.topic_prefix", category: name))
|
||||||
|
|
|
@ -49,7 +49,7 @@ class DirectoryColumn < ActiveRecord::Base
|
||||||
column.enabled = false
|
column.enabled = false
|
||||||
end
|
end
|
||||||
|
|
||||||
unless @@plugin_directory_columns.include?(directory_column.name)
|
if @@plugin_directory_columns.exclude?(directory_column.name)
|
||||||
@@plugin_directory_columns << directory_column.name
|
@@plugin_directory_columns << directory_column.name
|
||||||
DirectoryItem.add_plugin_query(attrs[:query])
|
DirectoryItem.add_plugin_query(attrs[:query])
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,10 +24,10 @@ class EmbeddableHost < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return false unless uri.present?
|
return false if uri.blank?
|
||||||
|
|
||||||
host = uri.host
|
host = uri.host
|
||||||
return false unless host.present?
|
return false if host.blank?
|
||||||
|
|
||||||
host << ":#{uri.port}" if uri.port.present? && uri.port != 80 && uri.port != 443
|
host << ":#{uri.port}" if uri.port.present? && uri.port != 80 && uri.port != 443
|
||||||
|
|
||||||
|
|
|
@ -857,7 +857,7 @@ class Group < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def bulk_add(user_ids)
|
def bulk_add(user_ids)
|
||||||
return unless user_ids.present?
|
return if user_ids.blank?
|
||||||
|
|
||||||
Group.transaction do
|
Group.transaction do
|
||||||
sql = <<~SQL
|
sql = <<~SQL
|
||||||
|
|
|
@ -33,13 +33,13 @@ class GroupHistory < ActiveRecord::Base
|
||||||
|
|
||||||
if !params.blank?
|
if !params.blank?
|
||||||
params = params.slice(*filters)
|
params = params.slice(*filters)
|
||||||
records = records.where(action: self.actions[params[:action].to_sym]) unless params[
|
records = records.where(action: self.actions[params[:action].to_sym]) if params[
|
||||||
:action
|
:action
|
||||||
].blank?
|
].present?
|
||||||
records = records.where(subject: params[:subject]) unless params[:subject].blank?
|
records = records.where(subject: params[:subject]) if params[:subject].present?
|
||||||
|
|
||||||
%i[acting_user target_user].each do |filter|
|
%i[acting_user target_user].each do |filter|
|
||||||
unless params[filter].blank?
|
if params[filter].present?
|
||||||
id = User.where(username_lower: params[filter]).pluck(:id)
|
id = User.where(username_lower: params[filter]).pluck(:id)
|
||||||
records = records.where("#{filter}_id" => id)
|
records = records.where("#{filter}_id" => id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class IncomingDomain < ActiveRecord::Base
|
class IncomingDomain < ActiveRecord::Base
|
||||||
def self.add!(uri)
|
def self.add!(uri)
|
||||||
name = uri.host
|
name = uri.host
|
||||||
return unless name.present?
|
return if name.blank?
|
||||||
|
|
||||||
https = uri.scheme == "https"
|
https = uri.scheme == "https"
|
||||||
port = uri.port
|
port = uri.port
|
||||||
|
|
|
@ -60,7 +60,7 @@ class IncomingLink < ActiveRecord::Base
|
||||||
self.incoming_referer_id = nil
|
self.incoming_referer_id = nil
|
||||||
|
|
||||||
# will set incoming_referer_id
|
# will set incoming_referer_id
|
||||||
return unless referer.present?
|
return if referer.blank?
|
||||||
|
|
||||||
parsed = URI.parse(referer)
|
parsed = URI.parse(referer)
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class InviteRedeemer
|
||||||
field_val = field_params[f.id.to_s]
|
field_val = field_params[f.id.to_s]
|
||||||
fields["#{User::USER_FIELD_PREFIX}#{f.id}"] = field_val[
|
fields["#{User::USER_FIELD_PREFIX}#{f.id}"] = field_val[
|
||||||
0...UserField.max_length
|
0...UserField.max_length
|
||||||
] unless field_val.blank?
|
] if field_val.present?
|
||||||
end
|
end
|
||||||
user.custom_fields = fields
|
user.custom_fields = fields
|
||||||
end
|
end
|
||||||
|
|
|
@ -1326,14 +1326,14 @@ class Post < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def parse_quote_into_arguments(quote)
|
def parse_quote_into_arguments(quote)
|
||||||
return {} unless quote.present?
|
return {} if quote.blank?
|
||||||
args = HashWithIndifferentAccess.new
|
args = HashWithIndifferentAccess.new
|
||||||
quote.first.scan(/([a-z]+)\:(\d+)/).each { |arg| args[arg[0]] = arg[1].to_i }
|
quote.first.scan(/([a-z]+)\:(\d+)/).each { |arg| args[arg[0]] = arg[1].to_i }
|
||||||
args
|
args
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_quoted_post_numbers(num)
|
def add_to_quoted_post_numbers(num)
|
||||||
return unless num.present?
|
return if num.blank?
|
||||||
self.quoted_post_numbers ||= []
|
self.quoted_post_numbers ||= []
|
||||||
self.quoted_post_numbers << num
|
self.quoted_post_numbers << num
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ class PostAnalyzer
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_oneboxes?
|
def has_oneboxes?
|
||||||
return false unless @raw.present?
|
return false if @raw.blank?
|
||||||
|
|
||||||
cooked_stripped
|
cooked_stripped
|
||||||
found_oneboxes?
|
found_oneboxes?
|
||||||
|
@ -56,7 +56,7 @@ class PostAnalyzer
|
||||||
|
|
||||||
# How many images are present in the post
|
# How many images are present in the post
|
||||||
def embedded_media_count
|
def embedded_media_count
|
||||||
return 0 unless @raw.present?
|
return 0 if @raw.blank?
|
||||||
|
|
||||||
# TODO - do we need to look for tags other than img, video and audio?
|
# TODO - do we need to look for tags other than img, video and audio?
|
||||||
cooked_stripped
|
cooked_stripped
|
||||||
|
@ -71,7 +71,7 @@ class PostAnalyzer
|
||||||
|
|
||||||
# How many attachments are present in the post
|
# How many attachments are present in the post
|
||||||
def attachment_count
|
def attachment_count
|
||||||
return 0 unless @raw.present?
|
return 0 if @raw.blank?
|
||||||
|
|
||||||
attachments =
|
attachments =
|
||||||
cooked_stripped.css("a.attachment[href^=\"#{Discourse.store.absolute_base_url}\"]")
|
cooked_stripped.css("a.attachment[href^=\"#{Discourse.store.absolute_base_url}\"]")
|
||||||
|
@ -119,7 +119,7 @@ class PostAnalyzer
|
||||||
|
|
||||||
# Returns an array of all links in a post excluding mentions
|
# Returns an array of all links in a post excluding mentions
|
||||||
def raw_links
|
def raw_links
|
||||||
return [] unless @raw.present?
|
return [] if @raw.blank?
|
||||||
return @raw_links if @raw_links.present?
|
return @raw_links if @raw_links.present?
|
||||||
|
|
||||||
@raw_links = []
|
@raw_links = []
|
||||||
|
|
|
@ -676,7 +676,7 @@ class PostMover
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_allowed_users(usernames)
|
def add_allowed_users(usernames)
|
||||||
return unless usernames.present?
|
return if usernames.blank?
|
||||||
|
|
||||||
names = usernames.split(",").flatten
|
names = usernames.split(",").flatten
|
||||||
User
|
User
|
||||||
|
|
|
@ -207,7 +207,7 @@ SQL
|
||||||
new_posts_read = timings.size - existing.size if is_regular
|
new_posts_read = timings.size - existing.size if is_regular
|
||||||
|
|
||||||
timings.each_with_index do |(post_number, time), index|
|
timings.each_with_index do |(post_number, time), index|
|
||||||
unless existing.include?(index)
|
if existing.exclude?(index)
|
||||||
PostTiming.record_new_timing(
|
PostTiming.record_new_timing(
|
||||||
topic_id: topic_id,
|
topic_id: topic_id,
|
||||||
post_number: post_number,
|
post_number: post_number,
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Reviewable < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.valid_type?(type)
|
def self.valid_type?(type)
|
||||||
return false unless Reviewable.types.include?(type)
|
return false if Reviewable.types.exclude?(type)
|
||||||
type.constantize <= Reviewable
|
type.constantize <= Reviewable
|
||||||
rescue NameError
|
rescue NameError
|
||||||
false
|
false
|
||||||
|
@ -383,7 +383,7 @@ class Reviewable < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.viewable_by(user, order: nil, preload: true)
|
def self.viewable_by(user, order: nil, preload: true)
|
||||||
return none unless user.present?
|
return none if user.blank?
|
||||||
|
|
||||||
result = self.order(order || "reviewables.score desc, reviewables.created_at desc")
|
result = self.order(order || "reviewables.score desc, reviewables.created_at desc")
|
||||||
|
|
||||||
|
@ -732,7 +732,7 @@ class Reviewable < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_flag_stats(status:, user_ids:)
|
def update_flag_stats(status:, user_ids:)
|
||||||
return unless %i[agreed disagreed ignored].include?(status)
|
return if %i[agreed disagreed ignored].exclude?(status)
|
||||||
|
|
||||||
# Don't count self-flags
|
# Don't count self-flags
|
||||||
user_ids -= [post&.user_id]
|
user_ids -= [post&.user_id]
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ScreenedIpAddress < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_match
|
def check_for_match
|
||||||
unless self.errors[:ip_address].present?
|
if self.errors[:ip_address].blank?
|
||||||
matched = self.class.match_for_ip_address(self.ip_address)
|
matched = self.class.match_for_ip_address(self.ip_address)
|
||||||
if matched && matched.action_type == self.action_type
|
if matched && matched.action_type == self.action_type
|
||||||
self.errors.add(:ip_address, :ip_address_already_screened)
|
self.errors.add(:ip_address, :ip_address_already_screened)
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SearchLog < ActiveRecord::Base
|
||||||
return [:error] if term.blank?
|
return [:error] if term.blank?
|
||||||
|
|
||||||
search_type = search_types[search_type]
|
search_type = search_types[search_type]
|
||||||
return [:error] unless search_type.present? && ip_address.present?
|
return [:error] if search_type.blank? || ip_address.blank?
|
||||||
|
|
||||||
ip_address = nil if user_id
|
ip_address = nil if user_id
|
||||||
key = redis_key(user_id: user_id, ip_address: ip_address)
|
key = redis_key(user_id: user_id, ip_address: ip_address)
|
||||||
|
|
|
@ -233,10 +233,10 @@ class Tag < ActiveRecord::Base
|
||||||
def update_synonym_associations
|
def update_synonym_associations
|
||||||
if target_tag_id && saved_change_to_target_tag_id?
|
if target_tag_id && saved_change_to_target_tag_id?
|
||||||
target_tag.tag_groups.each do |tag_group|
|
target_tag.tag_groups.each do |tag_group|
|
||||||
tag_group.tags << self unless tag_group.tags.include?(self)
|
tag_group.tags << self if tag_group.tags.exclude?(self)
|
||||||
end
|
end
|
||||||
target_tag.categories.each do |category|
|
target_tag.categories.each do |category|
|
||||||
category.tags << self unless category.tags.include?(self)
|
category.tags << self if category.tags.exclude?(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ThemeField < ActiveRecord::Base
|
||||||
|
|
||||||
scope :find_by_theme_ids,
|
scope :find_by_theme_ids,
|
||||||
->(theme_ids) do
|
->(theme_ids) do
|
||||||
return none unless theme_ids.present?
|
return none if theme_ids.blank?
|
||||||
|
|
||||||
where(theme_id: theme_ids).joins(
|
where(theme_id: theme_ids).joins(
|
||||||
"JOIN (
|
"JOIN (
|
||||||
|
@ -34,7 +34,7 @@ class ThemeField < ActiveRecord::Base
|
||||||
|
|
||||||
scope :filter_locale_fields,
|
scope :filter_locale_fields,
|
||||||
->(locale_codes) do
|
->(locale_codes) do
|
||||||
return none unless locale_codes.present?
|
return none if locale_codes.blank?
|
||||||
|
|
||||||
where(target_id: Theme.targets[:translations], name: locale_codes).joins(
|
where(target_id: Theme.targets[:translations], name: locale_codes).joins(
|
||||||
DB.sql_fragment(
|
DB.sql_fragment(
|
||||||
|
@ -420,7 +420,7 @@ class ThemeField < ActiveRecord::Base
|
||||||
if basic_html_field? || translation_field?
|
if basic_html_field? || translation_field?
|
||||||
self.value_baked, self.error =
|
self.value_baked, self.error =
|
||||||
translation_field? ? process_translation : process_html(self.value)
|
translation_field? ? process_translation : process_html(self.value)
|
||||||
self.error = nil unless self.error.present?
|
self.error = nil if self.error.blank?
|
||||||
self.compiler_version = Theme.compiler_version
|
self.compiler_version = Theme.compiler_version
|
||||||
CSP::Extension.clear_theme_extensions_cache!
|
CSP::Extension.clear_theme_extensions_cache!
|
||||||
elsif extra_js_field? || js_tests_field?
|
elsif extra_js_field? || js_tests_field?
|
||||||
|
|
|
@ -1372,7 +1372,7 @@ class Topic < ActiveRecord::Base
|
||||||
self.slug_computed_callbacks = []
|
self.slug_computed_callbacks = []
|
||||||
|
|
||||||
def slug_for_topic(title)
|
def slug_for_topic(title)
|
||||||
return "" unless title.present?
|
return "" if title.blank?
|
||||||
slug = Slug.for(title)
|
slug = Slug.for(title)
|
||||||
|
|
||||||
# this is a hook for plugins that need to modify the generated slug
|
# this is a hook for plugins that need to modify the generated slug
|
||||||
|
@ -1384,7 +1384,7 @@ class Topic < ActiveRecord::Base
|
||||||
# Even if the slug column in the database is null, topic.slug will return something:
|
# Even if the slug column in the database is null, topic.slug will return something:
|
||||||
def slug
|
def slug
|
||||||
unless slug = read_attribute(:slug)
|
unless slug = read_attribute(:slug)
|
||||||
return "" unless title.present?
|
return "" if title.blank?
|
||||||
slug = slug_for_topic(title)
|
slug = slug_for_topic(title)
|
||||||
if new_record?
|
if new_record?
|
||||||
write_attribute(:slug, slug)
|
write_attribute(:slug, slug)
|
||||||
|
@ -1445,12 +1445,12 @@ class Topic < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_pin_for(user)
|
def clear_pin_for(user)
|
||||||
return unless user.present?
|
return if user.blank?
|
||||||
TopicUser.change(user.id, id, cleared_pinned_at: Time.now)
|
TopicUser.change(user.id, id, cleared_pinned_at: Time.now)
|
||||||
end
|
end
|
||||||
|
|
||||||
def re_pin_for(user)
|
def re_pin_for(user)
|
||||||
return unless user.present?
|
return if user.blank?
|
||||||
TopicUser.change(user.id, id, cleared_pinned_at: nil)
|
TopicUser.change(user.id, id, cleared_pinned_at: nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2062,7 +2062,7 @@ class Topic < ActiveRecord::Base
|
||||||
|
|
||||||
def self.publish_stats_to_clients!(topic_id, type, opts = {})
|
def self.publish_stats_to_clients!(topic_id, type, opts = {})
|
||||||
topic = Topic.find_by(id: topic_id)
|
topic = Topic.find_by(id: topic_id)
|
||||||
return unless topic.present?
|
return if topic.blank?
|
||||||
|
|
||||||
case type
|
case type
|
||||||
when :liked, :unliked
|
when :liked, :unliked
|
||||||
|
|
|
@ -315,7 +315,7 @@ class TopicEmbed < ActiveRecord::Base
|
||||||
return result if result.size >= 100
|
return result if result.size >= 100
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return result unless result.blank?
|
return result if result.present?
|
||||||
|
|
||||||
# If there is no first paragraph, return the first div (onebox)
|
# If there is no first paragraph, return the first div (onebox)
|
||||||
doc.css("div").first.to_s
|
doc.css("div").first.to_s
|
||||||
|
|
|
@ -86,7 +86,7 @@ class TopicLinkClick < ActiveRecord::Base
|
||||||
).first
|
).first
|
||||||
|
|
||||||
# If no link is found...
|
# If no link is found...
|
||||||
unless link.present?
|
if link.blank?
|
||||||
# ... return the url for relative links or when using the same host
|
# ... return the url for relative links or when using the same host
|
||||||
return url if url =~ %r{\A/[^/]} || uri.try(:host) == Discourse.current_hostname
|
return url if url =~ %r{\A/[^/]} || uri.try(:host) == Discourse.current_hostname
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class TranslationOverride < ActiveRecord::Base
|
||||||
|
|
||||||
validate :check_interpolation_keys
|
validate :check_interpolation_keys
|
||||||
|
|
||||||
enum :status, %i[up_to_date outdated invalid_interpolation_keys deprecated]
|
enum status: { up_to_date: 0, outdated: 1, invalid_interpolation_keys: 2, deprecated: 3 }
|
||||||
|
|
||||||
def self.upsert!(locale, key, value)
|
def self.upsert!(locale, key, value)
|
||||||
params = { locale: locale, translation_key: key }
|
params = { locale: locale, translation_key: key }
|
||||||
|
|
|
@ -898,7 +898,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
def password=(password)
|
def password=(password)
|
||||||
# special case for passwordless accounts
|
# special case for passwordless accounts
|
||||||
@raw_password = password unless password.blank?
|
@raw_password = password if password.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def password
|
def password
|
||||||
|
|
|
@ -203,7 +203,7 @@ class UserProfile < ActiveRecord::Base
|
||||||
URI.parse(self.website).host
|
URI.parse(self.website).host
|
||||||
rescue URI::Error
|
rescue URI::Error
|
||||||
end
|
end
|
||||||
unless allowed_domains.split("|").include?(domain)
|
if allowed_domains.split("|").exclude?(domain)
|
||||||
self.errors.add :base,
|
self.errors.add :base,
|
||||||
(
|
(
|
||||||
I18n.t(
|
I18n.t(
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ReviewableSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def claimed_by
|
def claimed_by
|
||||||
return nil unless @options[:claimed_topics].present?
|
return nil if @options[:claimed_topics].blank?
|
||||||
@options[:claimed_topics][object.topic_id]
|
@options[:claimed_topics][object.topic_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class UserAuthTokenSerializer < ApplicationSerializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def seen_at
|
def seen_at
|
||||||
return object.created_at unless object.seen_at.present?
|
return object.created_at if object.seen_at.blank?
|
||||||
|
|
||||||
object.seen_at
|
object.seen_at
|
||||||
end
|
end
|
||||||
|
|
|
@ -79,7 +79,7 @@ class AnonymousShadowCreator
|
||||||
|
|
||||||
def resolve_username
|
def resolve_username
|
||||||
username = I18n.t("anonymous").downcase
|
username = I18n.t("anonymous").downcase
|
||||||
username = "anonymous" unless UserNameSuggester.sanitize_username(username).present?
|
username = "anonymous" if UserNameSuggester.sanitize_username(username).blank?
|
||||||
|
|
||||||
UserNameSuggester.suggest(username)
|
UserNameSuggester.suggest(username)
|
||||||
end
|
end
|
||||||
|
|
|
@ -244,7 +244,7 @@ class BadgeGranter
|
||||||
post_ids = list.flat_map { |i| i["post_ids"] }.compact.uniq
|
post_ids = list.flat_map { |i| i["post_ids"] }.compact.uniq
|
||||||
user_ids = list.flat_map { |i| i["user_ids"] }.compact.uniq
|
user_ids = list.flat_map { |i| i["user_ids"] }.compact.uniq
|
||||||
|
|
||||||
next unless post_ids.present? || user_ids.present?
|
next if post_ids.blank? && user_ids.blank?
|
||||||
|
|
||||||
find_by_type(type).each { |badge| backfill(badge, post_ids: post_ids, user_ids: user_ids) }
|
find_by_type(type).each { |badge| backfill(badge, post_ids: post_ids, user_ids: user_ids) }
|
||||||
end
|
end
|
||||||
|
@ -368,7 +368,7 @@ class BadgeGranter
|
||||||
end
|
end
|
||||||
if opts[:target_posts]
|
if opts[:target_posts]
|
||||||
raise "Query did not return a post ID" unless result.post_id
|
raise "Query did not return a post ID" unless result.post_id
|
||||||
unless Post.exists?(result.post_id).present?
|
if Post.exists?(result.post_id).blank?
|
||||||
raise "Query returned a non-existent post ID:\n#{result.post_id}"
|
raise "Query returned a non-existent post ID:\n#{result.post_id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -383,7 +383,7 @@ class BadgeGranter
|
||||||
def self.backfill(badge, opts = nil)
|
def self.backfill(badge, opts = nil)
|
||||||
return unless SiteSetting.enable_badges
|
return unless SiteSetting.enable_badges
|
||||||
return unless badge.enabled
|
return unless badge.enabled
|
||||||
return unless badge.query.present?
|
return if badge.query.blank?
|
||||||
|
|
||||||
post_ids = user_ids = nil
|
post_ids = user_ids = nil
|
||||||
post_ids = opts[:post_ids] if opts
|
post_ids = opts[:post_ids] if opts
|
||||||
|
|
|
@ -108,7 +108,7 @@ class NotificationEmailer
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless EMAILABLE_POST_TYPES.include?(post_type)
|
return if EMAILABLE_POST_TYPES.exclude?(post_type)
|
||||||
|
|
||||||
Jobs.enqueue_in(delay, :user_email, self.class.notification_params(notification, type))
|
Jobs.enqueue_in(delay, :user_email, self.class.notification_params(notification, type))
|
||||||
end
|
end
|
||||||
|
|
|
@ -318,7 +318,7 @@ class StaffActionLogger
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_site_text_change(subject, new_text = nil, old_text = nil, opts = {})
|
def log_site_text_change(subject, new_text = nil, old_text = nil, opts = {})
|
||||||
raise Discourse::InvalidParameters.new(:subject) unless subject.present?
|
raise Discourse::InvalidParameters.new(:subject) if subject.blank?
|
||||||
UserHistory.create!(
|
UserHistory.create!(
|
||||||
params(opts).merge(
|
params(opts).merge(
|
||||||
action: UserHistory.actions[:change_site_text],
|
action: UserHistory.actions[:change_site_text],
|
||||||
|
@ -856,9 +856,7 @@ class StaffActionLogger
|
||||||
|
|
||||||
if opts[:changes]
|
if opts[:changes]
|
||||||
old_values, new_values = get_changes(opts[:changes])
|
old_values, new_values = get_changes(opts[:changes])
|
||||||
history_params[:previous_value] = old_values&.join(", ") unless opts[:changes].keys.include?(
|
history_params[:previous_value] = old_values&.join(", ") if opts[:changes].keys.exclude?("id")
|
||||||
"id",
|
|
||||||
)
|
|
||||||
history_params[:new_value] = new_values&.join(", ")
|
history_params[:new_value] = new_values&.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Discourse::Cors
|
||||||
elsif cors_origins
|
elsif cors_origins
|
||||||
origin = nil
|
origin = nil
|
||||||
if origin = env["HTTP_ORIGIN"]
|
if origin = env["HTTP_ORIGIN"]
|
||||||
origin = nil unless cors_origins.include?(origin)
|
origin = nil if cors_origins.exclude?(origin)
|
||||||
end
|
end
|
||||||
|
|
||||||
headers["Access-Control-Allow-Origin"] = origin || cors_origins[0]
|
headers["Access-Control-Allow-Origin"] = origin || cors_origins[0]
|
||||||
|
|
|
@ -19,7 +19,7 @@ class BackfillPostUploadReverseIndex < ActiveRecord::Migration[4.2]
|
||||||
|
|
||||||
def add_to_reverse_index(url, post_id)
|
def add_to_reverse_index(url, post_id)
|
||||||
# make sure we have a url to insert
|
# make sure we have a url to insert
|
||||||
return unless url.present?
|
return if url.blank?
|
||||||
# local uploads are relative
|
# local uploads are relative
|
||||||
if index = url.index(local_base_url)
|
if index = url.index(local_base_url)
|
||||||
url = url[index..-1]
|
url = url[index..-1]
|
||||||
|
|
|
@ -73,9 +73,9 @@ class DisallowMultiLevelsThemeComponents < ActiveRecord::Migration[5.2]
|
||||||
)
|
)
|
||||||
|
|
||||||
children.each do |child|
|
children.each do |child|
|
||||||
unless @handled.include?(
|
if @handled.exclude?(
|
||||||
[top_parent.parent_theme_id, child.parent_theme_id, child.child_theme_id],
|
[top_parent.parent_theme_id, child.parent_theme_id, child.child_theme_id],
|
||||||
)
|
)
|
||||||
migrate_child(child, top_parent)
|
migrate_child(child, top_parent)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Archetype
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.list
|
def self.list
|
||||||
return [] unless @archetypes.present?
|
return [] if @archetypes.blank?
|
||||||
@archetypes.values
|
@archetypes.values
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -161,8 +161,8 @@ class Auth::ManagedAuthenticator < Auth::Authenticator
|
||||||
|
|
||||||
if bio || location
|
if bio || location
|
||||||
profile = user.user_profile
|
profile = user.user_profile
|
||||||
profile.bio_raw = bio unless profile.bio_raw.present?
|
profile.bio_raw = bio if profile.bio_raw.blank?
|
||||||
profile.location = location unless profile.location.present?
|
profile.location = location if profile.location.blank?
|
||||||
profile.save
|
profile.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -317,7 +317,7 @@ class Autospec::Manager
|
||||||
if @queue.first && @queue.first[0] == "focus"
|
if @queue.first && @queue.first[0] == "focus"
|
||||||
focus = @queue.shift
|
focus = @queue.shift
|
||||||
@queue.unshift([file, spec, runner])
|
@queue.unshift([file, spec, runner])
|
||||||
unless spec.include?(":") && focus[1].include?(spec.split(":")[0])
|
if spec.exclude?(":") || focus[1].exclude?(spec.split(":")[0])
|
||||||
@queue.unshift(focus) if focus[1].include?(spec) || file != spec
|
@queue.unshift(focus) if focus[1].include?(spec) || file != spec
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -153,7 +153,7 @@ module BackupRestore
|
||||||
RailsMultisite::ConnectionManagement.establish_connection(db: @current_db)
|
RailsMultisite::ConnectionManagement.establish_connection(db: @current_db)
|
||||||
while pg_dump_running
|
while pg_dump_running
|
||||||
message = logs.pop.strip
|
message = logs.pop.strip
|
||||||
log(message) unless message.blank?
|
log(message) if message.present?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class BookmarksBulkAction
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform!
|
def perform!
|
||||||
unless BookmarksBulkAction.operations.include?(@operation[:type])
|
if BookmarksBulkAction.operations.exclude?(@operation[:type])
|
||||||
raise Discourse::InvalidParameters.new(:operation)
|
raise Discourse::InvalidParameters.new(:operation)
|
||||||
end
|
end
|
||||||
# careful these are private methods, we need send
|
# careful these are private methods, we need send
|
||||||
|
|
|
@ -18,7 +18,7 @@ class CommonPasswords
|
||||||
@mutex = Mutex.new
|
@mutex = Mutex.new
|
||||||
|
|
||||||
def self.common_password?(password)
|
def self.common_password?(password)
|
||||||
return false unless password.present?
|
return false if password.blank?
|
||||||
password_list.include?(password)
|
password_list.include?(password)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ class ComposerMessagesFinder
|
||||||
def check_get_a_room(min_users_posted: 5)
|
def check_get_a_room(min_users_posted: 5)
|
||||||
return unless @user.guardian.can_send_private_messages?
|
return unless @user.guardian.can_send_private_messages?
|
||||||
return unless educate_reply?(:notified_about_get_a_room)
|
return unless educate_reply?(:notified_about_get_a_room)
|
||||||
return unless @details[:post_id].present?
|
return if @details[:post_id].blank?
|
||||||
return if @topic.category&.read_restricted
|
return if @topic.category&.read_restricted
|
||||||
|
|
||||||
reply_to_user_id = Post.where(id: @details[:post_id]).pluck(:user_id)[0]
|
reply_to_user_id = Post.where(id: @details[:post_id]).pluck(:user_id)[0]
|
||||||
|
|
|
@ -155,7 +155,7 @@ module CookedProcessorMixin
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_size_from_image_sizes(src, image_sizes)
|
def get_size_from_image_sizes(src, image_sizes)
|
||||||
return unless image_sizes.present?
|
return if image_sizes.blank?
|
||||||
image_sizes.each do |image_size|
|
image_sizes.each do |image_size|
|
||||||
url, size = image_size[0], image_size[1]
|
url, size = image_size[0], image_size[1]
|
||||||
if url && src && url.include?(src) && size && size["width"].to_i > 0 &&
|
if url && src && url.include?(src) && size && size["width"].to_i > 0 &&
|
||||||
|
|
|
@ -4,7 +4,7 @@ module DirectoryHelper
|
||||||
def tmp_directory(prefix)
|
def tmp_directory(prefix)
|
||||||
directory_cache[prefix] ||= begin
|
directory_cache[prefix] ||= begin
|
||||||
f = File.join(Rails.root, "tmp", Time.now.strftime("#{prefix}%Y%m%d%H%M%S"))
|
f = File.join(Rails.root, "tmp", Time.now.strftime("#{prefix}%Y%m%d%H%M%S"))
|
||||||
FileUtils.mkdir_p(f) unless Dir[f].present?
|
FileUtils.mkdir_p(f) if Dir[f].blank?
|
||||||
f
|
f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1182,7 +1182,7 @@ module Discourse
|
||||||
CDN_REQUEST_METHODS ||= %w[GET HEAD OPTIONS]
|
CDN_REQUEST_METHODS ||= %w[GET HEAD OPTIONS]
|
||||||
|
|
||||||
def self.is_cdn_request?(env, request_method)
|
def self.is_cdn_request?(env, request_method)
|
||||||
return unless CDN_REQUEST_METHODS.include?(request_method)
|
return if CDN_REQUEST_METHODS.exclude?(request_method)
|
||||||
|
|
||||||
cdn_hostnames = GlobalSetting.cdn_hostnames
|
cdn_hostnames = GlobalSetting.cdn_hostnames
|
||||||
return if cdn_hostnames.blank?
|
return if cdn_hostnames.blank?
|
||||||
|
|
|
@ -159,7 +159,7 @@ module DiscourseTagging
|
||||||
parent_tag = tags.select { |t| t.id == parent_tag_ids.first }.first
|
parent_tag = tags.select { |t| t.id == parent_tag_ids.first }.first
|
||||||
original_child_tag = tags.select { |t| t.id == tag_id }.first
|
original_child_tag = tags.select { |t| t.id == tag_id }.first
|
||||||
|
|
||||||
next unless parent_tag.present? && original_child_tag.present?
|
next if parent_tag.blank? || original_child_tag.blank?
|
||||||
parent_child_names_map[parent_tag.name] = original_child_tag.name
|
parent_child_names_map[parent_tag.name] = original_child_tag.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,7 @@ module Email
|
||||||
|
|
||||||
def reply_by_email_address
|
def reply_by_email_address
|
||||||
return @reply_by_email_address if @reply_by_email_address
|
return @reply_by_email_address if @reply_by_email_address
|
||||||
return nil unless SiteSetting.reply_by_email_address.present?
|
return nil if SiteSetting.reply_by_email_address.blank?
|
||||||
|
|
||||||
@reply_by_email_address = SiteSetting.reply_by_email_address.dup
|
@reply_by_email_address = SiteSetting.reply_by_email_address.dup
|
||||||
|
|
||||||
|
|
|
@ -445,7 +445,7 @@ module Email
|
||||||
text_content_type = @mail.content_type
|
text_content_type = @mail.content_type
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless text.present? || html.present?
|
return if text.blank? && html.blank?
|
||||||
|
|
||||||
if text.present?
|
if text.present?
|
||||||
text = trim_discourse_markers(text)
|
text = trim_discourse_markers(text)
|
||||||
|
|
|
@ -423,7 +423,7 @@ module Email
|
||||||
.css("a")
|
.css("a")
|
||||||
.each do |link|
|
.each do |link|
|
||||||
begin
|
begin
|
||||||
link["href"] = "#{site_uri}#{link["href"]}" unless URI(link["href"].to_s).host.present?
|
link["href"] = "#{site_uri}#{link["href"]}" if URI(link["href"].to_s).host.blank?
|
||||||
rescue URI::Error
|
rescue URI::Error
|
||||||
# leave it
|
# leave it
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ module EmailControllerHelper
|
||||||
take_next: false,
|
take_next: false,
|
||||||
) do |memo, v|
|
) do |memo, v|
|
||||||
memo[:current] = v[:name] if v[:value] == frequency_in_minutes && email_digests
|
memo[:current] = v[:name] if v[:value] == frequency_in_minutes && email_digests
|
||||||
next(memo) unless allowed_frequencies.include?(v[:name])
|
next(memo) if allowed_frequencies.exclude?(v[:name])
|
||||||
|
|
||||||
memo.tap do |m|
|
memo.tap do |m|
|
||||||
m[:selected] = v[:value] if m[:take_next] && email_digests
|
m[:selected] = v[:value] if m[:take_next] && email_digests
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Encodings
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.delete_bom!(string)
|
def self.delete_bom!(string)
|
||||||
string.sub!(/\A\xEF\xBB\xBF/, "") unless string.blank?
|
string.sub!(/\A\xEF\xBB\xBF/, "") if string.present?
|
||||||
string
|
string
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -407,7 +407,7 @@ class FinalDestination
|
||||||
|
|
||||||
def validate_uri_format
|
def validate_uri_format
|
||||||
return false unless @uri && @uri.host
|
return false unless @uri && @uri.host
|
||||||
return false unless %w[https http].include?(@uri.scheme)
|
return false if %w[https http].exclude?(@uri.scheme)
|
||||||
|
|
||||||
# In some cases (like local/test environments) we may want to allow http URLs
|
# In some cases (like local/test environments) we may want to allow http URLs
|
||||||
# to be used for internal hosts, but only if it's the case that the host is
|
# to be used for internal hosts, but only if it's the case that the host is
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class FinalDestination::HTTP < Net::HTTP
|
class FinalDestination::HTTP < Net::HTTP
|
||||||
def connect
|
def connect
|
||||||
raise ArgumentError.new("address cannot be nil or empty") unless @address.present?
|
raise ArgumentError.new("address cannot be nil or empty") if @address.blank?
|
||||||
|
|
||||||
original_open_timeout = @open_timeout
|
original_open_timeout = @open_timeout
|
||||||
return super if @ipaddr
|
return super if @ipaddr
|
||||||
|
|
|
@ -73,7 +73,7 @@ module I18n
|
||||||
execute_reload if @requires_reload
|
execute_reload if @requires_reload
|
||||||
|
|
||||||
locale = (opts[:locale] || config.locale).to_sym
|
locale = (opts[:locale] || config.locale).to_sym
|
||||||
load_locale(locale) unless @loaded_locales.include?(locale)
|
load_locale(locale) if @loaded_locales.exclude?(locale)
|
||||||
|
|
||||||
results = {}
|
results = {}
|
||||||
regexp = I18n::Backend::DiscourseI18n.create_search_regexp(query)
|
regexp = I18n::Backend::DiscourseI18n.create_search_regexp(query)
|
||||||
|
@ -99,7 +99,7 @@ module I18n
|
||||||
def ensure_loaded!(locale)
|
def ensure_loaded!(locale)
|
||||||
locale = locale.to_sym
|
locale = locale.to_sym
|
||||||
@loaded_locales ||= []
|
@loaded_locales ||= []
|
||||||
load_locale(locale) unless @loaded_locales.include?(locale)
|
load_locale(locale) if @loaded_locales.exclude?(locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
# In some environments such as migrations we don't want to use overrides.
|
# In some environments such as migrations we don't want to use overrides.
|
||||||
|
@ -198,7 +198,7 @@ module I18n
|
||||||
key = args.shift
|
key = args.shift
|
||||||
locale = (options[:locale] || config.locale).to_sym
|
locale = (options[:locale] || config.locale).to_sym
|
||||||
|
|
||||||
load_locale(locale) unless @loaded_locales.include?(locale)
|
load_locale(locale) if @loaded_locales.exclude?(locale)
|
||||||
|
|
||||||
if @overrides_enabled
|
if @overrides_enabled
|
||||||
overrides = {}
|
overrides = {}
|
||||||
|
@ -234,7 +234,7 @@ module I18n
|
||||||
|
|
||||||
locale ||= config.locale
|
locale ||= config.locale
|
||||||
locale = locale.to_sym
|
locale = locale.to_sym
|
||||||
load_locale(locale) unless @loaded_locales.include?(locale)
|
load_locale(locale) if @loaded_locales.exclude?(locale)
|
||||||
exists_no_cache?(key, locale)
|
exists_no_cache?(key, locale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ module HasErrors
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_error(msg)
|
def add_error(msg)
|
||||||
errors.add(:base, msg) unless errors[:base].include?(msg)
|
errors.add(:base, msg) if errors[:base].exclude?(msg)
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_errors_from(obj)
|
def add_errors_from(obj)
|
||||||
|
|
|
@ -125,7 +125,7 @@ module ImportExport
|
||||||
|
|
||||||
@export_data[:categories].each do |c|
|
@export_data[:categories].each do |c|
|
||||||
c[:permissions_params].each do |group_name, _|
|
c[:permissions_params].each do |group_name, _|
|
||||||
group_names << group_name unless auto_group_names.include?(group_name.to_s)
|
group_names << group_name if auto_group_names.exclude?(group_name.to_s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ class NewPostManager
|
||||||
|
|
||||||
pattern = SiteSetting.auto_silence_first_post_regex
|
pattern = SiteSetting.auto_silence_first_post_regex
|
||||||
|
|
||||||
return false unless pattern.present?
|
return false if pattern.blank?
|
||||||
return false unless is_first_post?(manager)
|
return false unless is_first_post?(manager)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -29,7 +29,7 @@ class NewPostResult
|
||||||
if arr.empty?
|
if arr.empty?
|
||||||
@success = true
|
@success = true
|
||||||
else
|
else
|
||||||
arr.each { |e| errors.add(:base, e) unless errors[:base].include?(e) }
|
arr.each { |e| errors.add(:base, e) if errors[:base].exclude?(e) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ module Onebox
|
||||||
)
|
)
|
||||||
|
|
||||||
response = http.head(uri.path)
|
response = http.head(uri.path)
|
||||||
unless %w[200 301 302].include?(response.code)
|
if %w[200 301 302].exclude?(response.code)
|
||||||
raise "unexpected response code #{response.code}"
|
raise "unexpected response code #{response.code}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Onebox
|
||||||
end
|
end
|
||||||
|
|
||||||
def data
|
def data
|
||||||
return nil unless %w[story comment].include?(raw["type"])
|
return nil if %w[story comment].exclude?(raw["type"])
|
||||||
|
|
||||||
html_entities = HTMLEntities.new
|
html_entities = HTMLEntities.new
|
||||||
data = {
|
data = {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user