Autofix Rubocop remaining Layout rules (#23679)

pull/53/head
Nick Schonning 2023-02-20 00:58:28 -05:00 committed by GitHub
parent d2dcb6c45a
commit 717683d1c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
117 changed files with 265 additions and 261 deletions

View File

@ -14,154 +14,6 @@ Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 81
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'app/controllers/api/v1/tags_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/concerns/session_tracking_concern.rb'
- 'app/controllers/concerns/signature_verification.rb'
- 'app/helpers/application_helper.rb'
- 'app/lib/activitypub/activity.rb'
- 'app/lib/activitypub/tag_manager.rb'
- 'app/lib/request.rb'
- 'app/lib/settings/scoped_settings.rb'
- 'app/lib/status_filter.rb'
- 'app/lib/tag_manager.rb'
- 'app/lib/webfinger.rb'
- 'app/models/account.rb'
- 'app/models/account_conversation.rb'
- 'app/models/admin/import.rb'
- 'app/models/custom_filter.rb'
- 'app/models/favourite.rb'
- 'app/models/form/admin_settings.rb'
- 'app/models/poll.rb'
- 'app/models/session_activation.rb'
- 'app/models/setting.rb'
- 'app/models/status_edit.rb'
- 'app/models/user.rb'
- 'app/models/user_role.rb'
- 'app/services/activitypub/fetch_remote_actor_service.rb'
- 'app/services/activitypub/fetch_remote_status_service.rb'
- 'app/services/activitypub/fetch_replies_service.rb'
- 'app/services/activitypub/process_account_service.rb'
- 'app/services/favourite_service.rb'
- 'app/services/notify_service.rb'
- 'app/services/post_status_service.rb'
- 'app/services/vote_service.rb'
- 'app/validators/follow_limit_validator.rb'
- 'app/validators/unreserved_username_validator.rb'
- 'app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb'
- 'db/migrate/20190314181829_migrate_open_registrations_setting.rb'
- 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb'
- 'db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb'
- 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb'
- 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb'
- 'lib/mastodon/domains_cli.rb'
# Offense count: 71
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'Capfile'
- 'app/helpers/languages_helper.rb'
- 'app/models/account.rb'
- 'app/models/account_conversation.rb'
- 'app/models/account_domain_block.rb'
- 'app/models/account_moderation_note.rb'
- 'app/models/account_note.rb'
- 'app/models/account_pin.rb'
- 'app/models/account_stat.rb'
- 'app/models/account_summary.rb'
- 'app/models/account_warning.rb'
- 'app/models/backup.rb'
- 'app/models/block.rb'
- 'app/models/bookmark.rb'
- 'app/models/canonical_email_block.rb'
- 'app/models/conversation.rb'
- 'app/models/conversation_mute.rb'
- 'app/models/custom_emoji.rb'
- 'app/models/custom_filter.rb'
- 'app/models/custom_filter_keyword.rb'
- 'app/models/custom_filter_status.rb'
- 'app/models/device.rb'
- 'app/models/domain_block.rb'
- 'app/models/email_domain_block.rb'
- 'app/models/encrypted_message.rb'
- 'app/models/favourite.rb'
- 'app/models/featured_tag.rb'
- 'app/models/follow.rb'
- 'app/models/follow_recommendation.rb'
- 'app/models/follow_recommendation_suppression.rb'
- 'app/models/follow_request.rb'
- 'app/models/identity.rb'
- 'app/models/import.rb'
- 'app/models/instance.rb'
- 'app/models/invite.rb'
- 'app/models/ip_block.rb'
- 'app/models/list.rb'
- 'app/models/list_account.rb'
- 'app/models/login_activity.rb'
- 'app/models/media_attachment.rb'
- 'app/models/mention.rb'
- 'app/models/mute.rb'
- 'app/models/notification.rb'
- 'app/models/one_time_key.rb'
- 'app/models/poll.rb'
- 'app/models/poll_vote.rb'
- 'app/models/preview_card.rb'
- 'app/models/preview_card_provider.rb'
- 'app/models/relay.rb'
- 'app/models/report.rb'
- 'app/models/report_note.rb'
- 'app/models/session_activation.rb'
- 'app/models/setting.rb'
- 'app/models/site_upload.rb'
- 'app/models/status.rb'
- 'app/models/status_edit.rb'
- 'app/models/status_pin.rb'
- 'app/models/status_stat.rb'
- 'app/models/tag.rb'
- 'app/models/unavailable_domain.rb'
- 'app/models/user.rb'
- 'app/models/user_ip.rb'
- 'app/models/web/push_subscription.rb'
- 'app/models/web/setting.rb'
- 'app/models/webauthn_credential.rb'
- 'config.ru'
- 'db/migrate/20220613110834_add_action_to_custom_filters.rb'
- 'db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb'
- 'db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb'
- 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb'
- 'spec/models/tag_spec.rb'
# Offense count: 113
# 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:
- 'app/lib/activitypub/linked_data_signature.rb'
- 'app/lib/ostatus/tag_manager.rb'
- 'app/models/account/field.rb'
- 'app/models/account_warning.rb'
- 'app/models/media_attachment.rb'
- 'app/models/notification.rb'
- 'app/models/poll.rb'
- 'app/presenters/account_relationships_presenter.rb'
- 'app/services/keys/claim_service.rb'
- 'app/services/keys/query_service.rb'
- 'app/workers/web/push_notification_worker.rb'
- 'db/post_migrate/20200917193528_migrate_notifications_type.rb'
- 'lib/sanitize_ext/sanitize_config.rb'
- 'lib/tasks/auto_annotate_models.rake'
- 'lib/tasks/mastodon.rake'
- 'spec/models/admin/account_action_spec.rb'
- 'spec/models/concerns/account_interactions_spec.rb'
# Offense count: 581
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/scm/git'

View File

@ -25,6 +25,7 @@ class Api::V1::TagsController < Api::BaseController
def set_or_create_tag
return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id])
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
end
end

View File

@ -128,6 +128,7 @@ class ApplicationController < ActionController::Base
def current_theme
return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme
current_user.setting_theme
end

View File

@ -13,6 +13,7 @@ module SessionTrackingConcern
def set_session_activity
return unless session_needs_update?
current_session.touch
end

View File

@ -165,6 +165,7 @@ module SignatureVerification
end
raise SignatureVerificationError, "Invalid Digest value. The provided Digest value is not a SHA-256 digest. Given digest: #{sha256[1]}" if digest_size != 32
raise SignatureVerificationError, "Invalid Digest value. Computed SHA-256 digest: #{body_digest}; given: #{sha256[1]}"
end

View File

@ -105,6 +105,7 @@ module ApplicationHelper
def can?(action, record)
return false if record.nil?
policy(record).public_send("#{action}?")
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# rubocop:disable Metrics/ModuleLength, Style/WordArray
module LanguagesHelper

View File

@ -153,6 +153,7 @@ class ActivityPub::Activity
def fetch_remote_original_status
if object_uri.start_with?('http')
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first, request_id: @options[:request_id])
elsif @object['url'].present?
::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id])

View File

@ -32,7 +32,7 @@ class ActivityPub::LinkedDataSignature
def sign!(creator, sign_with: nil)
options = {
'type' => 'RsaSignature2017',
'type' => 'RsaSignature2017',
'creator' => ActivityPub::TagManager.instance.key_uri_for(creator),
'created' => Time.now.utc.iso8601,
}

View File

@ -26,6 +26,7 @@ class ActivityPub::TagManager
target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target)
when :note, :comment, :activity
return activity_account_status_url(target.account, target) if target.reblog?
short_account_status_url(target.account, target)
end
end
@ -38,6 +39,7 @@ class ActivityPub::TagManager
target.instance_actor? ? instance_actor_url : account_url(target)
when :note, :comment, :activity
return activity_account_status_url(target.account, target) if target.reblog?
account_status_url(target.account, target)
when :emoji
emoji_url(target)

View File

@ -5,27 +5,27 @@ class OStatus::TagManager
include RoutingHelper
VERBS = {
post: 'http://activitystrea.ms/schema/1.0/post',
share: 'http://activitystrea.ms/schema/1.0/share',
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
delete: 'http://activitystrea.ms/schema/1.0/delete',
follow: 'http://activitystrea.ms/schema/1.0/follow',
post: 'http://activitystrea.ms/schema/1.0/post',
share: 'http://activitystrea.ms/schema/1.0/share',
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
delete: 'http://activitystrea.ms/schema/1.0/delete',
follow: 'http://activitystrea.ms/schema/1.0/follow',
request_friend: 'http://activitystrea.ms/schema/1.0/request-friend',
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
reject: 'http://activitystrea.ms/schema/1.0/reject',
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
block: 'http://mastodon.social/schema/1.0/block',
unblock: 'http://mastodon.social/schema/1.0/unblock',
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
reject: 'http://activitystrea.ms/schema/1.0/reject',
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
block: 'http://mastodon.social/schema/1.0/block',
unblock: 'http://mastodon.social/schema/1.0/unblock',
}.freeze
TYPES = {
activity: 'http://activitystrea.ms/schema/1.0/activity',
note: 'http://activitystrea.ms/schema/1.0/note',
comment: 'http://activitystrea.ms/schema/1.0/comment',
person: 'http://activitystrea.ms/schema/1.0/person',
activity: 'http://activitystrea.ms/schema/1.0/activity',
note: 'http://activitystrea.ms/schema/1.0/note',
comment: 'http://activitystrea.ms/schema/1.0/comment',
person: 'http://activitystrea.ms/schema/1.0/person',
collection: 'http://activitystrea.ms/schema/1.0/collection',
group: 'http://activitystrea.ms/schema/1.0/group',
group: 'http://activitystrea.ms/schema/1.0/group',
}.freeze
COLLECTIONS = {

View File

@ -182,6 +182,7 @@ class Request
contents = truncated_body(limit)
raise Mastodon::LengthValidationError if contents.bytesize > limit
contents
end
end

View File

@ -34,6 +34,7 @@ module Settings
Setting.default_settings.each do |key, default_value|
next if records.key?(key) || default_value.is_a?(Hash)
records[key] = Setting.new(var: key, value: default_value)
end
@ -54,6 +55,7 @@ module Settings
if db_val
default_value = ScopedSettings.default_settings[key]
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
db_val.value
else
ScopedSettings.default_settings[key]

View File

@ -11,6 +11,7 @@ class StatusFilter
def filtered?
return false if !account.nil? && account.id == status.account_id
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
end

View File

@ -25,6 +25,7 @@ class TagManager
def local_url?(url)
uri = Addressable::URI.parse(url).normalize
return false unless uri.host
domain = uri.host + (uri.port ? ":#{uri.port}" : '')
TagManager.instance.web_domain?(domain)

View File

@ -57,6 +57,7 @@ class Webfinger
if res.code == 200
body = res.body_with_limit
raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty?
body
elsif res.code == 404 && use_fallback
body_from_host_meta

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: accounts
@ -539,6 +540,7 @@ class Account < ApplicationRecord
def ensure_keys!
return unless local? && private_key.blank? && public_key.blank?
generate_keys
save!
end

View File

@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model
@account = account
super(
name: sanitize(attributes['name']),
value: sanitize(attributes['value']),
name: sanitize(attributes['name']),
value: sanitize(attributes['value']),
verified_at: attributes['verified_at']&.to_datetime,
)
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_conversations
@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord
def push_to_streaming_api
return if destroyed? || !subscribed_to_timeline?
PushConversationWorker.perform_async(id)
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_domain_blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_moderation_notes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_notes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_pins

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_stats

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_summaries

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: account_warnings
@ -17,13 +18,13 @@
class AccountWarning < ApplicationRecord
enum action: {
none: 0,
disable: 1_000,
none: 0,
disable: 1_000,
mark_statuses_as_sensitive: 1_250,
delete_statuses: 1_500,
sensitive: 2_000,
silence: 3_000,
suspend: 4_000,
delete_statuses: 1_500,
sensitive: 2_000,
silence: 3_000,
suspend: 4_000,
}, _suffix: :action
before_validation :before_validate

View File

@ -56,6 +56,7 @@ class Admin::Import
def validate_data
return if data.nil?
errors.add(:data, I18n.t('imports.errors.over_rows_processing_limit', count: ROWS_PROCESSING_LIMIT)) if csv_row_count > ROWS_PROCESSING_LIMIT
rescue CSV::MalformedCSVError => e
errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: backups

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: bookmarks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: canonical_email_blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: conversations

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: conversation_mutes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_emojis

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filters
@ -101,6 +102,7 @@ class CustomFilter < ApplicationRecord
status_matches = [status.id, status.reblog_of_id].compact & rules[:status_ids] if rules[:status_ids].present?
next if keyword_matches.blank? && status_matches.blank?
FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches)
end
end
@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord
def invalidate_cache!
return unless @should_invalidate_cache
@should_invalidate_cache = false
Rails.cache.delete("filters:v3:#{account_id}")

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filter_keywords

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: custom_filter_statuses

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: devices

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: domain_blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: email_domain_blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: encrypted_messages

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: favourites
@ -38,6 +39,7 @@ class Favourite < ApplicationRecord
def decrement_cache_counters
return if association(:status).loaded? && status.marked_for_destruction?
status&.decrement_count!(:favourites_count)
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: featured_tags

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follows

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_recommendations

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_recommendation_suppressions

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: follow_requests

View File

@ -128,6 +128,7 @@ class Form::AdminSettings
def validate_site_uploads
UPLOAD_KEYS.each do |key|
next unless instance_variable_defined?("@#{key}")
upload = instance_variable_get("@#{key}")
next if upload.valid?

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: identities

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: imports

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: instances

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: invites

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: ip_blocks

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: lists

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: list_accounts

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: login_activities

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: media_attachments
@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord
return {} if width.nil?
{
width: width,
width: width,
height: height,
size: "#{width}x#{height}",
aspect: width.to_f / height,

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mentions

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mutes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: notifications
@ -19,12 +20,12 @@ class Notification < ApplicationRecord
include Paginable
LEGACY_TYPE_CLASS_MAP = {
'Mention' => :mention,
'Status' => :reblog,
'Follow' => :follow,
'Mention' => :mention,
'Status' => :reblog,
'Follow' => :follow,
'FollowRequest' => :follow_request,
'Favourite' => :favourite,
'Poll' => :poll,
'Favourite' => :favourite,
'Poll' => :poll,
}.freeze
TYPES = %i(

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: one_time_keys

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: polls
@ -74,9 +75,9 @@ class Poll < ApplicationRecord
def initialize(poll, id, title, votes_count)
super(
poll: poll,
id: id,
title: title,
poll: poll,
id: id,
title: title,
votes_count: votes_count,
)
end
@ -105,6 +106,7 @@ class Poll < ApplicationRecord
def reset_parent_cache
return if status_id.nil?
Rails.cache.delete("statuses/#{status_id}")
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: poll_votes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: preview_cards

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: preview_card_providers

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: relays

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: reports

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: report_notes

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: session_activations
@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord
def deactivate(id)
return unless id
where(session_id: id).destroy_all
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: settings
@ -30,6 +31,7 @@ class Setting < RailsSettings::Base
default_value = default_settings[key]
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
db_val.value
else
default_settings[key]
@ -43,6 +45,7 @@ class Setting < RailsSettings::Base
default_settings.each do |key, default_value|
next if records.key?(key) || default_value.is_a?(Hash)
records[key] = Setting.new(var: key, value: default_value)
end
@ -51,6 +54,7 @@ class Setting < RailsSettings::Base
def default_settings
return {} unless RailsSettings::Default.enabled?
RailsSettings::Default.instance
end
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: site_uploads

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: statuses

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_edits
@ -45,6 +46,7 @@ class StatusEdit < ApplicationRecord
def emojis
return @emojis if defined?(@emojis)
@emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_pins

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: status_stats

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: tags

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: unavailable_domains

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: users
@ -492,12 +493,14 @@ class User < ApplicationRecord
def sanitize_languages
return if chosen_languages.nil?
chosen_languages.reject!(&:blank?)
self.chosen_languages = nil if chosen_languages.empty?
end
def sanitize_role
return if role.nil?
self.role = nil if role.everyone?
end
@ -516,6 +519,7 @@ class User < ApplicationRecord
def notify_staff_about_pending_account!
User.those_who_can(:manage_users).includes(:account).find_each do |u|
next unless u.allows_pending_account_emails?
AdminMailer.new_pending_account(u.account, self).deliver_later
end
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: user_ips

View File

@ -163,6 +163,7 @@ class UserRole < ApplicationRecord
def in_permissions?(privilege)
raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege)
computed_permissions & FLAGS[privilege] == FLAGS[privilege]
end
@ -172,6 +173,7 @@ class UserRole < ApplicationRecord
def validate_own_role_edition
return unless defined?(@current_account) && @current_account.user_role.id == id
errors.add(:permissions_as_keys, :own_role) if permissions_changed?
errors.add(:position, :own_role) if position_changed?
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: web_push_subscriptions

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: web_settings

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: webauthn_credentials

View File

@ -70,16 +70,16 @@ class AccountRelationshipsPresenter
def cache_uncached!
@uncached_account_ids.each do |account_id|
maps_for_account = {
following: { account_id => following[account_id] },
followed_by: { account_id => followed_by[account_id] },
blocking: { account_id => blocking[account_id] },
blocked_by: { account_id => blocked_by[account_id] },
muting: { account_id => muting[account_id] },
requested: { account_id => requested[account_id] },
requested_by: { account_id => requested_by[account_id] },
following: { account_id => following[account_id] },
followed_by: { account_id => followed_by[account_id] },
blocking: { account_id => blocking[account_id] },
blocked_by: { account_id => blocked_by[account_id] },
muting: { account_id => muting[account_id] },
requested: { account_id => requested[account_id] },
requested_by: { account_id => requested_by[account_id] },
domain_blocking: { account_id => domain_blocking[account_id] },
endorsed: { account_id => endorsed[account_id] },
account_note: { account_id => account_note[account_id] },
endorsed: { account_id => endorsed[account_id] },
account_note: { account_id => account_note[account_id] },
}
Rails