summaryrefslogtreecommitdiff
path: root/lib/gitlab/background_migration/redact_links/redactable.rb
blob: baab34221f16aac694384d3ce2adf1046623ec76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true
# rubocop:disable Style/Documentation

module Gitlab
  module BackgroundMigration
    class RedactLinks
      module Redactable
        extend ActiveSupport::Concern

        def redact_field!(field)
          self[field].gsub!(%r{/sent_notifications/\h{32}/unsubscribe}, '/sent_notifications/REDACTED/unsubscribe')

          if self.changed?
            self.update_columns(field => self[field],
                                "#{field}_html" => nil)
          end
        end
      end
    end
  end
end