OpenSourcePolitics / decidim-app

Open Source Politics' Decidim reference implementation
GNU Affero General Public License v3.0
9 stars 12 forks source link

must work with image src #386

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

@param [String] deprecated_endpoint

https://api.github.com/OpenSourcePolitics/decidim-app/blob/dd254bd654e0302552aa13df0ef5e7c3baf83464/app/services/decidim/repair_url_in_content_service.rb#L17


# frozen_string_literal: true

module Decidim
  # Looks for any occurence of "@deprecated_endpoint" in every database columns of type COLUMN_TYPES
  # For each field containing @deprecated_endpoint:
  #   - Looks for the current ActiveStorage::Blob with the given filename
  #   - Find the blob's service_url
  #   - Replace the @deprecated_endpoint with the blob's service_url in text
  #   - Update the column
  # Context:
  # After S3 assets migration with rake task "bundle exec rake scaleway:storage:migrate_from_local", every linked documents URL were well updated.
  # However every links added to text fields redirecting to an uploaded file were outdated and still redirects to the old S3 bucket
  class RepairUrlInContentService
    COLUMN_TYPES = [:string, :jsonb, :text].freeze
    DEFAULT_LOGGER = Rails.logger

    # TODO: must work with image src
    # @param [String] deprecated_endpoint
    def self.run(deprecated_endpoint)
      new(deprecated_endpoint).run
    end

    # @param [String] deprecated_endpoint
    def initialize(deprecated_endpoint, logger = nil)
      @logger = logger || DEFAULT_LOGGER
      @deprecated_endpoint = deprecated_endpoint
    end

    def run
github-actions[bot] commented 1 year ago

Closed in 8b75a651d0e0cac1db253fee046bab238bdb78e3