Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callbacks and deliver short circuiting #72

Merged
merged 2 commits into from
Aug 15, 2022
Merged

Callbacks and deliver short circuiting #72

merged 2 commits into from
Aug 15, 2022

Conversation

jwoertink
Copy link
Member

Fixes #65
Fixes #61

This PR allows you to setup before/after callbacks when sending an email as well as short circuiting an email from being delivered.

class FriendIsLiveEmail < BaseEmail
  def initialize(@recipient : Carbon::Emailable, @friend : User)
  end

  before_send do
    if !@recipient.wants_email_from_friend?(@friend)
      self.deliverable = false
    end
  end

  after_send do |response|
     MarkEmailAsRecentlySent.run(self, sent_at: Time.utc)
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding before/after hooks for emails Short circuit email sending
2 participants