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

Send emails to subscribers in batches of 50 to avoid SMTP limit #9570

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions app/mailers/subscription_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ def notify_node_creation(node)
.collect(&:email)
recipients += node.author.followers.collect(&:email)
recipients.uniq!
mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients,
subject: subject
)
while recipients.length > 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use recipients.length.positive? instead of recipients.length > 0.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use !empty? instead of length > 0.

mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients.pop(50),
subject: subject
)
end
end

def notify_note_liked(node, user)
Expand Down Expand Up @@ -64,11 +66,13 @@ def notify_tag_added(node, tag, tagging_user)
end
end
@footer = feature('email-footer')
mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients,
subject: subject
)
while recipients.length > 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use recipients.length.positive? instead of recipients.length > 0.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use !empty? instead of length > 0.

mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients.pop(50),
subject: subject
)
end
end

def send_digest(user_id, nodes, frequency)
Expand Down