File tree 1 file changed +11
-0
lines changed
1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ class Submitter < ApplicationRecord
55
55
has_many_attached :attachments
56
56
has_many_attached :preview_documents
57
57
has_many :template_accesses , through : :template
58
+ has_many :email_events , as : :emailable , dependent : ( Docuseal . multitenant? ? nil : :destroy )
58
59
59
60
has_many :document_generation_events , dependent : :destroy
60
61
has_many :submission_events , dependent : :destroy
@@ -63,6 +64,8 @@ class Submitter < ApplicationRecord
63
64
64
65
scope :completed , -> { where . not ( completed_at : nil ) }
65
66
67
+ after_destroy :anonymize_email_events , if : -> { Docuseal . multitenant? }
68
+
66
69
def status
67
70
if declined_at?
68
71
'declined'
@@ -108,4 +111,12 @@ def with_signature_fields?
108
111
fields . any? { |f | f [ 'submitter_uuid' ] == uuid && signature_field_types . include? ( f [ 'type' ] ) }
109
112
end
110
113
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
111
122
end
You can’t perform that action at this time.
0 commit comments