From 1ec2327652498b62ab7c61f763c167286b261da2 Mon Sep 17 00:00:00 2001 From: robcolbert Date: Wed, 3 Jul 2019 20:20:14 -0400 Subject: [PATCH] move --- .../rest/media_attachment_serializer.rb | 4 +- lib/tasks/media_attachment_serializer.rb | 49 ------------------- 2 files changed, 2 insertions(+), 51 deletions(-) delete mode 100644 lib/tasks/media_attachment_serializer.rb diff --git a/app/serializers/rest/media_attachment_serializer.rb b/app/serializers/rest/media_attachment_serializer.rb index 33ec661d..7853ebf8 100644 --- a/app/serializers/rest/media_attachment_serializer.rb +++ b/app/serializers/rest/media_attachment_serializer.rb @@ -13,7 +13,7 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer def url if object.file_file_name and object.file_file_name.start_with? "gab://media/" - return object.file_file_name.sub("gab://media/", "").split("|")[1] + return object.file_file_name.sub("gab://media/", "").sub("https://gabfiles.blob.core.windows.net/", "https://gab.com/media/").sub("https://files.gab.com/file/files-gab/", "https://gab.com/media/").split("|")[1] end if object.needs_redownload? @@ -29,7 +29,7 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer def preview_url if object.file_file_name and object.file_file_name.start_with? "gab://media/" - return object.file_file_name.sub("gab://media/", "").split("|")[0] + return object.file_file_name.sub("gab://media/", "").sub("https://gabfiles.blob.core.windows.net/", "https://gab.com/media/").sub("https://files.gab.com/file/files-gab/", "https://gab.com/media/").split("|")[0] end if object.needs_redownload? diff --git a/lib/tasks/media_attachment_serializer.rb b/lib/tasks/media_attachment_serializer.rb deleted file mode 100644 index 7853ebf8..00000000 --- a/lib/tasks/media_attachment_serializer.rb +++ /dev/null @@ -1,49 +0,0 @@ -# frozen_string_literal: true - -class REST::MediaAttachmentSerializer < ActiveModel::Serializer - include RoutingHelper - - attributes :id, :type, :url, :preview_url, - :remote_url, :text_url, :meta, - :description, :blurhash - - def id - object.id.to_s - end - - def url - if object.file_file_name and object.file_file_name.start_with? "gab://media/" - return object.file_file_name.sub("gab://media/", "").sub("https://gabfiles.blob.core.windows.net/", "https://gab.com/media/").sub("https://files.gab.com/file/files-gab/", "https://gab.com/media/").split("|")[1] - end - - if object.needs_redownload? - media_proxy_url(object.id, :original) - else - full_asset_url(object.file.url(:original)) - end - end - - def remote_url - object.remote_url.presence - end - - def preview_url - if object.file_file_name and object.file_file_name.start_with? "gab://media/" - return object.file_file_name.sub("gab://media/", "").sub("https://gabfiles.blob.core.windows.net/", "https://gab.com/media/").sub("https://files.gab.com/file/files-gab/", "https://gab.com/media/").split("|")[0] - end - - if object.needs_redownload? - media_proxy_url(object.id, :small) - else - full_asset_url(object.file.url(:small)) - end - end - - def text_url - object.local? ? medium_url(object) : nil - end - - def meta - object.file.meta - end -end