From 778b37790b425debd16b73c21f0805ff2e9a4ce8 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Sun, 4 Mar 2018 18:00:46 +0900 Subject: Do not fetch environment variables to determine default locale (#6618) The default locale is now set by config. --- lib/tasks/assets.rake | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 0826f0186..b642510a1 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -1,10 +1,8 @@ # frozen_string_literal: true def render_static_page(action, dest:, **opts) - I18n.with_locale(ENV['DEFAULT_LOCALE'] || I18n.default_locale) do - html = ApplicationController.render(action, opts) - File.write(dest, html) - end + html = ApplicationController.render(action, opts) + File.write(dest, html) end namespace :assets do -- cgit From 78d772af862c536b2e985977b6ba549efe668fe0 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 6 Mar 2018 06:29:01 +0100 Subject: Fix #3807: Increase avatars to 400x400 max (#6651) But do not upscale when they are smaller --- app/models/concerns/account_avatar.rb | 4 ++-- lib/paperclip/lazy_thumbnail.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/app/models/concerns/account_avatar.rb b/app/models/concerns/account_avatar.rb index 7712a29fd..9e34a9461 100644 --- a/app/models/concerns/account_avatar.rb +++ b/app/models/concerns/account_avatar.rb @@ -7,8 +7,8 @@ module AccountAvatar class_methods do def avatar_styles(file) - styles = { original: { geometry: '120x120#', file_geometry_parser: FastGeometryParser } } - styles[:static] = { geometry: '120x120#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif' + styles = { original: { geometry: '400x400#', file_geometry_parser: FastGeometryParser } } + styles[:static] = { geometry: '400x400#', format: 'png', convert_options: '-coalesce', file_geometry_parser: FastGeometryParser } if file.content_type == 'image/gif' styles end diff --git a/lib/paperclip/lazy_thumbnail.rb b/lib/paperclip/lazy_thumbnail.rb index 42f9a557a..aafa21343 100644 --- a/lib/paperclip/lazy_thumbnail.rb +++ b/lib/paperclip/lazy_thumbnail.rb @@ -4,6 +4,10 @@ module Paperclip class LazyThumbnail < Paperclip::Thumbnail def make return File.open(@file.path) unless needs_convert? + + min_side = [@current_geometry.width, @current_geometry.height].min + options[:geometry] = "#{min_side.to_i}x#{min_side.to_i}#" if @target_geometry.square? && min_side < @target_geometry.width + Paperclip::Thumbnail.make(file, options, attachment) end -- cgit From 4ca60c665e02103b8730748c9b82b52bcd0d8d1c Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 7 Mar 2018 12:06:23 +0100 Subject: Bump version to 2.3.0rc2 --- lib/mastodon/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 4150b39b6..418ce4828 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -21,7 +21,7 @@ module Mastodon end def flags - 'rc1' + 'rc2' end def to_a -- cgit From 64db9ed5f6c8ff826104b3294956416d08d7a135 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 8 Mar 2018 06:59:42 +0100 Subject: After blocking domain with reject_media, invalidate cache (#6679) Media attachments are part of the association cache of statuses, since they are presumed to be immutable. Unless this cache is cleared manually, the statuses will continue to look like they have media embedded. --- app/services/block_domain_service.rb | 37 +++++++++++++++++++++++++----------- lib/tasks/mastodon.rake | 8 ++++---- 2 files changed, 30 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/app/services/block_domain_service.rb b/app/services/block_domain_service.rb index eefdc0dbf..d082de40b 100644 --- a/app/services/block_domain_service.rb +++ b/app/services/block_domain_service.rb @@ -5,13 +5,14 @@ class BlockDomainService < BaseService def call(domain_block) @domain_block = domain_block - process_domain_block + process_domain_block! end private - def process_domain_block + def process_domain_block! clear_media! if domain_block.reject_media? + if domain_block.silence? silence_accounts! elsif domain_block.suspend? @@ -19,14 +20,26 @@ class BlockDomainService < BaseService end end + def invalidate_association_caches! + # Normally, associated models of a status are immutable (except for accounts) + # so they are aggressively cached. After updating the media attachments to no + # longer point to a local file, we need to clear the cache to make those + # changes appear in the API and UI + @affected_status_ids.each { |id| Rails.cache.delete_matched("statuses/#{id}-*") } + end + def silence_accounts! blocked_domain_accounts.in_batches.update_all(silenced: true) end def clear_media! - clear_account_images - clear_account_attachments - clear_emojos + @affected_status_ids = [] + + clear_account_images! + clear_account_attachments! + clear_emojos! + + invalidate_association_caches! end def suspend_accounts! @@ -36,23 +49,25 @@ class BlockDomainService < BaseService end end - def clear_account_images + def clear_account_images! blocked_domain_accounts.find_each do |account| - account.avatar.destroy - account.header.destroy + account.avatar.destroy if account.avatar.exists? + account.header.destroy if account.header.exists? account.save end end - def clear_account_attachments + def clear_account_attachments! media_from_blocked_domain.find_each do |attachment| - attachment.file.destroy + @affected_status_ids << attachment.status_id if attachment.status_id.present? + + attachment.file.destroy if attachment.file.exists? attachment.type = :unknown attachment.save end end - def clear_emojos + def clear_emojos! emojis_from_blocked_domains.destroy_all end diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 9202b4839..0b011bf57 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -476,10 +476,10 @@ namespace :mastodon do time_ago = ENV.fetch('NUM_DAYS') { 7 }.to_i.days.ago MediaAttachment.where.not(remote_url: '').where.not(file_file_name: nil).where('created_at < ?', time_ago).find_each do |media| - if media.file.exists? - media.file.destroy - media.save - end + next unless media.file.exists? + + media.file.destroy + media.save end end -- cgit From bd077ad7d9633a4ef1415aa123c7ecf54e829ae8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 8 Mar 2018 11:19:02 +0100 Subject: Bump version to 2.3.0rc3 --- lib/mastodon/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 418ce4828..9155702ac 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -21,7 +21,7 @@ module Mastodon end def flags - 'rc2' + 'rc3' end def to_a -- cgit