Skip to content

Commit 4116746

Browse files
committed
destroy email events
1 parent b2b2856 commit 4116746

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/models/submitter.rb

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class Submitter < ApplicationRecord
5555
has_many_attached :attachments
5656
has_many_attached :preview_documents
5757
has_many :template_accesses, through: :template
58+
has_many :email_events, as: :emailable, dependent: (Docuseal.multitenant? ? nil : :destroy)
5859

5960
has_many :document_generation_events, dependent: :destroy
6061
has_many :submission_events, dependent: :destroy
@@ -63,6 +64,8 @@ class Submitter < ApplicationRecord
6364

6465
scope :completed, -> { where.not(completed_at: nil) }
6566

67+
after_destroy :anonymize_email_events, if: -> { Docuseal.multitenant? }
68+
6669
def status
6770
if declined_at?
6871
'declined'
@@ -108,4 +111,12 @@ def with_signature_fields?
108111
fields.any? { |f| f['submitter_uuid'] == uuid && signature_field_types.include?(f['type']) }
109112
end
110113
end
114+
115+
private
116+
117+
def anonymize_email_events
118+
email_events.each do |event|
119+
event.update!(email: Digest::MD5.base64digest(event.email))
120+
end
121+
end
111122
end

0 commit comments

Comments
 (0)