mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
418 B
14 lines
418 B
# frozen_string_literal: true
|
|
|
|
module EmailMessages
|
|
module_function
|
|
|
|
def find_or_create_for_account_user(account, user, subject, body)
|
|
subject = I18n.t(:you_are_invited_to_sign_a_document) if subject.blank?
|
|
|
|
message = account.email_messages.new(author: user, subject:, body:).tap(&:validate)
|
|
|
|
account.email_messages.find_by(sha1: message.sha1) || message.tap { |m| m.save!(validate: false) }
|
|
end
|
|
end
|