Skip to content

Commit

Permalink
Merge pull request #1188 from fatfreecrm/deliver_later
Browse files Browse the repository at this point in the history
Schedule emails to deliver asynchronously
  • Loading branch information
CloCkWeRX authored Oct 28, 2023
2 parents 3e4ab48 + 923d429 commit 92bebce
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/observers/entity_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def after_update(item)
private

def send_notification_to_assignee(item)
UserMailer.assigned_entity_notification(item, current_user).deliver_now if item.assignee.present? && current_user.present? && can_send_email?
UserMailer.assigned_entity_notification(item, current_user).deliver_later if item.assignee.present? && current_user.present? && can_send_email?
end

# Need to have a host set before email can be sent
Expand Down
2 changes: 1 addition & 1 deletion app/models/polymorphic/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def subscribe_user_to_entity(u = user)
def notify_subscribers
commentable.subscribed_users.reject { |user_id| user_id == user.id }.each do |subscriber_id|
if subscriber = User.find_by_id(subscriber_id)
SubscriptionMailer.comment_notification(subscriber, self).deliver_now
SubscriptionMailer.comment_notification(subscriber, self).deliver_later
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fat_free_crm/mail_processor/dropbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def default_access
def notify(email, mediator_links)
DropboxMailer.create_dropbox_notification(
@sender, @settings[:address], email, mediator_links
).deliver_now
).deliver_later
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/observers/entity_observer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
let(:assignee) { create(:user) }
let(:assigner) { create(:user) }
let!(:entity) { build(entity_type, user: assigner, assignee: assignee) }
let(:mail) { double('mail', deliver_now: true) }
let(:mail) { double('mail', deliver_later: true) }

after :each do
entity.save
Expand Down Expand Up @@ -48,7 +48,7 @@
let(:assignee) { create(:user) }
let(:assigner) { create(:user) }
let!(:entity) { create(entity_type, user: create(:user)) }
let(:mail) { double('mail', deliver_now: true) }
let(:mail) { double('mail', deliver_later: true) }

it "notifies the new owner if the entity is re-assigned" do
expect(UserMailer).to receive(:assigned_entity_notification).with(entity, assigner).and_return(mail)
Expand Down

0 comments on commit 92bebce

Please sign in to comment.