Skip to content

Commit

Permalink
Merge remote-tracking branch 'parent/main' into kb_development
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Oct 4, 2023
2 parents c9d14c6 + c676bc9 commit e824446
Show file tree
Hide file tree
Showing 24 changed files with 100 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .haml-lint_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `haml-lint --auto-gen-config`
# on 2023-09-28 10:42:25 -0400 using Haml-Lint version 0.50.0.
# on 2023-10-03 08:32:28 -0400 using Haml-Lint version 0.51.0.
# The point is for the user to remove these configuration records
# one by one as the lints are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -15,7 +15,7 @@ linters:
UnnecessaryStringOutput:
enabled: false

# Offense count: 59
# Offense count: 44
RuboCop:
enabled: false

Expand Down
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ AllCops:
- 'Vagrantfile'
- 'vendor/**/*'
- 'lib/json_ld/*' # Generated files
- 'lib/mastodon/migration_helpers.rb' # Vendored from GitLab
- 'lib/templates/**/*'

# Reason: Prefer Hashes without extreme indentation
Expand Down
30 changes: 0 additions & 30 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,13 @@ Bundler/OrderedGems:
Exclude:
- 'Gemfile'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'config/environments/production.rb'
- 'config/initializers/rack_attack.rb'
- 'config/routes.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Exclude:
- 'config/application.rb'
- 'config/initializers/3_omniauth.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Exclude:
- 'app/models/account.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_no_space, require_space
Layout/SpaceInLambdaLiteral:
Exclude:
- 'config/environments/production.rb'
- 'config/initializers/content_security_policy.rb'

# Configuration parameters: AllowComments, AllowEmptyLambdas.
Lint/EmptyBlock:
Exclude:
Expand Down Expand Up @@ -281,10 +255,6 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups:
Max: 6

RSpec/PendingWithoutReason:
Exclude:
- 'spec/models/account_spec.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Rails/ApplicationController:
Exclude:
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/admin/announcements_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

module Admin::AnnouncementsHelper
def datetime_pattern
'[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}'
end

def datetime_placeholder
Time.zone.now.strftime('%FT%R')
end
end
29 changes: 25 additions & 4 deletions app/lib/admin/system_check/elasticsearch_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,35 @@ def required_version
end

def compatible_version?
return false if running_version.nil?

Gem::Version.new(running_version) >= Gem::Version.new(required_version) ||
Gem::Version.new(compatible_wire_version) >= Gem::Version.new(required_version)
running_version_ok? || compatible_wire_version_ok?
rescue ArgumentError
false
end

def running_version_ok?
return false if running_version.blank?

gem_version_running >= gem_version_required
end

def compatible_wire_version_ok?
return false if compatible_wire_version.blank?

gem_version_compatible_wire >= gem_version_required
end

def gem_version_running
Gem::Version.new(running_version)
end

def gem_version_required
Gem::Version.new(required_version)
end

def gem_version_compatible_wire
Gem::Version.new(compatible_wire_version)
end

def mismatched_indexes
@mismatched_indexes ||= INDEXES.filter_map do |klass|
klass.base_name if Chewy.client.indices.get_mapping[klass.index_name]&.deep_symbolize_keys != klass.mappings_hash
Expand Down
2 changes: 1 addition & 1 deletion app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Account < ApplicationRecord
BACKGROUND_REFRESH_INTERVAL = 1.week.freeze

USERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
MENTION_RE = %r{(?<=^|[^/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
USERNAME_ONLY_RE = /\A#{USERNAME_RE}\z/i

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/accounts/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
.dashboard__counters__label= t 'admin.accounts.login_status'

- if @account.local? && @account.user.nil?
= link_to t('admin.accounts.unblock_email'), unblock_email_admin_account_path(@account.id), method: :post, class: 'button' if can?(:unblock_email, @account) && CanonicalEmailBlock.where(reference_account_id: @account.id).exists?
= link_to t('admin.accounts.unblock_email'), unblock_email_admin_account_path(@account.id), method: :post, class: 'button' if can?(:unblock_email, @account) && CanonicalEmailBlock.exists?(reference_account_id: @account.id)
- else
.table-wrapper
%table.table.inline-table
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/announcements/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
= render 'shared/error_messages', object: @announcement

.fields-group
= f.input :starts_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :ends_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :starts_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }
= f.input :ends_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }

.fields-group
= f.input :all_day, as: :boolean, wrapper: :with_label
Expand All @@ -16,7 +16,7 @@

- unless @announcement.published?
.fields-group
= f.input :scheduled_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :scheduled_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }

.actions
= f.button :button, t('generic.save_changes'), type: :submit
6 changes: 3 additions & 3 deletions app/views/admin/announcements/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
= render 'shared/error_messages', object: @announcement

.fields-group
= f.input :starts_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :ends_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :starts_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }
= f.input :ends_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }

.fields-group
= f.input :all_day, as: :boolean, wrapper: :with_label
Expand All @@ -15,7 +15,7 @@
= f.input :text, wrapper: :with_block_label

.fields-group
= f.input :scheduled_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}(:[0-9]{2}){1,2}', placeholder: Time.now.strftime('%FT%R') }
= f.input :scheduled_at, include_blank: true, wrapper: :with_block_label, html5: true, input_html: { pattern: datetime_pattern, placeholder: datetime_placeholder }

.actions
= f.button :button, t('.create'), type: :submit
2 changes: 1 addition & 1 deletion app/views/admin/reports/actions/preview.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
= fa_icon 'link'
= media_attachment.file_file_name
.strike-card__statuses-list__item__meta
= link_to ActivityPub::TagManager.instance.url_for(status), target: '_blank' do
= link_to ActivityPub::TagManager.instance.url_for(status), target: '_blank', rel: 'noopener noreferrer' do
%time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at)
- unless status.application.nil?
·
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/statuses/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= t('statuses.title', name: display_name(@account), quote: truncate(@status.spoiler_text.presence || @status.text, length: 50, omission: '…', escape: false))

- content_for :heading_actions do
= link_to t('admin.statuses.open'), ActivityPub::TagManager.instance.url_for(@status), class: 'button', target: '_blank'
= link_to t('admin.statuses.open'), ActivityPub::TagManager.instance.url_for(@status), class: 'button', target: '_blank', rel: 'noopener noreferrer'

%h3= t('admin.statuses.metadata')

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tags/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.dashboard
.dashboard__item
= react_admin_component :counter, measure: 'tag_accounts', start_at: @time_period.first, end_at: @time_period.last, params: { id: @tag.id }, label: t('admin.trends.tags.dashboard.tag_accounts_measure'), href: tag_url(@tag), target: '_blank'
= react_admin_component :counter, measure: 'tag_accounts', start_at: @time_period.first, end_at: @time_period.last, params: { id: @tag.id }, label: t('admin.trends.tags.dashboard.tag_accounts_measure'), href: tag_url(@tag), target: '_blank', rel: 'noopener noreferrer'
.dashboard__item
= react_admin_component :counter, measure: 'tag_uses', start_at: @time_period.first, end_at: @time_period.last, params: { id: @tag.id }, label: t('admin.trends.tags.dashboard.tag_uses_measure')
.dashboard__item
Expand Down
2 changes: 1 addition & 1 deletion app/views/auth/registrations/new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
= f.input :confirm_password, as: :string, placeholder: t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), required: false, input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: t('simple_form.labels.defaults.password')), autocomplete: 'off' }, hint: false
= f.input :website, as: :url, wrapper: :with_label, label: t('simple_form.labels.defaults.honeypot', label: 'Website'), required: false, input_html: { 'aria-label': t('simple_form.labels.defaults.honeypot', label: 'Website'), autocomplete: 'off' }

- if approved_registrations? && !@invite.present?
- if approved_registrations? && @invite.blank?
%p.lead= t('auth.sign_up.manual_review', domain: site_hostname)

.fields-group
Expand Down
4 changes: 2 additions & 2 deletions app/views/disputes/strikes/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- unless @strike.none_action?
%p= t "user_mailer.warning.explanation.#{@strike.action}", instance: Rails.configuration.x.local_domain

- unless @strike.text.blank?
- if @strike.text.present?
= linkify(@strike.text)

- if @strike.report && [email protected]?
Expand Down Expand Up @@ -57,7 +57,7 @@
= fa_icon 'link'
= media_attachment.file_file_name
.strike-card__statuses-list__item__meta
= link_to ActivityPub::TagManager.instance.url_for(status), target: '_blank' do
= link_to ActivityPub::TagManager.instance.url_for(status), target: '_blank', rel: 'noopener noreferrer' do
%time.formatted{ datetime: status.created_at.iso8601, title: l(status.created_at) }= l(status.created_at)
- unless status.application.nil?
·
Expand Down
2 changes: 1 addition & 1 deletion app/views/statuses/_detailed_status.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@

- if user_signed_in?
·
= link_to t('statuses.open_in_web'), web_url("@#{status.account.pretty_acct}/#{status.id}"), class: 'detailed-status__application', target: '_blank'
= link_to t('statuses.open_in_web'), web_url("@#{status.account.pretty_acct}/#{status.id}"), class: 'detailed-status__application', target: '_blank', rel: 'noopener noreferrer'
4 changes: 2 additions & 2 deletions app/views/user_mailer/warning.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
- unless @warning.none_action?
%p= t "user_mailer.warning.explanation.#{@warning.action}", instance: @instance

- unless @warning.text.blank?
- if @warning.text.present?
= linkify(@warning.text)

- if @warning.report && [email protected]?
Expand Down Expand Up @@ -68,7 +68,7 @@
%table.content-section{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
%td.content-cell{ class: @statuses.nil? || @statuses.empty? ? '' : 'content-start' }
%td.content-cell{ class: @statuses.blank? ? '' : 'content-start' }
%table.column{ cellspacing: 0, cellpadding: 0 }
%tbody
%tr
Expand Down
10 changes: 5 additions & 5 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
require 'rails'

require 'active_record/railtie'
#require 'active_storage/engine'
# require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'action_mailer/railtie'
require 'active_job/railtie'
#require 'action_cable/engine'
#require 'action_mailbox/engine'
#require 'action_text/engine'
#require 'rails/test_unit/railtie'
# require 'action_cable/engine'
# require 'action_mailbox/engine'
# require 'action_text/engine'
# require 'rails/test_unit/railtie'
require 'sprockets/railtie'

# Used to be implicitly required in action_mailbox/engine
Expand Down
10 changes: 5 additions & 5 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
config.force_ssl = true
config.ssl_options = {
redirect: {
exclude: -> request { request.path.start_with?('/health') || request.headers["Host"].end_with?('.onion') || request.headers["Host"].end_with?('.i2p') }
exclude: ->request { request.path.start_with?('/health') || request.headers["Host"].end_with?('.onion') || request.headers["Host"].end_with?('.i2p') }
}
}

Expand Down Expand Up @@ -148,11 +148,11 @@
config.action_mailer.delivery_method = ENV.fetch('SMTP_DELIVERY_METHOD', 'smtp').to_sym

config.action_dispatch.default_headers = {
'Server' => 'Mastodon',
'X-Frame-Options' => 'DENY',
'Server' => 'Mastodon',
'X-Frame-Options' => 'DENY',
'X-Content-Type-Options' => 'nosniff',
'X-XSS-Protection' => '0',
'Referrer-Policy' => 'same-origin',
'X-XSS-Protection' => '0',
'Referrer-Policy' => 'same-origin',
}

config.x.otp_secret = ENV.fetch('OTP_SECRET')
Expand Down
Loading

0 comments on commit e824446

Please sign in to comment.