docbrown/app/models/email_message.rb
Josh Puetz f6dc638190
Upgrade to Ahoy 2.0.x (#13085)
* First set of changes for Ahoy 2.0

* Fix line length

* Change test

* Remove unused test

* Remove ahoy_messages.opened_at

* Simply digest email sending calculation to not rely on last_opened

* Remove outdated comment

* Fix typo in test

* Rework site config email digest to a single value

* Fix merge duplication

* Remove UTM references from ahoy emails

* Fix credits tests

* Remove UTM from expected email params
2021-04-06 10:12:32 -05:00

17 lines
676 B
Ruby

class EmailMessage < Ahoy::Message
belongs_to :feedback_message, optional: true
# So far this is mostly used to be compatible with administrate gem,
# which doesn't seem to play nicely with namespaces. But there could be other
# reasons to define behavior here, similar to how we use the Tag model.
def body_html_content
doctype_index = content.index("<!DOCTYPE")
closing_body_index = content.index("</body>") + 6
content[doctype_index..closing_body_index]
end
def self.find_for_reports(feedback_message_ids)
select(:to, :subject, :content, :utm_campaign, :feedback_message_id)
.where(feedback_message_id: feedback_message_ids)
end
end