about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2022-11-10 08:50:11 -0600
committerStarfall <us@starfall.systems>2022-11-10 08:50:11 -0600
commit67d1a0476d77e2ed0ca15dd2981c54c2b90b0742 (patch)
tree152f8c13a341d76738e8e2c09b24711936e6af68 /lib
parentb581e6b6d4a5ba9ed4ae17427b7f2d5d158be4e5 (diff)
parentee7e49d1b1323618e16026bc8db8ab7f9459cc2d (diff)
Merge remote-tracking branch 'glitch/main'
- Remove Helm charts
- Lots of conflicts with our removal of recommended settings and custom
  icons
Diffstat (limited to 'lib')
-rw-r--r--lib/assets/wordmark.dark.pngbin8991 -> 6753 bytes
-rw-r--r--lib/assets/wordmark.light.pngbin8625 -> 6613 bytes
-rw-r--r--lib/exceptions.rb9
-rw-r--r--lib/mastodon/accounts_cli.rb6
-rw-r--r--lib/mastodon/canonical_email_blocks_cli.rb31
-rw-r--r--lib/mastodon/media_cli.rb2
-rw-r--r--lib/mastodon/search_cli.rb2
-rw-r--r--lib/mastodon/version.rb8
-rw-r--r--lib/paperclip/transcoder.rb6
-rw-r--r--lib/tasks/emojis.rake4
-rw-r--r--lib/tasks/mastodon.rake7
-rw-r--r--lib/tasks/tests.rake51
12 files changed, 83 insertions, 43 deletions
diff --git a/lib/assets/wordmark.dark.png b/lib/assets/wordmark.dark.png
index defe50178..6772b3318 100644
--- a/lib/assets/wordmark.dark.png
+++ b/lib/assets/wordmark.dark.png
Binary files differdiff --git a/lib/assets/wordmark.light.png b/lib/assets/wordmark.light.png
index d4485c0fb..6d95088a4 100644
--- a/lib/assets/wordmark.light.png
+++ b/lib/assets/wordmark.light.png
Binary files differdiff --git a/lib/exceptions.rb b/lib/exceptions.rb
index 0c677b660..3c5ba226b 100644
--- a/lib/exceptions.rb
+++ b/lib/exceptions.rb
@@ -25,4 +25,13 @@ module Mastodon
       end
     end
   end
+
+  class PrivateNetworkAddressError < HostValidationError
+    attr_reader :host
+
+    def initialize(host)
+      @host = host
+      super()
+    end
+  end
 end
diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb
index 558f4d3c4..c8a8448ed 100644
--- a/lib/mastodon/accounts_cli.rb
+++ b/lib/mastodon/accounts_cli.rb
@@ -126,6 +126,7 @@ module Mastodon
     end
 
     option :role
+    option :remove_role, type: :boolean
     option :email
     option :confirm, type: :boolean
     option :enable, type: :boolean
@@ -137,7 +138,8 @@ module Mastodon
     long_desc <<-LONG_DESC
       Modify a user account.
 
-      With the --role option, update the user's role.
+      With the --role option, update the user's role. To remove the user's
+      role, i.e. demote to normal user, use --remove-role.
 
       With the --email option, update the user's e-mail address. With
       the --confirm option, mark the user's e-mail as confirmed.
@@ -171,6 +173,8 @@ module Mastodon
         end
 
         user.role_id = role.id
+      elsif options[:remove_role]
+        user.role_id = nil
       end
 
       password = SecureRandom.hex if options[:reset_password]
diff --git a/lib/mastodon/canonical_email_blocks_cli.rb b/lib/mastodon/canonical_email_blocks_cli.rb
index 64b72e603..ec228d466 100644
--- a/lib/mastodon/canonical_email_blocks_cli.rb
+++ b/lib/mastodon/canonical_email_blocks_cli.rb
@@ -18,17 +18,15 @@ module Mastodon
       When suspending a local user, a hash of a "canonical" version of their e-mail
       address is stored to prevent them from signing up again.
 
-      This command can be used to find whether a known email address is blocked,
-      and if so, which account it was attached to.
+      This command can be used to find whether a known email address is blocked.
     LONG_DESC
     def find(email)
-      accts = CanonicalEmailBlock.find_blocks(email).map(&:reference_account).map(&:acct).to_a
+      accts = CanonicalEmailBlock.matching_email(email)
+
       if accts.empty?
-        say("#{email} is not blocked", :yellow)
+        say("#{email} is not blocked", :green)
       else
-        accts.each do |acct|
-          say(acct, :white)
-        end
+        say("#{email} is blocked", :red)
       end
     end
 
@@ -40,24 +38,13 @@ module Mastodon
       This command allows removing a canonical email block.
     LONG_DESC
     def remove(email)
-      blocks = CanonicalEmailBlock.find_blocks(email)
+      blocks = CanonicalEmailBlock.matching_email(email)
+
       if blocks.empty?
-        say("#{email} is not blocked", :yellow)
+        say("#{email} is not blocked", :green)
       else
         blocks.destroy_all
-        say("Removed canonical email block for #{email}", :green)
-      end
-    end
-
-    private
-
-    def color(processed, failed)
-      if !processed.zero? && failed.zero?
-        :green
-      elsif failed.zero?
-        :yellow
-      else
-        :red
+        say("Unblocked #{email}", :green)
       end
     end
   end
diff --git a/lib/mastodon/media_cli.rb b/lib/mastodon/media_cli.rb
index 4904cc5eb..bba4a1bd7 100644
--- a/lib/mastodon/media_cli.rb
+++ b/lib/mastodon/media_cli.rb
@@ -234,7 +234,7 @@ module Mastodon
       end
 
       if options[:days].present?
-        scope = scope.where('id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
+        scope = scope.where('media_attachments.id > ?', Mastodon::Snowflake.id_at(options[:days].days.ago, with_random: false))
       end
 
       processed, aggregate = parallelize_with_progress(scope) do |media_attachment|
diff --git a/lib/mastodon/search_cli.rb b/lib/mastodon/search_cli.rb
index b579ebc14..b206854ab 100644
--- a/lib/mastodon/search_cli.rb
+++ b/lib/mastodon/search_cli.rb
@@ -30,7 +30,7 @@ module Mastodon
       changed since the last run. Index upgrades erase index data.
 
       Even if creating or upgrading indices is not necessary, data from the
-      database will be imported into the indices, unless overriden with --no-import.
+      database will be imported into the indices, unless overridden with --no-import.
     LONG_DESC
     def deploy
       if options[:concurrency] < 1
diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb
index 75e283cce..8636fbee7 100644
--- a/lib/mastodon/version.rb
+++ b/lib/mastodon/version.rb
@@ -5,19 +5,19 @@ module Mastodon
     module_function
 
     def major
-      3
+      4
     end
 
     def minor
-      5
+      0
     end
 
     def patch
-      3
+      0
     end
 
     def flags
-      ''
+      'rc2'
     end
 
     def suffix
diff --git a/lib/paperclip/transcoder.rb b/lib/paperclip/transcoder.rb
index afd9f58ff..b3b55f82f 100644
--- a/lib/paperclip/transcoder.rb
+++ b/lib/paperclip/transcoder.rb
@@ -40,8 +40,10 @@ module Paperclip
         @output_options['f']       = 'image2'
         @output_options['vframes'] = 1
       when 'mp4'
-        @output_options['acodec'] = 'aac'
-        @output_options['strict'] = 'experimental'
+        unless eligible_to_passthrough?(metadata)
+          @output_options['acodec'] = 'aac'
+          @output_options['strict'] = 'experimental'
+        end
 
         if high_vfr?(metadata) && !eligible_to_passthrough?(metadata)
           @output_options['vsync'] = 'vfr'
diff --git a/lib/tasks/emojis.rake b/lib/tasks/emojis.rake
index d9db79940..473aee9cc 100644
--- a/lib/tasks/emojis.rake
+++ b/lib/tasks/emojis.rake
@@ -45,7 +45,7 @@ end
 namespace :emojis do
   desc 'Generate a unicode to filename mapping'
   task :generate do
-    source = 'http://www.unicode.org/Public/emoji/13.1/emoji-test.txt'
+    source = 'http://www.unicode.org/Public/emoji/14.0/emoji-test.txt'
     codes  = []
     dest   = Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_map.json')
 
@@ -69,7 +69,7 @@ namespace :emojis do
       end
     end
 
-    existence_maps = grouped_codes.map { |c| c.index_with { |cc| File.exist?(Rails.root.join('public', 'emoji', codepoints_to_filename(cc) + '.svg')) } }
+    existence_maps = grouped_codes.map { |c| c.index_with { |cc| File.exist?(Rails.root.join('public', 'emoji', "#{codepoints_to_filename(cc)}.svg")) } }
     map = {}
 
     existence_maps.each do |group|
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake
index d652468b3..80e1dcf52 100644
--- a/lib/tasks/mastodon.rake
+++ b/lib/tasks/mastodon.rake
@@ -11,7 +11,7 @@ namespace :mastodon do
     # When the application code gets loaded, it runs `lib/mastodon/redis_configuration.rb`.
     # This happens before application environment configuration and sets REDIS_URL etc.
     # These variables are then used even when REDIS_HOST etc. are changed, so clear them
-    # out so they don't interfer with our new configuration.
+    # out so they don't interfere with our new configuration.
     ENV.delete('REDIS_URL')
     ENV.delete('CACHE_REDIS_URL')
     ENV.delete('SIDEKIQ_REDIS_URL')
@@ -433,9 +433,12 @@ namespace :mastodon do
 
           password = SecureRandom.hex(16)
 
-          user = User.new(admin: true, email: email, password: password, confirmed_at: Time.now.utc, account_attributes: { username: username }, bypass_invite_request_check: true)
+          owner_role = UserRole.find_by(name: 'Owner')
+          user = User.new(email: email, password: password, confirmed_at: Time.now.utc, account_attributes: { username: username }, bypass_invite_request_check: true, role: owner_role)
           user.save(validate: false)
 
+          Setting.site_contact_username = username
+
           prompt.ok "You can login with the password: #{password}"
           prompt.warn 'You can change your password once you login.'
         end
diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake
index 65bff6a8e..96d2f7112 100644
--- a/lib/tasks/tests.rake
+++ b/lib/tasks/tests.rake
@@ -53,6 +53,41 @@ namespace :tests do
         VALUES
           (1, 2, 'test', '{ "home", "public" }', true, true, now(), now()),
           (2, 2, 'take', '{ "home" }', false, false, now(), now());
+
+        -- Orphaned admin action logs
+
+        INSERT INTO "admin_action_logs"
+          (account_id, action, target_type, target_id, created_at, updated_at)
+        VALUES
+          (1, 'destroy', 'Account', 1312, now(), now()),
+          (1, 'destroy', 'User', 1312, now(), now()),
+          (1, 'destroy', 'Report', 1312, now(), now()),
+          (1, 'destroy', 'DomainBlock', 1312, now(), now()),
+          (1, 'destroy', 'EmailDomainBlock', 1312, now(), now()),
+          (1, 'destroy', 'Status', 1312, now(), now()),
+          (1, 'destroy', 'CustomEmoji', 1312, now(), now());
+
+        -- Admin action logs with linked objects
+
+        INSERT INTO "domain_blocks"
+          (id, domain, created_at, updated_at)
+        VALUES
+          (1, 'example.org', now(), now());
+
+        INSERT INTO "email_domain_blocks"
+          (id, domain, created_at, updated_at)
+        VALUES
+          (1, 'example.org', now(), now());
+
+        INSERT INTO "admin_action_logs"
+          (account_id, action, target_type, target_id, created_at, updated_at)
+        VALUES
+          (1, 'destroy', 'Account', 1, now(), now()),
+          (1, 'destroy', 'User', 1, now(), now()),
+          (1, 'destroy', 'DomainBlock', 1312, now(), now()),
+          (1, 'destroy', 'EmailDomainBlock', 1312, now(), now()),
+          (1, 'destroy', 'Status', 1, now(), now()),
+          (1, 'destroy', 'CustomEmoji', 3, now(), now());
       SQL
     end
 
@@ -207,18 +242,18 @@ namespace :tests do
         -- custom emoji
 
         INSERT INTO "custom_emojis"
-          (shortcode, created_at, updated_at)
+          (id, shortcode, created_at, updated_at)
         VALUES
-          ('test', now(), now()),
-          ('Test', now(), now()),
-          ('blobcat', now(), now());
+          (1, 'test', now(), now()),
+          (2, 'Test', now(), now()),
+          (3, 'blobcat', now(), now());
 
         INSERT INTO "custom_emojis"
-          (shortcode, domain, uri, created_at, updated_at)
+          (id, shortcode, domain, uri, created_at, updated_at)
         VALUES
-          ('blobcat', 'remote.org', 'https://remote.org/emoji/blobcat', now(), now()),
-          ('blobcat', 'Remote.org', 'https://remote.org/emoji/blobcat', now(), now()),
-          ('Blobcat', 'remote.org', 'https://remote.org/emoji/Blobcat', now(), now());
+          (4, 'blobcat', 'remote.org', 'https://remote.org/emoji/blobcat', now(), now()),
+          (5, 'blobcat', 'Remote.org', 'https://remote.org/emoji/blobcat', now(), now()),
+          (6, 'Blobcat', 'remote.org', 'https://remote.org/emoji/Blobcat', now(), now());
 
         -- favourites