diff --git a/Gemfile b/Gemfile index b6ecb0126d..b80621bf9d 100644 --- a/Gemfile +++ b/Gemfile @@ -88,7 +88,7 @@ gem 'sidekiq-scheduler', '~> 6.0' gem 'sidekiq-unique-jobs', '> 8' gem 'simple_form', '~> 5.2' gem 'simple-navigation', '~> 4.4' -gem 'stoplight' +gem 'stoplight', github: 'ClearlyClaire/stoplight', ref: 'f13e0c0d5e6d34af8d3cfc888871caa84237db42' gem 'strong_migrations' gem 'tty-prompt', '~> 0.23', require: false gem 'twitter-text', '~> 3.1.0' diff --git a/Gemfile.lock b/Gemfile.lock index e99d5f7cba..bc8b8396d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/ClearlyClaire/stoplight.git + revision: f13e0c0d5e6d34af8d3cfc888871caa84237db42 + ref: f13e0c0d5e6d34af8d3cfc888871caa84237db42 + specs: + stoplight (5.3.1) + zeitwerk + GIT remote: https://github.com/mastodon/webpush.git revision: 9631ac63045cfabddacc69fc06e919b4c13eb913 @@ -853,8 +861,6 @@ GEM stackprof (0.2.27) starry (0.2.0) base64 - stoplight (5.3.1) - zeitwerk stringio (3.1.7) strong_migrations (2.5.0) activerecord (>= 7.1) @@ -1086,7 +1092,7 @@ DEPENDENCIES simplecov (~> 0.22) simplecov-lcov (~> 0.8) stackprof - stoplight + stoplight! strong_migrations test-prof thor (~> 1.2) diff --git a/app/models/rule_translation.rb b/app/models/rule_translation.rb index ccf0d4ba33..fbcf55627c 100644 --- a/app/models/rule_translation.rb +++ b/app/models/rule_translation.rb @@ -22,6 +22,6 @@ class RuleTranslation < ApplicationRecord scope :by_language_length, -> { order(Arel.sql('LENGTH(LANGUAGE)').desc) } def self.languages - RuleTranslation.joins(:rule).merge(Rule.kept).select(:language).distinct.pluck(:language).sort + joins(:rule).merge(Rule.kept).distinct.pluck(:language).sort end end diff --git a/app/services/activitypub/process_status_update_service.rb b/app/services/activitypub/process_status_update_service.rb index 0da1335b5c..362be0c877 100644 --- a/app/services/activitypub/process_status_update_service.rb +++ b/app/services/activitypub/process_status_update_service.rb @@ -307,7 +307,7 @@ class ActivityPub::ProcessStatusUpdateService < BaseService @quote_changed = true else quote = @status.quote - quote.update(approval_uri: approval_uri, state: :pending, legacy: @status_parser.legacy_quote?) if quote.approval_uri != @status_parser.quote_approval_uri + quote.update(approval_uri: approval_uri, state: :pending, legacy: @status_parser.legacy_quote?) if quote.approval_uri != approval_uri end else quote = Quote.create(status: @status, approval_uri: approval_uri, legacy: @status_parser.legacy_quote?) diff --git a/app/services/activitypub/verify_quote_service.rb b/app/services/activitypub/verify_quote_service.rb index 2b10de9d9b..2badadd425 100644 --- a/app/services/activitypub/verify_quote_service.rb +++ b/app/services/activitypub/verify_quote_service.rb @@ -13,7 +13,7 @@ class ActivityPub::VerifyQuoteService < BaseService @fetching_error = nil fetch_quoted_post_if_needed!(fetchable_quoted_uri, prefetched_body: prefetched_quoted_object) - return handle_local_quote! if quote.quoted_account&.local? + return if quote.quoted_account&.local? return if fast_track_approval! || quote.approval_uri.blank? @json = fetch_approval_object(quote.approval_uri, prefetched_body: prefetched_approval) @@ -35,15 +35,6 @@ class ActivityPub::VerifyQuoteService < BaseService private - def handle_local_quote! - @quote.update!(approval_uri: nil) - if StatusPolicy.new(@quote.account, @quote.quoted_status).quote? - @quote.accept! - else - @quote.reject! - end - end - # FEP-044f defines rules that don't require the approval flow def fast_track_approval! return false if @quote.quoted_status_id.blank? diff --git a/spec/models/rule_translation_spec.rb b/spec/models/rule_translation_spec.rb index 649bd5c0e4..1a0a737504 100644 --- a/spec/models/rule_translation_spec.rb +++ b/spec/models/rule_translation_spec.rb @@ -52,4 +52,22 @@ RSpec.describe RuleTranslation do end end end + + describe '.languages' do + let(:discarded_rule) { Fabricate :rule, deleted_at: 5.days.ago } + let(:kept_rule) { Fabricate :rule } + + before do + Fabricate :rule_translation, rule: discarded_rule, language: 'en' + Fabricate :rule_translation, rule: kept_rule, language: 'es' + Fabricate :rule_translation, language: 'fr' + Fabricate :rule_translation, language: 'es' + end + + it 'returns ordered distinct languages connected to non-discarded rules' do + expect(described_class.languages) + .to be_an(Array) + .and eq(%w(es fr)) + end + end end