M .rubocop_todo.yml => .rubocop_todo.yml +0 -148
@@ 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.
M Capfile => Capfile +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/scm/git'
M app/controllers/api/v1/tags_controller.rb => app/controllers/api/v1/tags_controller.rb +1 -0
@@ 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
M app/controllers/application_controller.rb => app/controllers/application_controller.rb +1 -0
@@ 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
M app/controllers/concerns/session_tracking_concern.rb => app/controllers/concerns/session_tracking_concern.rb +1 -0
@@ 13,6 13,7 @@ module SessionTrackingConcern
def set_session_activity
return unless session_needs_update?
+
current_session.touch
end
M app/controllers/concerns/signature_verification.rb => app/controllers/concerns/signature_verification.rb +1 -0
@@ 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
M app/helpers/application_helper.rb => app/helpers/application_helper.rb +1 -0
@@ 105,6 105,7 @@ module ApplicationHelper
def can?(action, record)
return false if record.nil?
+
policy(record).public_send("#{action}?")
end
M app/helpers/languages_helper.rb => app/helpers/languages_helper.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/ModuleLength, Style/WordArray
module LanguagesHelper
M app/lib/activitypub/activity.rb => app/lib/activitypub/activity.rb +1 -0
@@ 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])
M app/lib/activitypub/linked_data_signature.rb => app/lib/activitypub/linked_data_signature.rb +1 -1
@@ 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,
}
M app/lib/activitypub/tag_manager.rb => app/lib/activitypub/tag_manager.rb +2 -0
@@ 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)
M app/lib/ostatus/tag_manager.rb => app/lib/ostatus/tag_manager.rb +16 -16
@@ 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 = {
M app/lib/request.rb => app/lib/request.rb +1 -0
@@ 182,6 182,7 @@ class Request
contents = truncated_body(limit)
raise Mastodon::LengthValidationError if contents.bytesize > limit
+
contents
end
end
M app/lib/settings/scoped_settings.rb => app/lib/settings/scoped_settings.rb +2 -0
@@ 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]
M app/lib/status_filter.rb => app/lib/status_filter.rb +1 -0
@@ 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
M app/lib/tag_manager.rb => app/lib/tag_manager.rb +1 -0
@@ 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)
M app/lib/webfinger.rb => app/lib/webfinger.rb +1 -0
@@ 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
M app/models/account.rb => app/models/account.rb +2 -0
@@ 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
M app/models/account/field.rb => app/models/account/field.rb +2 -2
@@ 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
M app/models/account_conversation.rb => app/models/account_conversation.rb +2 -0
@@ 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
M app/models/account_domain_block.rb => app/models/account_domain_block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_domain_blocks
M app/models/account_moderation_note.rb => app/models/account_moderation_note.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_moderation_notes
M app/models/account_note.rb => app/models/account_note.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_notes
M app/models/account_pin.rb => app/models/account_pin.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_pins
M app/models/account_stat.rb => app/models/account_stat.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_stats
M app/models/account_summary.rb => app/models/account_summary.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: account_summaries
M app/models/account_warning.rb => app/models/account_warning.rb +7 -6
@@ 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
M app/models/admin/import.rb => app/models/admin/import.rb +1 -0
@@ 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))
M app/models/backup.rb => app/models/backup.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: backups
M app/models/block.rb => app/models/block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: blocks
M app/models/bookmark.rb => app/models/bookmark.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: bookmarks
M app/models/canonical_email_block.rb => app/models/canonical_email_block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: canonical_email_blocks
M app/models/conversation.rb => app/models/conversation.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: conversations
M app/models/conversation_mute.rb => app/models/conversation_mute.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: conversation_mutes
M app/models/custom_emoji.rb => app/models/custom_emoji.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: custom_emojis
M app/models/custom_filter.rb => app/models/custom_filter.rb +3 -0
@@ 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}")
M app/models/custom_filter_keyword.rb => app/models/custom_filter_keyword.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: custom_filter_keywords
M app/models/custom_filter_status.rb => app/models/custom_filter_status.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: custom_filter_statuses
M app/models/device.rb => app/models/device.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: devices
M app/models/domain_block.rb => app/models/domain_block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: domain_blocks
M app/models/email_domain_block.rb => app/models/email_domain_block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: email_domain_blocks
M app/models/encrypted_message.rb => app/models/encrypted_message.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: encrypted_messages
M app/models/favourite.rb => app/models/favourite.rb +2 -0
@@ 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
M app/models/featured_tag.rb => app/models/featured_tag.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: featured_tags
M app/models/follow.rb => app/models/follow.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: follows
M app/models/follow_recommendation.rb => app/models/follow_recommendation.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: follow_recommendations
M app/models/follow_recommendation_suppression.rb => app/models/follow_recommendation_suppression.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: follow_recommendation_suppressions
M app/models/follow_request.rb => app/models/follow_request.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: follow_requests
M app/models/form/admin_settings.rb => app/models/form/admin_settings.rb +1 -0
@@ 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?
M app/models/identity.rb => app/models/identity.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: identities
M app/models/import.rb => app/models/import.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: imports
M app/models/instance.rb => app/models/instance.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: instances
M app/models/invite.rb => app/models/invite.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: invites
M app/models/ip_block.rb => app/models/ip_block.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: ip_blocks
M app/models/list.rb => app/models/list.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: lists
M app/models/list_account.rb => app/models/list_account.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: list_accounts
M app/models/login_activity.rb => app/models/login_activity.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: login_activities
M app/models/media_attachment.rb => app/models/media_attachment.rb +2 -1
@@ 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,
M app/models/mention.rb => app/models/mention.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: mentions
M app/models/mute.rb => app/models/mute.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: mutes
M app/models/notification.rb => app/models/notification.rb +6 -5
@@ 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(
M app/models/one_time_key.rb => app/models/one_time_key.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: one_time_keys
M app/models/poll.rb => app/models/poll.rb +5 -3
@@ 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
M app/models/poll_vote.rb => app/models/poll_vote.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: poll_votes
M app/models/preview_card.rb => app/models/preview_card.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: preview_cards
M app/models/preview_card_provider.rb => app/models/preview_card_provider.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: preview_card_providers
M app/models/relay.rb => app/models/relay.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: relays
M app/models/report.rb => app/models/report.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: reports
M app/models/report_note.rb => app/models/report_note.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: report_notes
M app/models/session_activation.rb => app/models/session_activation.rb +2 -0
@@ 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
M app/models/setting.rb => app/models/setting.rb +4 -0
@@ 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
M app/models/site_upload.rb => app/models/site_upload.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: site_uploads
M app/models/status.rb => app/models/status.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: statuses
M app/models/status_edit.rb => app/models/status_edit.rb +2 -0
@@ 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
M app/models/status_pin.rb => app/models/status_pin.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: status_pins
M app/models/status_stat.rb => app/models/status_stat.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: status_stats
M app/models/tag.rb => app/models/tag.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: tags
M app/models/unavailable_domain.rb => app/models/unavailable_domain.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: unavailable_domains
M app/models/user.rb => app/models/user.rb +4 -0
@@ 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
M app/models/user_ip.rb => app/models/user_ip.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: user_ips
M app/models/user_role.rb => app/models/user_role.rb +2 -0
@@ 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
M app/models/web/push_subscription.rb => app/models/web/push_subscription.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: web_push_subscriptions
M app/models/web/setting.rb => app/models/web/setting.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: web_settings
M app/models/webauthn_credential.rb => app/models/webauthn_credential.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# == Schema Information
#
# Table name: webauthn_credentials
M app/presenters/account_relationships_presenter.rb => app/presenters/account_relationships_presenter.rb +9 -9
@@ 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.cache.write("relationship:#{@current_account_id}:#{account_id}", maps_for_account, expires_in: 1.day)
M app/services/activitypub/fetch_remote_actor_service.rb => app/services/activitypub/fetch_remote_actor_service.rb +1 -0
@@ 50,6 50,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
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
+
return
end
M app/services/activitypub/fetch_remote_status_service.rb => app/services/activitypub/fetch_remote_status_service.rb +1 -0
@@ 56,6 56,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService
def trustworthy_attribution?(uri, attributed_to)
return false if uri.nil? || attributed_to.nil?
+
Addressable::URI.parse(uri).normalized_host.casecmp(Addressable::URI.parse(attributed_to).normalized_host).zero?
end
M app/services/activitypub/fetch_replies_service.rb => app/services/activitypub/fetch_replies_service.rb +1 -0
@@ 36,6 36,7 @@ class ActivityPub::FetchRepliesService < BaseService
return collection_or_uri if collection_or_uri.is_a?(Hash)
return unless @allow_synchronous_requests
return if invalid_origin?(collection_or_uri)
+
fetch_resource_without_id_validation(collection_or_uri, nil, true)
end
M app/services/activitypub/process_account_service.rb => app/services/activitypub/process_account_service.rb +2 -0
@@ 226,6 226,7 @@ class ActivityPub::ProcessAccountService < BaseService
def property_values
return unless @json['attachment'].is_a?(Array)
+
as_array(@json['attachment']).select { |attachment| attachment['type'] == 'PropertyValue' }.map { |attachment| attachment.slice('name', 'value') }
end
@@ 289,6 290,7 @@ class ActivityPub::ProcessAccountService < BaseService
def domain_block
return @domain_block if defined?(@domain_block)
+
@domain_block = DomainBlock.rule_for(@domain)
end
M app/services/favourite_service.rb => app/services/favourite_service.rb +1 -0
@@ 40,6 40,7 @@ class FavouriteService < BaseService
def bump_potential_friendship(account, status)
ActivityTracker.increment('activity:interactions')
return if account.following?(status.account_id)
+
PotentialFriendshipTracker.record(account.id, status.account_id, :favourite)
end
M app/services/keys/claim_service.rb => app/services/keys/claim_service.rb +3 -3
@@ 9,10 9,10 @@ class Keys::ClaimService < BaseService
def initialize(account, device_id, key_attributes = {})
super(
- account: account,
+ account: account,
device_id: device_id,
- key_id: key_attributes[:key_id],
- key: key_attributes[:key],
+ key_id: key_attributes[:key_id],
+ key: key_attributes[:key],
signature: key_attributes[:signature],
)
end
M app/services/keys/query_service.rb => app/services/keys/query_service.rb +3 -3
@@ 23,9 23,9 @@ class Keys::QueryService < BaseService
def initialize(attributes = {})
super(
- device_id: attributes[:device_id],
- name: attributes[:name],
- identity_key: attributes[:identity_key],
+ device_id: attributes[:device_id],
+ name: attributes[:name],
+ identity_key: attributes[:identity_key],
fingerprint_key: attributes[:fingerprint_key],
)
@claim_url = attributes[:claim_url]
M app/services/notify_service.rb => app/services/notify_service.rb +1 -0
@@ 31,6 31,7 @@ class NotifyService < BaseService
def following_sender?
return @following_sender if defined?(@following_sender)
+
@following_sender = @recipient.following?(@notification.from_account) || @recipient.requested?(@notification.from_account)
end
M app/services/post_status_service.rb => app/services/post_status_service.rb +3 -0
@@ 86,6 86,7 @@ class PostStatusService < BaseService
def safeguard_mentions!(status)
return if @options[:allowed_mentions].nil?
+
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) }
@@ 175,8 176,10 @@ class PostStatusService < BaseService
def bump_potential_friendship!
return if !@status.reply? || @account.id == @status.in_reply_to_account_id
+
ActivityTracker.increment('activity:interactions')
return if @account.following?(@status.in_reply_to_account_id)
+
PotentialFriendshipTracker.record(@account.id, @status.in_reply_to_account_id, :reply)
end
M app/services/vote_service.rb => app/services/vote_service.rb +2 -0
@@ 44,11 44,13 @@ class VoteService < BaseService
def distribute_poll!
return if @poll.hide_totals?
+
ActivityPub::DistributePollUpdateWorker.perform_in(3.minutes, @poll.status.id)
end
def queue_final_poll_check!
return unless @poll.expires?
+
PollExpirationNotifyWorker.perform_at(@poll.expires_at + 5.minutes, @poll.id)
end
M app/validators/follow_limit_validator.rb => app/validators/follow_limit_validator.rb +1 -0
@@ 6,6 6,7 @@ class FollowLimitValidator < ActiveModel::Validator
def validate(follow)
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)
end
M app/validators/unreserved_username_validator.rb => app/validators/unreserved_username_validator.rb +2 -0
@@ 13,12 13,14 @@ class UnreservedUsernameValidator < ActiveModel::Validator
def pam_controlled?
return false unless Devise.pam_authentication && Devise.pam_controlled_service
+
Rpam2.account(Devise.pam_controlled_service, @username).present?
end
def reserved_username?
return true if pam_controlled?
return false unless Setting.reserved_usernames
+
Setting.reserved_usernames.include?(@username.downcase)
end
end
M app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb => app/workers/scheduler/accounts_statuses_cleanup_scheduler.rb +2 -0
@@ 62,6 62,7 @@ class Scheduler::AccountsStatusesCleanupScheduler
# 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
break if budget.zero? || (num_processed_accounts.zero? && first_policy_id.nil?)
+
first_policy_id = nil
end
end
@@ 73,6 74,7 @@ class Scheduler::AccountsStatusesCleanupScheduler
def under_load?
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)
end
M app/workers/web/push_notification_worker.rb => app/workers/web/push_notification_worker.rb +6 -6
@@ 22,13 22,13 @@ class Web::PushNotificationWorker
request = Request.new(:post, @subscription.endpoint, body: payload.fetch(:ciphertext), http_client: http_client)
request.add_headers(
- 'Content-Type' => 'application/octet-stream',
- 'Ttl' => TTL,
- 'Urgency' => URGENCY,
+ 'Content-Type' => 'application/octet-stream',
+ 'Ttl' => TTL,
+ 'Urgency' => URGENCY,
'Content-Encoding' => 'aesgcm',
- 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}",
- 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}",
- 'Authorization' => @subscription.authorization_header
+ 'Encryption' => "salt=#{Webpush.encode64(payload.fetch(:salt)).delete('=')}",
+ 'Crypto-Key' => "dh=#{Webpush.encode64(payload.fetch(:server_public_key)).delete('=')};#{@subscription.crypto_key_header}",
+ 'Authorization' => @subscription.authorization_header
)
request.perform do |response|
M config.ru => config.ru +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
# This file is used by Rack-based servers to start the application.
require File.expand_path('config/environment', __dir__)
M db/migrate/20190314181829_migrate_open_registrations_setting.rb => db/migrate/20190314181829_migrate_open_registrations_setting.rb +2 -0
@@ 2,6 2,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
def up
open_registrations = Setting.find_by(var: 'open_registrations')
return if open_registrations.nil? || open_registrations.value
+
setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode')
setting.update(value: 'none')
end
@@ 9,6 10,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
def down
registrations_mode = Setting.find_by(var: 'registrations_mode')
return if registrations_mode.nil?
+
setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations')
setting.update(value: registrations_mode.value == 'open')
end
M db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb => db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb +1 -0
@@ 8,6 8,7 @@ class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2]
User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user|
next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists?
+
user.settings.advanced_layout = true
end
end
M db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb => db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb +1 -0
@@ 11,6 11,7 @@ class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
rescue ActiveRecord::StatementInvalid => e
remove_index :tags, name: 'index_tags_on_name_lower_btree'
raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique)
+
raise e
end
M db/migrate/20220613110834_add_action_to_custom_filters.rb => db/migrate/20220613110834_add_action_to_custom_filters.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddActionToCustomFilters < ActiveRecord::Migration[6.1]
M db/post_migrate/20200917193528_migrate_notifications_type.rb => db/post_migrate/20200917193528_migrate_notifications_type.rb +5 -5
@@ 4,12 4,12 @@ class MigrateNotificationsType < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
TYPES_TO_MIGRATE = {
- 'Mention' => :mention,
- 'Status' => :reblog,
- 'Follow' => :follow,
+ 'Mention' => :mention,
+ 'Status' => :reblog,
+ 'Follow' => :follow,
'FollowRequest' => :follow_request,
- 'Favourite' => :favourite,
- 'Poll' => :poll,
+ 'Favourite' => :favourite,
+ 'Poll' => :poll,
}.freeze
def up
M db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb => db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1]
M db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb => db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1]
M db/post_migrate/20221101190723_backfill_admin_action_logs.rb => db/post_migrate/20221101190723_backfill_admin_action_logs.rb +13 -0
@@ 79,11 79,13 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
safety_assured do
AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log|
next if log.account.nil?
+
log.update_attribute('human_identifier', log.account.acct)
end
AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log|
next if log.user.nil?
+
log.update_attribute('human_identifier', log.user.account.acct)
log.update_attribute('route_param', log.user.account_id)
end
@@ 92,57 94,68 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
next if log.domain_block.nil?
+
log.update_attribute('human_identifier', log.domain_block.domain)
end
AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log|
next if log.domain_allow.nil?
+
log.update_attribute('human_identifier', log.domain_allow.domain)
end
AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log|
next if log.email_domain_block.nil?
+
log.update_attribute('human_identifier', log.email_domain_block.domain)
end
AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log|
next if log.unavailable_domain.nil?
+
log.update_attribute('human_identifier', log.unavailable_domain.domain)
end
AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log|
next if log.status.nil?
+
log.update_attribute('human_identifier', log.status.account.acct)
log.update_attribute('permalink', log.status.uri)
end
AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log|
next if log.account_warning.nil?
+
log.update_attribute('human_identifier', log.account_warning.account.acct)
end
AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log|
next if log.announcement.nil?
+
log.update_attribute('human_identifier', log.announcement.text)
end
AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log|
next if log.ip_block.nil?
+
log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}")
end
AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log|
next if log.custom_emoji.nil?
+
log.update_attribute('human_identifier', log.custom_emoji.shortcode)
end
AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log|
next if log.canonical_email_block.nil?
+
log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash)
end
AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log|
next if log.appeal.nil?
+
log.update_attribute('human_identifier', log.appeal.account.acct)
log.update_attribute('route_param', log.appeal.account_warning_id)
end
M db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb => db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb +13 -0
@@ 79,11 79,13 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
safety_assured do
AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log|
next if log.account.nil?
+
log.update_attribute('human_identifier', log.account.acct)
end
AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log|
next if log.user.nil?
+
log.update_attribute('human_identifier', log.user.account.acct)
log.update_attribute('route_param', log.user.account_id)
end
@@ 92,57 94,68 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
next if log.domain_block.nil?
+
log.update_attribute('human_identifier', log.domain_block.domain)
end
AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log|
next if log.domain_allow.nil?
+
log.update_attribute('human_identifier', log.domain_allow.domain)
end
AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log|
next if log.email_domain_block.nil?
+
log.update_attribute('human_identifier', log.email_domain_block.domain)
end
AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log|
next if log.unavailable_domain.nil?
+
log.update_attribute('human_identifier', log.unavailable_domain.domain)
end
AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log|
next if log.status.nil?
+
log.update_attribute('human_identifier', log.status.account.acct)
log.update_attribute('permalink', log.status.uri)
end
AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log|
next if log.account_warning.nil?
+
log.update_attribute('human_identifier', log.account_warning.account.acct)
end
AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log|
next if log.announcement.nil?
+
log.update_attribute('human_identifier', log.announcement.text)
end
AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log|
next if log.ip_block.nil?
+
log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}")
end
AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log|
next if log.custom_emoji.nil?
+
log.update_attribute('human_identifier', log.custom_emoji.shortcode)
end
AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log|
next if log.canonical_email_block.nil?
+
log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash)
end
AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log|
next if log.appeal.nil?
+
log.update_attribute('human_identifier', log.appeal.account.acct)
log.update_attribute('route_param', log.appeal.account_warning_id)
end
M lib/mastodon/domains_cli.rb => lib/mastodon/domains_cli.rb +2 -0
@@ 148,6 148,7 @@ module Mastodon
begin
Request.new(:get, "https://#{domain}/api/v1/instance").perform do |res|
next unless res.code == 200
+
stats[domain] = Oj.load(res.to_s)
end
@@ 161,6 162,7 @@ module Mastodon
Request.new(:get, "https://#{domain}/api/v1/instance/activity").perform do |res|
next unless res.code == 200
+
stats[domain]['activity'] = Oj.load(res.to_s)
end
rescue StandardError
M lib/sanitize_ext/sanitize_config.rb => lib/sanitize_ext/sanitize_config.rb +6 -6
@@ 72,7 72,7 @@ class Sanitize
elements: %w(p br span a),
attributes: {
- 'a' => %w(href rel class),
+ 'a' => %w(href rel class),
'span' => %w(class),
},
@@ 98,17 98,17 @@ class Sanitize
attributes: merge(
RELAXED[:attributes],
- 'audio' => %w(controls),
- 'embed' => %w(height src type width),
+ 'audio' => %w(controls),
+ 'embed' => %w(height src type width),
'iframe' => %w(allowfullscreen frameborder height scrolling src width),
'source' => %w(src type),
- 'video' => %w(controls height loop width),
- 'div' => [:data]
+ 'video' => %w(controls height loop width),
+ 'div' => [:data]
),
protocols: merge(
RELAXED[:protocols],
- 'embed' => { 'src' => HTTP_PROTOCOLS },
+ 'embed' => { 'src' => HTTP_PROTOCOLS },
'iframe' => { 'src' => HTTP_PROTOCOLS },
'source' => { 'src' => HTTP_PROTOCOLS }
)
M lib/tasks/auto_annotate_models.rake => lib/tasks/auto_annotate_models.rake +35 -35
@@ 3,42 3,42 @@
if Rails.env.development?
task :set_annotation_options do
Annotate.set_defaults(
- 'routes' => 'false',
- 'models' => 'true',
- 'position_in_routes' => 'before',
- 'position_in_class' => 'before',
- 'position_in_test' => 'before',
- 'position_in_fixture' => 'before',
- 'position_in_factory' => 'before',
- 'position_in_serializer' => 'before',
- 'show_foreign_keys' => 'false',
- 'show_indexes' => 'false',
- 'simple_indexes' => 'false',
- 'model_dir' => 'app/models',
- 'root_dir' => '',
- 'include_version' => 'false',
- 'require' => '',
- 'exclude_tests' => 'true',
- 'exclude_fixtures' => 'true',
- 'exclude_factories' => 'true',
- 'exclude_serializers' => 'true',
- 'exclude_scaffolds' => 'true',
- 'exclude_controllers' => 'true',
- 'exclude_helpers' => 'true',
- 'ignore_model_sub_dir' => 'false',
- 'ignore_columns' => nil,
- 'ignore_routes' => nil,
- 'ignore_unknown_models' => 'false',
+ 'routes' => 'false',
+ 'models' => 'true',
+ 'position_in_routes' => 'before',
+ 'position_in_class' => 'before',
+ 'position_in_test' => 'before',
+ 'position_in_fixture' => 'before',
+ 'position_in_factory' => 'before',
+ 'position_in_serializer' => 'before',
+ 'show_foreign_keys' => 'false',
+ 'show_indexes' => 'false',
+ 'simple_indexes' => 'false',
+ 'model_dir' => 'app/models',
+ 'root_dir' => '',
+ 'include_version' => 'false',
+ 'require' => '',
+ 'exclude_tests' => 'true',
+ 'exclude_fixtures' => 'true',
+ 'exclude_factories' => 'true',
+ 'exclude_serializers' => 'true',
+ 'exclude_scaffolds' => 'true',
+ 'exclude_controllers' => 'true',
+ 'exclude_helpers' => 'true',
+ 'ignore_model_sub_dir' => 'false',
+ 'ignore_columns' => nil,
+ 'ignore_routes' => nil,
+ 'ignore_unknown_models' => 'false',
'hide_limit_column_types' => 'integer,boolean',
- 'skip_on_db_migrate' => 'false',
- 'format_bare' => 'true',
- 'format_rdoc' => 'false',
- 'format_markdown' => 'false',
- 'sort' => 'false',
- 'force' => 'false',
- 'trace' => 'false',
- 'wrapper_open' => nil,
- 'wrapper_close' => nil
+ 'skip_on_db_migrate' => 'false',
+ 'format_bare' => 'true',
+ 'format_rdoc' => 'false',
+ 'format_markdown' => 'false',
+ 'sort' => 'false',
+ 'force' => 'false',
+ 'trace' => 'false',
+ 'wrapper_open' => nil,
+ 'wrapper_close' => nil
)
end
M lib/tasks/mastodon.rake => lib/tasks/mastodon.rake +8 -8
@@ 399,14 399,14 @@ namespace :mastodon do
end
ActionMailer::Base.smtp_settings = {
- port: env['SMTP_PORT'],
- address: env['SMTP_SERVER'],
- user_name: env['SMTP_LOGIN'].presence,
- password: env['SMTP_PASSWORD'].presence,
- domain: env['LOCAL_DOMAIN'],
- authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain,
- openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'],
- enable_starttls: enable_starttls,
+ port: env['SMTP_PORT'],
+ address: env['SMTP_SERVER'],
+ user_name: env['SMTP_LOGIN'].presence,
+ password: env['SMTP_PASSWORD'].presence,
+ domain: env['LOCAL_DOMAIN'],
+ authentication: env['SMTP_AUTH_METHOD'] == 'none' ? nil : env['SMTP_AUTH_METHOD'] || :plain,
+ openssl_verify_mode: env['SMTP_OPENSSL_VERIFY_MODE'],
+ enable_starttls: enable_starttls,
enable_starttls_auto: enable_starttls_auto,
}
M spec/controllers/api/v1/accounts/statuses_controller_spec.rb => spec/controllers/api/v1/accounts/statuses_controller_spec.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require 'rails_helper'
describe Api::V1::Accounts::StatusesController do
M spec/models/admin/account_action_spec.rb => spec/models/admin/account_action_spec.rb +2 -2
@@ 12,9 12,9 @@ RSpec.describe Admin::AccountAction, type: :model do
before do
account_action.assign_attributes(
- type: type,
+ type: type,
current_account: account,
- target_account: target_account
+ target_account: target_account
)
end
M spec/models/concerns/account_interactions_spec.rb => spec/models/concerns/account_interactions_spec.rb +2 -2
@@ 149,8 149,8 @@ describe AccountInteractions do
let(:mute) do
Fabricate(:mute,
- account: account,
- target_account: target_account,
+ account: account,
+ target_account: target_account,
hide_notifications: hide_notifications)
end
M spec/models/tag_spec.rb => spec/models/tag_spec.rb +1 -0
@@ 1,4 1,5 @@
# frozen_string_literal: true
+
require 'rails_helper'
RSpec.describe Tag do