about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-05-17 10:30:34 +0200
committerClaire <claire.github-309c@sitedethib.com>2021-05-17 10:30:34 +0200
commit69737b703ab1d9b9e49315f12c3aca8cf6df70ac (patch)
treefd533bcafe02475fbc19681cc764d75fe6f16e12 /lib
parent678e07c54485c6cc61b2ac18aa5ceaa290a6fcbd (diff)
parent4c7efdba402b6b8ee0363b6f1dc2c202303d7623 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `README.md`: our READMEs are entirely different and
  upstream's has been updated. Kept our README.
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/maintenance_cli.rb16
-rw-r--r--lib/mastodon/version.rb2
-rw-r--r--lib/tasks/repo.rake59
3 files changed, 66 insertions, 11 deletions
diff --git a/lib/mastodon/maintenance_cli.rb b/lib/mastodon/maintenance_cli.rb
index 9f1eaf263..8e2084e33 100644
--- a/lib/mastodon/maintenance_cli.rb
+++ b/lib/mastodon/maintenance_cli.rb
@@ -14,7 +14,7 @@ module Mastodon
     end
 
     MIN_SUPPORTED_VERSION = 2019_10_01_213028
-    MAX_SUPPORTED_VERSION = 2021_03_08_133107
+    MAX_SUPPORTED_VERSION = 2021_05_07_001928
 
     # Stubs to enjoy ActiveRecord queries while not depending on a particular
     # version of the code/database
@@ -42,6 +42,8 @@ module Mastodon
     class CustomEmojiCategory < ApplicationRecord; end
     class Bookmark < ApplicationRecord; end
     class WebauthnCredential < ApplicationRecord; end
+    class FollowRecommendationSuppression < ApplicationRecord; end
+    class CanonicalEmailBlock < ApplicationRecord; end
 
     class PreviewCard < ApplicationRecord
       self.inheritance_column = false
@@ -88,6 +90,7 @@ module Mastodon
         ]
         owned_classes << AccountDeletionRequest if ActiveRecord::Base.connection.table_exists?(:account_deletion_requests)
         owned_classes << AccountNote if ActiveRecord::Base.connection.table_exists?(:account_notes)
+        owned_classes << FollowRecommendationSuppression if ActiveRecord::Base.connection.table_exists?(:follow_recommendation_suppressions)
 
         owned_classes.each do |klass|
           klass.where(account_id: other_account.id).find_each do |record|
@@ -111,6 +114,12 @@ module Mastodon
             end
           end
         end
+
+        if ActiveRecord::Base.connection.table_exists?(:canonical_email_blocks)
+          CanonicalEmailBlock.where(reference_account_id: other_account.id).find_each do |record|
+            record.update_attribute(:reference_account_id, id)
+          end
+        end
       end
     end
 
@@ -466,6 +475,11 @@ module Mastodon
 
       @prompt.say 'Restoring tags indexes…'
       ActiveRecord::Base.connection.add_index :tags, 'lower((name)::text)', name: 'index_tags_on_name_lower', unique: true
+
+      if ActiveRecord::Base.connection.indexes(:tags).any? { |i| i.name == 'index_tags_on_name_lower_btree' }
+        @prompt.say 'Reindexing textual indexes on tags…'
+        ActiveRecord::Base.connection.execute('REINDEX INDEX index_tags_on_name_lower_btree;')
+      end
     end
 
     def deduplicate_webauthn_credentials!
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
index 6a79453f1..ff0e694b7 100644
--- a/lib/mastodon/version.rb
+++ b/lib/mastodon/version.rb
@@ -17,7 +17,7 @@ module Mastodon
     end
 
     def flags
-      'rc2'
+      ''
     end
 
     def suffix
diff --git a/lib/tasks/repo.rake b/lib/tasks/repo.rake
index d1de17b7c..86c358a94 100644
--- a/lib/tasks/repo.rake
+++ b/lib/tasks/repo.rake
@@ -1,27 +1,34 @@
 # frozen_string_literal: true
 
+REPOSITORY_NAME = 'tootsuite/mastodon'
+
 namespace :repo do
   desc 'Generate the AUTHORS.md file'
   task :authors do
     file = File.open(Rails.root.join('AUTHORS.md'), 'w')
+
     file << <<~HEADER
       Authors
       =======
 
-      Mastodon is available on [GitHub](https://github.com/tootsuite/mastodon)
+      Mastodon is available on [GitHub](https://github.com/#{REPOSITORY_NAME})
       and provided thanks to the work of the following contributors:
 
     HEADER
 
-    url = 'https://api.github.com/repos/tootsuite/mastodon/contributors?anon=1'
+    url = "https://api.github.com/repos/#{REPOSITORY_NAME}/contributors?anon=1"
+
     HttpLog.config.compact_log = true
+
     while url.present?
-      response = HTTP.get(url)
+      response     = HTTP.get(url)
       contributors = Oj.load(response.body)
+
       contributors.each do |c|
         file << "* [#{c['login']}](#{c['html_url']})\n" if c['login']
         file << "* [#{c['name']}](mailto:#{c['email']})\n" if c['name']
       end
+
       url = LinkHeader.parse(response.headers['Link']).find_link(%w(rel next))&.href
     end
 
@@ -47,7 +54,7 @@ namespace :repo do
               response = nil
 
               loop do
-                response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/tootsuite/mastodon/pulls/#{pull_request_number}")
+                response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/#{REPOSITORY_NAME}/pulls/#{pull_request_number}")
 
                 if response.code == 403
                   sleep_for = (response.headers['X-RateLimit-Reset'].to_i - Time.now.to_i).abs
@@ -83,12 +90,46 @@ namespace :repo do
     missing_yaml_files = I18n.available_locales.reject { |locale| File.exist?(Rails.root.join('config', 'locales', "#{locale}.yml")) }
     missing_json_files = I18n.available_locales.reject { |locale| File.exist?(Rails.root.join('app', 'javascript', 'mastodon', 'locales', "#{locale}.json")) }
 
-    if missing_json_files.empty? && missing_yaml_files.empty?
-      puts pastel.green('OK')
-    else
-      puts pastel.red("Missing YAML files: #{pastel.bold(missing_yaml_files.join(', '))}") unless missing_yaml_files.empty?
-      puts pastel.red("Missing JSON files: #{pastel.bold(missing_json_files.join(', '))}") unless missing_json_files.empty?
+    locales_in_files = Dir[Rails.root.join('config', 'locales', '*.yml')].map do |path|
+      file_name = File.basename(path)
+      file_name.gsub(/\A(doorkeeper|devise|activerecord|simple_form)\./, '').gsub(/\.yml\z/, '').to_sym
+    end.uniq.compact
+
+    missing_available_locales = locales_in_files - I18n.available_locales
+    missing_locale_names = I18n.available_locales.reject { |locale| SettingsHelper::HUMAN_LOCALES.key?(locale) }
+
+    critical = false
+
+    unless missing_json_files.empty?
+      critical = true
+
+      puts pastel.red("You are missing JSON files for these locales: #{pastel.bold(missing_json_files.join(', '))}")
+      puts pastel.red('This will lead to runtime errors for users who have selected those locales')
+      puts pastel.red("Add the missing files or remove the locales from #{pastel.bold('I18n.available_locales')} in config/application.rb")
+    end
+
+    unless missing_yaml_files.empty?
+      critical = true
+
+      puts pastel.red("You are missing YAML files for these locales: #{pastel.bold(missing_yaml_files.join(', '))}")
+      puts pastel.red('This will lead to runtime errors for users who have selected those locales')
+      puts pastel.red("Add the missing files or remove the locales from #{pastel.bold('I18n.available_locales')} in config/application.rb")
+    end
+
+    unless missing_available_locales.empty?
+      puts pastel.yellow("You have locale files that are not enabled: #{pastel.bold(missing_available_locales.join(', '))}")
+      puts pastel.yellow("Add them to #{pastel.bold('I18n.available_locales')} in config/application.rb or remove them")
+    end
+
+    unless missing_locale_names.empty?
+      puts pastel.yellow("You are missing human-readable names for these locales: #{pastel.bold(missing_locale_names.join(', '))}")
+      puts pastel.yellow("Add them to #{pastel.bold('HUMAN_LOCALES')} in app/helpers/settings_helper.rb or remove the locales from #{pastel.bold('I18n.available_locales')} in config/application.rb")
+    end
+
+    if critical
       exit(1)
+    else
+      puts pastel.green('OK')
     end
   end
 end