From db57bff11d6a9e101d8aa0adc635367365c83901 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 13 Sep 2021 18:59:37 +0200 Subject: Stop setting a shortcode to newly-created media attachments (#16730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Stop setting a shortcode to newly-created media attachments The WebUI has stopped using the “short media URL” in ages. This isn't used anywhere except for mail notifications. Deprecating it would allow us to eventually get rid of at least a database column and corruption-prone index, as well as a controller. * Fix tests --- app/models/media_attachment.rb | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'app/models') diff --git a/app/models/media_attachment.rb b/app/models/media_attachment.rb index 3515f6895..66d800b7b 100644 --- a/app/models/media_attachment.rb +++ b/app/models/media_attachment.rb @@ -255,7 +255,7 @@ class MediaAttachment < ApplicationRecord after_commit :reset_parent_cache, on: :update before_create :prepare_description, unless: :local? - before_create :set_shortcode + before_create :set_unknown_type before_create :set_processing after_post_process :set_meta @@ -298,15 +298,8 @@ class MediaAttachment < ApplicationRecord private - def set_shortcode + def set_unknown_type self.type = :unknown if file.blank? && !type_changed? - - return unless local? - - loop do - self.shortcode = SecureRandom.urlsafe_base64(14) - break if MediaAttachment.find_by(shortcode: shortcode).nil? - end end def prepare_description -- cgit