Autofix Rubocop remaining Layout rules (#23679)
This commit is contained in:
parent
d2dcb6c45a
commit
717683d1c3
|
@ -14,154 +14,6 @@ Bundler/OrderedGems:
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'Gemfile'
|
- '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
|
# Offense count: 581
|
||||||
# This cop supports safe autocorrection (--autocorrect).
|
# This cop supports safe autocorrection (--autocorrect).
|
||||||
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
|
||||||
|
|
1
Capfile
1
Capfile
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'capistrano/setup'
|
require 'capistrano/setup'
|
||||||
require 'capistrano/deploy'
|
require 'capistrano/deploy'
|
||||||
require 'capistrano/scm/git'
|
require 'capistrano/scm/git'
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Api::V1::TagsController < Api::BaseController
|
||||||
|
|
||||||
def set_or_create_tag
|
def set_or_create_tag
|
||||||
return not_found unless Tag::HASHTAG_NAME_RE.match?(params[:id])
|
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])
|
@tag = Tag.find_normalized(params[:id]) || Tag.new(name: Tag.normalize(params[:id]), display_name: params[:id])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -128,6 +128,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def current_theme
|
def current_theme
|
||||||
return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme
|
return Setting.theme unless Themes.instance.names.include? current_user&.setting_theme
|
||||||
|
|
||||||
current_user.setting_theme
|
current_user.setting_theme
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ module SessionTrackingConcern
|
||||||
|
|
||||||
def set_session_activity
|
def set_session_activity
|
||||||
return unless session_needs_update?
|
return unless session_needs_update?
|
||||||
|
|
||||||
current_session.touch
|
current_session.touch
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ module SignatureVerification
|
||||||
end
|
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. 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]}"
|
raise SignatureVerificationError, "Invalid Digest value. Computed SHA-256 digest: #{body_digest}; given: #{sha256[1]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ module ApplicationHelper
|
||||||
|
|
||||||
def can?(action, record)
|
def can?(action, record)
|
||||||
return false if record.nil?
|
return false if record.nil?
|
||||||
|
|
||||||
policy(record).public_send("#{action}?")
|
policy(record).public_send("#{action}?")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# rubocop:disable Metrics/ModuleLength, Style/WordArray
|
# rubocop:disable Metrics/ModuleLength, Style/WordArray
|
||||||
|
|
||||||
module LanguagesHelper
|
module LanguagesHelper
|
||||||
|
|
|
@ -153,6 +153,7 @@ class ActivityPub::Activity
|
||||||
def fetch_remote_original_status
|
def fetch_remote_original_status
|
||||||
if object_uri.start_with?('http')
|
if object_uri.start_with?('http')
|
||||||
return if ActivityPub::TagManager.instance.local_uri?(object_uri)
|
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])
|
ActivityPub::FetchRemoteStatusService.new.call(object_uri, id: true, on_behalf_of: @account.followers.local.first, request_id: @options[:request_id])
|
||||||
elsif @object['url'].present?
|
elsif @object['url'].present?
|
||||||
::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id])
|
::FetchRemoteStatusService.new.call(@object['url'], request_id: @options[:request_id])
|
||||||
|
|
|
@ -32,7 +32,7 @@ class ActivityPub::LinkedDataSignature
|
||||||
|
|
||||||
def sign!(creator, sign_with: nil)
|
def sign!(creator, sign_with: nil)
|
||||||
options = {
|
options = {
|
||||||
'type' => 'RsaSignature2017',
|
'type' => 'RsaSignature2017',
|
||||||
'creator' => ActivityPub::TagManager.instance.key_uri_for(creator),
|
'creator' => ActivityPub::TagManager.instance.key_uri_for(creator),
|
||||||
'created' => Time.now.utc.iso8601,
|
'created' => Time.now.utc.iso8601,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ class ActivityPub::TagManager
|
||||||
target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target)
|
target.instance_actor? ? about_more_url(instance_actor: true) : short_account_url(target)
|
||||||
when :note, :comment, :activity
|
when :note, :comment, :activity
|
||||||
return activity_account_status_url(target.account, target) if target.reblog?
|
return activity_account_status_url(target.account, target) if target.reblog?
|
||||||
|
|
||||||
short_account_status_url(target.account, target)
|
short_account_status_url(target.account, target)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -38,6 +39,7 @@ class ActivityPub::TagManager
|
||||||
target.instance_actor? ? instance_actor_url : account_url(target)
|
target.instance_actor? ? instance_actor_url : account_url(target)
|
||||||
when :note, :comment, :activity
|
when :note, :comment, :activity
|
||||||
return activity_account_status_url(target.account, target) if target.reblog?
|
return activity_account_status_url(target.account, target) if target.reblog?
|
||||||
|
|
||||||
account_status_url(target.account, target)
|
account_status_url(target.account, target)
|
||||||
when :emoji
|
when :emoji
|
||||||
emoji_url(target)
|
emoji_url(target)
|
||||||
|
|
|
@ -5,27 +5,27 @@ class OStatus::TagManager
|
||||||
include RoutingHelper
|
include RoutingHelper
|
||||||
|
|
||||||
VERBS = {
|
VERBS = {
|
||||||
post: 'http://activitystrea.ms/schema/1.0/post',
|
post: 'http://activitystrea.ms/schema/1.0/post',
|
||||||
share: 'http://activitystrea.ms/schema/1.0/share',
|
share: 'http://activitystrea.ms/schema/1.0/share',
|
||||||
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
|
favorite: 'http://activitystrea.ms/schema/1.0/favorite',
|
||||||
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
|
unfavorite: 'http://activitystrea.ms/schema/1.0/unfavorite',
|
||||||
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
delete: 'http://activitystrea.ms/schema/1.0/delete',
|
||||||
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
follow: 'http://activitystrea.ms/schema/1.0/follow',
|
||||||
request_friend: 'http://activitystrea.ms/schema/1.0/request-friend',
|
request_friend: 'http://activitystrea.ms/schema/1.0/request-friend',
|
||||||
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
|
authorize: 'http://activitystrea.ms/schema/1.0/authorize',
|
||||||
reject: 'http://activitystrea.ms/schema/1.0/reject',
|
reject: 'http://activitystrea.ms/schema/1.0/reject',
|
||||||
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
unfollow: 'http://ostatus.org/schema/1.0/unfollow',
|
||||||
block: 'http://mastodon.social/schema/1.0/block',
|
block: 'http://mastodon.social/schema/1.0/block',
|
||||||
unblock: 'http://mastodon.social/schema/1.0/unblock',
|
unblock: 'http://mastodon.social/schema/1.0/unblock',
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
TYPES = {
|
TYPES = {
|
||||||
activity: 'http://activitystrea.ms/schema/1.0/activity',
|
activity: 'http://activitystrea.ms/schema/1.0/activity',
|
||||||
note: 'http://activitystrea.ms/schema/1.0/note',
|
note: 'http://activitystrea.ms/schema/1.0/note',
|
||||||
comment: 'http://activitystrea.ms/schema/1.0/comment',
|
comment: 'http://activitystrea.ms/schema/1.0/comment',
|
||||||
person: 'http://activitystrea.ms/schema/1.0/person',
|
person: 'http://activitystrea.ms/schema/1.0/person',
|
||||||
collection: 'http://activitystrea.ms/schema/1.0/collection',
|
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
|
}.freeze
|
||||||
|
|
||||||
COLLECTIONS = {
|
COLLECTIONS = {
|
||||||
|
|
|
@ -182,6 +182,7 @@ class Request
|
||||||
|
|
||||||
contents = truncated_body(limit)
|
contents = truncated_body(limit)
|
||||||
raise Mastodon::LengthValidationError if contents.bytesize > limit
|
raise Mastodon::LengthValidationError if contents.bytesize > limit
|
||||||
|
|
||||||
contents
|
contents
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -34,6 +34,7 @@ module Settings
|
||||||
|
|
||||||
Setting.default_settings.each do |key, default_value|
|
Setting.default_settings.each do |key, default_value|
|
||||||
next if records.key?(key) || default_value.is_a?(Hash)
|
next if records.key?(key) || default_value.is_a?(Hash)
|
||||||
|
|
||||||
records[key] = Setting.new(var: key, value: default_value)
|
records[key] = Setting.new(var: key, value: default_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ module Settings
|
||||||
if db_val
|
if db_val
|
||||||
default_value = ScopedSettings.default_settings[key]
|
default_value = ScopedSettings.default_settings[key]
|
||||||
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
|
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
|
||||||
|
|
||||||
db_val.value
|
db_val.value
|
||||||
else
|
else
|
||||||
ScopedSettings.default_settings[key]
|
ScopedSettings.default_settings[key]
|
||||||
|
|
|
@ -11,6 +11,7 @@ class StatusFilter
|
||||||
|
|
||||||
def filtered?
|
def filtered?
|
||||||
return false if !account.nil? && account.id == status.account_id
|
return false if !account.nil? && account.id == status.account_id
|
||||||
|
|
||||||
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
blocked_by_policy? || (account_present? && filtered_status?) || silenced_account?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ class TagManager
|
||||||
def local_url?(url)
|
def local_url?(url)
|
||||||
uri = Addressable::URI.parse(url).normalize
|
uri = Addressable::URI.parse(url).normalize
|
||||||
return false unless uri.host
|
return false unless uri.host
|
||||||
|
|
||||||
domain = uri.host + (uri.port ? ":#{uri.port}" : '')
|
domain = uri.host + (uri.port ? ":#{uri.port}" : '')
|
||||||
|
|
||||||
TagManager.instance.web_domain?(domain)
|
TagManager.instance.web_domain?(domain)
|
||||||
|
|
|
@ -57,6 +57,7 @@ class Webfinger
|
||||||
if res.code == 200
|
if res.code == 200
|
||||||
body = res.body_with_limit
|
body = res.body_with_limit
|
||||||
raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty?
|
raise Webfinger::Error, "Request for #{@uri} returned empty response" if body.empty?
|
||||||
|
|
||||||
body
|
body
|
||||||
elsif res.code == 404 && use_fallback
|
elsif res.code == 404 && use_fallback
|
||||||
body_from_host_meta
|
body_from_host_meta
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: accounts
|
# Table name: accounts
|
||||||
|
@ -539,6 +540,7 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
def ensure_keys!
|
def ensure_keys!
|
||||||
return unless local? && private_key.blank? && public_key.blank?
|
return unless local? && private_key.blank? && public_key.blank?
|
||||||
|
|
||||||
generate_keys
|
generate_keys
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,8 +14,8 @@ class Account::Field < ActiveModelSerializers::Model
|
||||||
@account = account
|
@account = account
|
||||||
|
|
||||||
super(
|
super(
|
||||||
name: sanitize(attributes['name']),
|
name: sanitize(attributes['name']),
|
||||||
value: sanitize(attributes['value']),
|
value: sanitize(attributes['value']),
|
||||||
verified_at: attributes['verified_at']&.to_datetime,
|
verified_at: attributes['verified_at']&.to_datetime,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_conversations
|
# Table name: account_conversations
|
||||||
|
@ -107,6 +108,7 @@ class AccountConversation < ApplicationRecord
|
||||||
|
|
||||||
def push_to_streaming_api
|
def push_to_streaming_api
|
||||||
return if destroyed? || !subscribed_to_timeline?
|
return if destroyed? || !subscribed_to_timeline?
|
||||||
|
|
||||||
PushConversationWorker.perform_async(id)
|
PushConversationWorker.perform_async(id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_domain_blocks
|
# Table name: account_domain_blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_moderation_notes
|
# Table name: account_moderation_notes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_notes
|
# Table name: account_notes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_pins
|
# Table name: account_pins
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_stats
|
# Table name: account_stats
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_summaries
|
# Table name: account_summaries
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: account_warnings
|
# Table name: account_warnings
|
||||||
|
@ -17,13 +18,13 @@
|
||||||
|
|
||||||
class AccountWarning < ApplicationRecord
|
class AccountWarning < ApplicationRecord
|
||||||
enum action: {
|
enum action: {
|
||||||
none: 0,
|
none: 0,
|
||||||
disable: 1_000,
|
disable: 1_000,
|
||||||
mark_statuses_as_sensitive: 1_250,
|
mark_statuses_as_sensitive: 1_250,
|
||||||
delete_statuses: 1_500,
|
delete_statuses: 1_500,
|
||||||
sensitive: 2_000,
|
sensitive: 2_000,
|
||||||
silence: 3_000,
|
silence: 3_000,
|
||||||
suspend: 4_000,
|
suspend: 4_000,
|
||||||
}, _suffix: :action
|
}, _suffix: :action
|
||||||
|
|
||||||
before_validation :before_validate
|
before_validation :before_validate
|
||||||
|
|
|
@ -56,6 +56,7 @@ class Admin::Import
|
||||||
|
|
||||||
def validate_data
|
def validate_data
|
||||||
return if data.nil?
|
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
|
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
|
rescue CSV::MalformedCSVError => e
|
||||||
errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))
|
errors.add(:data, I18n.t('imports.errors.invalid_csv_file', error: e.message))
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: backups
|
# Table name: backups
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: blocks
|
# Table name: blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: bookmarks
|
# Table name: bookmarks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: canonical_email_blocks
|
# Table name: canonical_email_blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: conversations
|
# Table name: conversations
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: conversation_mutes
|
# Table name: conversation_mutes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: custom_emojis
|
# Table name: custom_emojis
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: custom_filters
|
# 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?
|
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?
|
next if keyword_matches.blank? && status_matches.blank?
|
||||||
|
|
||||||
FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches)
|
FilterResultPresenter.new(filter: filter, keyword_matches: keyword_matches, status_matches: status_matches)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -111,6 +113,7 @@ class CustomFilter < ApplicationRecord
|
||||||
|
|
||||||
def invalidate_cache!
|
def invalidate_cache!
|
||||||
return unless @should_invalidate_cache
|
return unless @should_invalidate_cache
|
||||||
|
|
||||||
@should_invalidate_cache = false
|
@should_invalidate_cache = false
|
||||||
|
|
||||||
Rails.cache.delete("filters:v3:#{account_id}")
|
Rails.cache.delete("filters:v3:#{account_id}")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: custom_filter_keywords
|
# Table name: custom_filter_keywords
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: custom_filter_statuses
|
# Table name: custom_filter_statuses
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: devices
|
# Table name: devices
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: domain_blocks
|
# Table name: domain_blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: email_domain_blocks
|
# Table name: email_domain_blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: encrypted_messages
|
# Table name: encrypted_messages
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: favourites
|
# Table name: favourites
|
||||||
|
@ -38,6 +39,7 @@ class Favourite < ApplicationRecord
|
||||||
|
|
||||||
def decrement_cache_counters
|
def decrement_cache_counters
|
||||||
return if association(:status).loaded? && status.marked_for_destruction?
|
return if association(:status).loaded? && status.marked_for_destruction?
|
||||||
|
|
||||||
status&.decrement_count!(:favourites_count)
|
status&.decrement_count!(:favourites_count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: featured_tags
|
# Table name: featured_tags
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: follows
|
# Table name: follows
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: follow_recommendations
|
# Table name: follow_recommendations
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: follow_recommendation_suppressions
|
# Table name: follow_recommendation_suppressions
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: follow_requests
|
# Table name: follow_requests
|
||||||
|
|
|
@ -128,6 +128,7 @@ class Form::AdminSettings
|
||||||
def validate_site_uploads
|
def validate_site_uploads
|
||||||
UPLOAD_KEYS.each do |key|
|
UPLOAD_KEYS.each do |key|
|
||||||
next unless instance_variable_defined?("@#{key}")
|
next unless instance_variable_defined?("@#{key}")
|
||||||
|
|
||||||
upload = instance_variable_get("@#{key}")
|
upload = instance_variable_get("@#{key}")
|
||||||
next if upload.valid?
|
next if upload.valid?
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: identities
|
# Table name: identities
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: imports
|
# Table name: imports
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: instances
|
# Table name: instances
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: invites
|
# Table name: invites
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: ip_blocks
|
# Table name: ip_blocks
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: lists
|
# Table name: lists
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: list_accounts
|
# Table name: list_accounts
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: login_activities
|
# Table name: login_activities
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: media_attachments
|
# Table name: media_attachments
|
||||||
|
@ -372,7 +373,7 @@ class MediaAttachment < ApplicationRecord
|
||||||
return {} if width.nil?
|
return {} if width.nil?
|
||||||
|
|
||||||
{
|
{
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
size: "#{width}x#{height}",
|
size: "#{width}x#{height}",
|
||||||
aspect: width.to_f / height,
|
aspect: width.to_f / height,
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: mentions
|
# Table name: mentions
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: mutes
|
# Table name: mutes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: notifications
|
# Table name: notifications
|
||||||
|
@ -19,12 +20,12 @@ class Notification < ApplicationRecord
|
||||||
include Paginable
|
include Paginable
|
||||||
|
|
||||||
LEGACY_TYPE_CLASS_MAP = {
|
LEGACY_TYPE_CLASS_MAP = {
|
||||||
'Mention' => :mention,
|
'Mention' => :mention,
|
||||||
'Status' => :reblog,
|
'Status' => :reblog,
|
||||||
'Follow' => :follow,
|
'Follow' => :follow,
|
||||||
'FollowRequest' => :follow_request,
|
'FollowRequest' => :follow_request,
|
||||||
'Favourite' => :favourite,
|
'Favourite' => :favourite,
|
||||||
'Poll' => :poll,
|
'Poll' => :poll,
|
||||||
}.freeze
|
}.freeze
|
||||||
|
|
||||||
TYPES = %i(
|
TYPES = %i(
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: one_time_keys
|
# Table name: one_time_keys
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: polls
|
# Table name: polls
|
||||||
|
@ -74,9 +75,9 @@ class Poll < ApplicationRecord
|
||||||
|
|
||||||
def initialize(poll, id, title, votes_count)
|
def initialize(poll, id, title, votes_count)
|
||||||
super(
|
super(
|
||||||
poll: poll,
|
poll: poll,
|
||||||
id: id,
|
id: id,
|
||||||
title: title,
|
title: title,
|
||||||
votes_count: votes_count,
|
votes_count: votes_count,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -105,6 +106,7 @@ class Poll < ApplicationRecord
|
||||||
|
|
||||||
def reset_parent_cache
|
def reset_parent_cache
|
||||||
return if status_id.nil?
|
return if status_id.nil?
|
||||||
|
|
||||||
Rails.cache.delete("statuses/#{status_id}")
|
Rails.cache.delete("statuses/#{status_id}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: poll_votes
|
# Table name: poll_votes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: preview_cards
|
# Table name: preview_cards
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: preview_card_providers
|
# Table name: preview_card_providers
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: relays
|
# Table name: relays
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: reports
|
# Table name: reports
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: report_notes
|
# Table name: report_notes
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: session_activations
|
# Table name: session_activations
|
||||||
|
@ -51,6 +52,7 @@ class SessionActivation < ApplicationRecord
|
||||||
|
|
||||||
def deactivate(id)
|
def deactivate(id)
|
||||||
return unless id
|
return unless id
|
||||||
|
|
||||||
where(session_id: id).destroy_all
|
where(session_id: id).destroy_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: settings
|
# Table name: settings
|
||||||
|
@ -30,6 +31,7 @@ class Setting < RailsSettings::Base
|
||||||
default_value = default_settings[key]
|
default_value = default_settings[key]
|
||||||
|
|
||||||
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
|
return default_value.with_indifferent_access.merge!(db_val.value) if default_value.is_a?(Hash)
|
||||||
|
|
||||||
db_val.value
|
db_val.value
|
||||||
else
|
else
|
||||||
default_settings[key]
|
default_settings[key]
|
||||||
|
@ -43,6 +45,7 @@ class Setting < RailsSettings::Base
|
||||||
|
|
||||||
default_settings.each do |key, default_value|
|
default_settings.each do |key, default_value|
|
||||||
next if records.key?(key) || default_value.is_a?(Hash)
|
next if records.key?(key) || default_value.is_a?(Hash)
|
||||||
|
|
||||||
records[key] = Setting.new(var: key, value: default_value)
|
records[key] = Setting.new(var: key, value: default_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -51,6 +54,7 @@ class Setting < RailsSettings::Base
|
||||||
|
|
||||||
def default_settings
|
def default_settings
|
||||||
return {} unless RailsSettings::Default.enabled?
|
return {} unless RailsSettings::Default.enabled?
|
||||||
|
|
||||||
RailsSettings::Default.instance
|
RailsSettings::Default.instance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: site_uploads
|
# Table name: site_uploads
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: statuses
|
# Table name: statuses
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: status_edits
|
# Table name: status_edits
|
||||||
|
@ -45,6 +46,7 @@ class StatusEdit < ApplicationRecord
|
||||||
|
|
||||||
def emojis
|
def emojis
|
||||||
return @emojis if defined?(@emojis)
|
return @emojis if defined?(@emojis)
|
||||||
|
|
||||||
@emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
|
@emojis = CustomEmoji.from_text([spoiler_text, text].join(' '), status.account.domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: status_pins
|
# Table name: status_pins
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: status_stats
|
# Table name: status_stats
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: tags
|
# Table name: tags
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: unavailable_domains
|
# Table name: unavailable_domains
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: users
|
# Table name: users
|
||||||
|
@ -492,12 +493,14 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def sanitize_languages
|
def sanitize_languages
|
||||||
return if chosen_languages.nil?
|
return if chosen_languages.nil?
|
||||||
|
|
||||||
chosen_languages.reject!(&:blank?)
|
chosen_languages.reject!(&:blank?)
|
||||||
self.chosen_languages = nil if chosen_languages.empty?
|
self.chosen_languages = nil if chosen_languages.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitize_role
|
def sanitize_role
|
||||||
return if role.nil?
|
return if role.nil?
|
||||||
|
|
||||||
self.role = nil if role.everyone?
|
self.role = nil if role.everyone?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -516,6 +519,7 @@ class User < ApplicationRecord
|
||||||
def notify_staff_about_pending_account!
|
def notify_staff_about_pending_account!
|
||||||
User.those_who_can(:manage_users).includes(:account).find_each do |u|
|
User.those_who_can(:manage_users).includes(:account).find_each do |u|
|
||||||
next unless u.allows_pending_account_emails?
|
next unless u.allows_pending_account_emails?
|
||||||
|
|
||||||
AdminMailer.new_pending_account(u.account, self).deliver_later
|
AdminMailer.new_pending_account(u.account, self).deliver_later
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: user_ips
|
# Table name: user_ips
|
||||||
|
|
|
@ -163,6 +163,7 @@ class UserRole < ApplicationRecord
|
||||||
|
|
||||||
def in_permissions?(privilege)
|
def in_permissions?(privilege)
|
||||||
raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege)
|
raise ArgumentError, "Unknown privilege: #{privilege}" unless FLAGS.key?(privilege)
|
||||||
|
|
||||||
computed_permissions & FLAGS[privilege] == FLAGS[privilege]
|
computed_permissions & FLAGS[privilege] == FLAGS[privilege]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -172,6 +173,7 @@ class UserRole < ApplicationRecord
|
||||||
|
|
||||||
def validate_own_role_edition
|
def validate_own_role_edition
|
||||||
return unless defined?(@current_account) && @current_account.user_role.id == id
|
return unless defined?(@current_account) && @current_account.user_role.id == id
|
||||||
|
|
||||||
errors.add(:permissions_as_keys, :own_role) if permissions_changed?
|
errors.add(:permissions_as_keys, :own_role) if permissions_changed?
|
||||||
errors.add(:position, :own_role) if position_changed?
|
errors.add(:position, :own_role) if position_changed?
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: web_push_subscriptions
|
# Table name: web_push_subscriptions
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: web_settings
|
# Table name: web_settings
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# == Schema Information
|
# == Schema Information
|
||||||
#
|
#
|
||||||
# Table name: webauthn_credentials
|
# Table name: webauthn_credentials
|
||||||
|
|
|
@ -70,16 +70,16 @@ class AccountRelationshipsPresenter
|
||||||
def cache_uncached!
|
def cache_uncached!
|
||||||
@uncached_account_ids.each do |account_id|
|
@uncached_account_ids.each do |account_id|
|
||||||
maps_for_account = {
|
maps_for_account = {
|
||||||
following: { account_id => following[account_id] },
|
following: { account_id => following[account_id] },
|
||||||
followed_by: { account_id => followed_by[account_id] },
|
followed_by: { account_id => followed_by[account_id] },
|
||||||
blocking: { account_id => blocking[account_id] },
|
blocking: { account_id => blocking[account_id] },
|
||||||
blocked_by: { account_id => blocked_by[account_id] },
|
blocked_by: { account_id => blocked_by[account_id] },
|
||||||
muting: { account_id => muting[account_id] },
|
muting: { account_id => muting[account_id] },
|
||||||
requested: { account_id => requested[account_id] },
|
requested: { account_id => requested[account_id] },
|
||||||
requested_by: { account_id => requested_by[account_id] },
|
requested_by: { account_id => requested_by[account_id] },
|
||||||
domain_blocking: { account_id => domain_blocking[account_id] },
|
domain_blocking: { account_id => domain_blocking[account_id] },
|
||||||
endorsed: { account_id => endorsed[account_id] },
|
endorsed: { account_id => endorsed[account_id] },
|
||||||
account_note: { account_id => account_note[account_id] },
|
account_note: { account_id => account_note[account_id] },
|
||||||
}
|
}
|
||||||
|
|
||||||
Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day)
|
Rails.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day)
|
||||||
|
|
|
@ -50,6 +50,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
||||||
|
|
||||||
if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero?
|
if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero?
|
||||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
|
||||||
|
|
||||||
def trustworthy_attribution?(uri, attributed_to)
|
def trustworthy_attribution?(uri, attributed_to)
|
||||||
return false if uri.nil? || attributed_to.nil?
|
return false if uri.nil? || attributed_to.nil?
|
||||||
|
|
||||||
Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero?
|
Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,6 +36,7 @@ class ActivityPub::FetchRepliesService < BaseService
|
||||||
return collection_or_uri if collection_or_uri.is_a?(Hash)
|
return collection_or_uri if collection_or_uri.is_a?(Hash)
|
||||||
return unless @allow_synchronous_requests
|
return unless @allow_synchronous_requests
|
||||||
return if invalid_origin?(collection_or_uri)
|
return if invalid_origin?(collection_or_uri)
|
||||||
|
|
||||||
fetch_resource_without_id_validation(collection_or_uri, nil, true)
|
fetch_resource_without_id_validation(collection_or_uri, nil, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -226,6 +226,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||||
|
|
||||||
def property_values
|
def property_values
|
||||||
return unless @json['attachment'].is_a?(Array)
|
return unless @json['attachment'].is_a?(Array)
|
||||||
|
|
||||||
as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
|
as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -289,6 +290,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
||||||
|
|
||||||
def domain_block
|
def domain_block
|
||||||
return @domain_block if defined?(@domain_block)
|
return @domain_block if defined?(@domain_block)
|
||||||
|
|
||||||
@domain_block = DomainBlock.rule_for(@domain)
|
@domain_block = DomainBlock.rule_for(@domain)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ class FavouriteService < BaseService
|
||||||
def bump_potential_friendship(account, status)
|
def bump_potential_friendship(account, status)
|
||||||
ActivityTracker.increment('activity:interactions')
|
ActivityTracker.increment('activity:interactions')
|
||||||
return if account.following?(status.account_id)
|
return if account.following?(status.account_id)
|
||||||
|
|
||||||
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
|
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ class Keys::ClaimService < BaseService
|
||||||
|
|
||||||
def initialize(account, device_id, key_attributes = {})
|
def initialize(account, device_id, key_attributes = {})
|
||||||
super(
|
super(
|
||||||
account: account,
|
account: account,
|
||||||
device_id: device_id,
|
device_id: device_id,
|
||||||
key_id: key_attributes[:key_id],
|
key_id: key_attributes[:key_id],
|
||||||
key: key_attributes[:key],
|
key: key_attributes[:key],
|
||||||
signature: key_attributes[:signature],
|
signature: key_attributes[:signature],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,9 +23,9 @@ class Keys::QueryService < BaseService
|
||||||
|
|
||||||
def initialize(attributes = {})
|
def initialize(attributes = {})
|
||||||
super(
|
super(
|
||||||
device_id: attributes[:device_id],
|
device_id: attributes[:device_id],
|
||||||
name: attributes[:name],
|
name: attributes[:name],
|
||||||
identity_key: attributes[:identity_key],
|
identity_key: attributes[:identity_key],
|
||||||
fingerprint_key: attributes[:fingerprint_key],
|
fingerprint_key: attributes[:fingerprint_key],
|
||||||
)
|
)
|
||||||
@claim_url = attributes[:claim_url]
|
@claim_url = attributes[:claim_url]
|
||||||
|
|
|
@ -31,6 +31,7 @@ class NotifyService < BaseService
|
||||||
|
|
||||||
def following_sender?
|
def following_sender?
|
||||||
return @following_sender if defined?(@following_sender)
|
return @following_sender if defined?(@following_sender)
|
||||||
|
|
||||||
@following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account)
|
@following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ class PostStatusService < BaseService
|
||||||
|
|
||||||
def safeguard_mentions!(status)
|
def safeguard_mentions!(status)
|
||||||
return if @options[:allowed_mentions].nil?
|
return if @options[:allowed_mentions].nil?
|
||||||
|
|
||||||
expected_account_ids = @options[:allowed_mentions].map(&:to_i)
|
expected_account_ids = @options[:allowed_mentions].map(&:to_i)
|
||||||
|
|
||||||
unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) }
|
unexpected_accounts = status.mentions.map(&:account).to_a.reject { |mentioned_account| expected_account_ids.include?(mentioned_account.id) }
|
||||||
|
@ -175,8 +176,10 @@ class PostStatusService < BaseService
|
||||||
|
|
||||||
def bump_potential_friendship!
|
def bump_potential_friendship!
|
||||||
return if !@status.reply? || @account.id == @status.in_reply_to_account_id
|
return if !@status.reply? || @account.id == @status.in_reply_to_account_id
|
||||||
|
|
||||||
ActivityTracker.increment('activity:interactions')
|
ActivityTracker.increment('activity:interactions')
|
||||||
return if @account.following?(@status.in_reply_to_account_id)
|
return if @account.following?(@status.in_reply_to_account_id)
|
||||||
|
|
||||||
PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply)
|
PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,13 @@ class VoteService < BaseService
|
||||||
|
|
||||||
def distribute_poll!
|
def distribute_poll!
|
||||||
return if @poll.hide_totals?
|
return if @poll.hide_totals?
|
||||||
|
|
||||||
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id)
|
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def queue_final_poll_check!
|
def queue_final_poll_check!
|
||||||
return unless @poll.expires?
|
return unless @poll.expires?
|
||||||
|
|
||||||
PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id)
|
PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ class FollowLimitValidator < ActiveModel::Validator
|
||||||
|
|
||||||
def validate(follow)
|
def validate(follow)
|
||||||
return if follow.account.nil? || !follow.account.local?
|
return if follow.account.nil? || !follow.account.local?
|
||||||
|
|
||||||
follow.errors.add(:base, I18n.t('users.follow_limit_reached', limit: self.class.limit_for_account(follow.account))) if limit_reached?(follow.account)
|
follow.errors.add(:base, I18n.t('users.follow_limit_reached', limit: self.class.limit_for_account(follow.account))) if limit_reached?(follow.account)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,14 @@ class UnreservedUsernameValidator < ActiveModel::Validator
|
||||||
|
|
||||||
def pam_controlled?
|
def pam_controlled?
|
||||||
return false unless Devise.pam_authentication && Devise.pam_controlled_service
|
return false unless Devise.pam_authentication && Devise.pam_controlled_service
|
||||||
|
|
||||||
Rpam2.account(Devise.pam_controlled_service, @username).present?
|
Rpam2.account(Devise.pam_controlled_service, @username).present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def reserved_username?
|
def reserved_username?
|
||||||
return true if pam_controlled?
|
return true if pam_controlled?
|
||||||
return false unless Setting.reserved_usernames
|
return false unless Setting.reserved_usernames
|
||||||
|
|
||||||
Setting.reserved_usernames.include?(@username.downcase)
|
Setting.reserved_usernames.include?(@username.downcase)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,6 +62,7 @@ class Scheduler::AccountsStatusesCleanupScheduler
|
||||||
# The idea here is to loop through all policies at least once until the budget is exhausted
|
# The idea here is to loop through all policies at least once until the budget is exhausted
|
||||||
# and start back after the last processed account otherwise
|
# and start back after the last processed account otherwise
|
||||||
break if budget.zero? || (num_processed_accounts.zero? && first_policy_id.nil?)
|
break if budget.zero? || (num_processed_accounts.zero? && first_policy_id.nil?)
|
||||||
|
|
||||||
first_policy_id = nil
|
first_policy_id = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -73,6 +74,7 @@ class Scheduler::AccountsStatusesCleanupScheduler
|
||||||
|
|
||||||
def under_load?
|
def under_load?
|
||||||
return true if Sidekiq::Stats.new.retry_size > MAX_RETRY_SIZE
|
return true if Sidekiq::Stats.new.retry_size > MAX_RETRY_SIZE
|
||||||
|
|
||||||
queue_under_load?('default', MAX_DEFAULT_SIZE, MAX_DEFAULT_LATENCY) || queue_under_load?('push', MAX_PUSH_SIZE, MAX_PUSH_LATENCY) || queue_under_load?('pull', MAX_PULL_SIZE, MAX_PULL_LATENCY)
|
queue_under_load?('default', MAX_DEFAULT_SIZE, MAX_DEFAULT_LATENCY) || queue_under_load?('push', MAX_PUSH_SIZE, MAX_PUSH_LATENCY) || queue_under_load?('pull', MAX_PULL_SIZE, MAX_PULL_LATENCY)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,13 @@ class Web::PushNotificationWorker
|
||||||
request = Request.new(:post, @subscription.endpoint, body: payload.fetch(:ciphertext), http_client: http_client)
|
request = Request.new(:post, @subscription.endpoint, body: payload.fetch(:ciphertext), http_client: http_client)
|
||||||
|
|
||||||
request.add_headers(
|
request.add_headers(
|
||||||
'Content-Type' => 'application/octet-stream',
|
'Content-Type' => 'application/octet-stream',
|
||||||
'Ttl' => TTL,
|
'Ttl' => TTL,
|
||||||
'Urgency' => URGENCY,
|
'Urgency' => URGENCY,
|
||||||
'Content-Encoding' => 'aesgcm',
|
'Content-Encoding' => 'aesgcm',
|
||||||
'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}",
|
'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}",
|
||||||
'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}",
|
'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}",
|
||||||
'Authorization' => @subscription.authorization_header
|
'Authorization' => @subscription.authorization_header
|
||||||
)
|
)
|
||||||
|
|
||||||
request.perform do |response|
|
request.perform do |response|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# This file is used by Rack-based servers to start the application.
|
# This file is used by Rack-based servers to start the application.
|
||||||
|
|
||||||
require File.expand_path('config/environment', __dir__)
|
require File.expand_path('config/environment', __dir__)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue