diff --git a/app/mailers/.keep b/app/mailers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 0e655997c..fd12a1e0d 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -1,6 +1,7 @@ class ApplicationMailer < ActionMailer::Base default from: "The DEV Community " layout "mailer" + default template_path: ->(mailer) { "mailers/#{mailer.class.name.underscore}" } def generate_unsubscribe_token(id, email_type) Rails.application.message_verifier(:unsubscribe).generate( diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rb index 771308950..9a86f9510 100644 --- a/app/mailers/digest_mailer.rb +++ b/app/mailers/digest_mailer.rb @@ -1,16 +1,16 @@ class DigestMailer < ApplicationMailer + default from: "DEV Digest " + def digest_email(user, articles) - @user = if Rails.env.development? - User.first - else - user - end + @user = user @articles = articles.first(6) @unsubscribe = generate_unsubscribe_token(@user.id, :email_digest_periodic) - @digest_email = true - mail(from: "DEV Digest ", to: @user.email, subject: "#{adjusted_title(@articles.first)} + #{@articles.size - 1} #{email_end_phrase} #{random_emoji}") do |format| - format.html { render "layouts/mailer" } - end + subject = generate_title(@articles) + mail(to: @user.email, subject: subject) + end + + def generate_title(articles) + "#{adjusted_title(articles.first)} + #{articles.size - 1} #{email_end_phrase} #{random_emoji}" end def adjusted_title(article) diff --git a/app/mailers/membership_mailer.rb b/app/mailers/membership_mailer.rb new file mode 100644 index 000000000..536ae13cf --- /dev/null +++ b/app/mailers/membership_mailer.rb @@ -0,0 +1,19 @@ +class MembershipMailer < ApplicationMailer + default from: "DEV Members " + + def new_membership_subscription_email(user, subscription_type) + @user = user + @subscription_type = subscription_type + mail(to: @user.email, subject: "Thanks for subscribing!") + end + + def subscription_update_confirm_email(user) + @user = user + mail(to: @user.email, subject: "Your subscription has been updated.") + end + + def subscription_cancellation_email(user) + @user = user + mail(to: @user.email, subject: "Sorry to lose you.") + end +end diff --git a/app/mailers/notify_mailer.rb b/app/mailers/notify_mailer.rb index 309e45827..75661ba35 100644 --- a/app/mailers/notify_mailer.rb +++ b/app/mailers/notify_mailer.rb @@ -1,34 +1,19 @@ class NotifyMailer < ApplicationMailer - def new_reply_email(comment) - @user = if Rails.env.development? - User.first - else - comment.parent_user - end + @user = comment.parent_user return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email) @unsubscribe = generate_unsubscribe_token(@user.id, :email_comment_notifications) @comment = comment - mail(to: @user.email, subject: "#{@comment.user.name} replied to your #{@comment.parent_type}") do |format| - format.html { render "layouts/mailer" } - format.text { render plain: "#{@comment.user.name} replied to your #{@comment.parent_type}:\n\n#{ActionController::Base.helpers.strip_tags(comment.processed_html.html_safe)}\n\nView now: https://dev.to#{comment.path}" } - end + mail(to: @user.email, subject: "#{@comment.user.name} replied to your #{@comment.parent_type}") end def new_follower_email(follow) - @user = if Rails.env.development? - User.first - else - follow.followable - end + @user = follow.followable return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email) @follower = follow.follower @unsubscribe = generate_unsubscribe_token(@user.id, :email_follower_notifications) - mail(to: @user.email, subject: "#{@follower.name} just followed you on dev.to") do |format| - format.html { render 'layouts/mailer' } - format.text { render plain: "#{@follower.name} just followed you. When someone follows you, your posts will be prioritized on their personalized home feed. This new feature is one step towards offering a more customized experience." } - end + mail(to: @user.email, subject: "#{@follower.name} just followed you on dev.to") end def new_mention_email(mention) @@ -39,76 +24,15 @@ class NotifyMailer < ApplicationMailer @mention = mention @unsubscribe = generate_unsubscribe_token(@user.id, :email_mention_notifications) - mail(to: @user.email, subject: "#{@mentioner.name} just mentioned you!") do |format| - format.html { render 'layouts/mailer' } - format.text { render plain: "#{@mentioner.name} just mentioned you in their #{mention.mentionable_type.downcase}\n\n#{ActionController::Base.helpers.strip_tags(@mentionable.processed_html.html_safe)}\n\nView now: https://dev.to#{mention.mentionable.path}" } - end + mail(to: @user.email, subject: "#{@mentioner.name} just mentioned you!") end def unread_notifications_email(user) - @user = if Rails.env.development? - User.first - else - user - end + @user = user return if RateLimitChecker.new.limit_by_email_recipient_address(@user.email) @unread_notifications_count = NotificationCounter.new(@user).unread_notification_count @unsubscribe = generate_unsubscribe_token(@user.id, :email_unread_notifications) - mail(to: @user.email, subject: "🔥 You have #{@unread_notifications_count} unread notifications on dev.to") do |format| - format.html { render 'layouts/mailer' } - format.text { render plain: "Visit https://dev.to/notifications to read all of your notifications" } - end - end - - def new_membership_subscription_email(user,subscription_type) - @user = if Rails.env.development? - User.first - else - user - end - @subscription_type = subscription_type - mail(from: "DEV Members ", to: @user.email, subject: "Thanks for subscribing!") do |format| - format.html { render "layouts/mailer" } - format.text { render plain: "Visit https://dev.to/settings/membership for full details" } - end - end - - def subscription_update_confirm_email(user) - @user = if Rails.env.development? - User.first - else - user - end - @update_subscription = true - mail(from: "DEV Members ", to: @user.email, subject: "Your subscription has been updated.") do |format| - format.html { render "layouts/mailer" } - format.text { render plain: "Visit https://dev.to/settings/membership for updated details" } - end - end - - def subscription_cancellation_email(user) - @user = if Rails.env.development? - User.first - else - user - end - @cancel_subscription = true - mail(from: "members@dev.to", to: @user.email, subject: "Sorry to lose you.") do |format| - format.html { render "layouts/mailer" } - format.text { render plain: " If you could send feedback to yo@dev.to to help us improve it would be much appreciated." } - end - end - - def scholarship_awarded_email(user) - @user = if Rails.env.development? - User.first - else - user - end - @scholarship_awarded = true - mail(from: "members@dev.to", to: @user.email, subject: "Congrats on your DEV Scholarship!") do |format| - format.html { render "layouts/mailer" } - format.text { render plain: "Congratulations on your dev.to Scholarship! See https://dev.to/settings/misc for updated details" } - end + subject = "🔥 You have #{@unread_notifications_count} unread notifications on dev.to" + mail(to: @user.email, subject: subject) end end diff --git a/app/mailers/scholarship_mailer.rb b/app/mailers/scholarship_mailer.rb new file mode 100644 index 000000000..27e93f648 --- /dev/null +++ b/app/mailers/scholarship_mailer.rb @@ -0,0 +1,6 @@ +class ScholarshipMailer < ApplicationMailer + def scholarship_awarded_email(user) + @user = user + mail(from: "members@dev.to", to: @user.email, subject: "Congrats on your DEV Scholarship!") + end +end diff --git a/app/services/membership_service.rb b/app/services/membership_service.rb index 28f0e674e..bb57a4d83 100644 --- a/app/services/membership_service.rb +++ b/app/services/membership_service.rb @@ -91,14 +91,14 @@ class MembershipService end def send_welcome_email - NotifyMailer.delay.new_membership_subscription_email(user, user.roles.last.name) + MembershipMailer.delay.new_membership_subscription_email(user, user.roles.last.name) end def send_update_email - NotifyMailer.delay.subscription_update_confirm_email(user) + MembershipMailer.delay.subscription_update_confirm_email(user) end def send_cancellation_email - NotifyMailer.delay.subscription_cancellation_email(user) + MembershipMailer.delay.subscription_cancellation_email(user) end end diff --git a/app/services/user_role_service.rb b/app/services/user_role_service.rb index 2bd879e8b..0270ba4ef 100644 --- a/app/services/user_role_service.rb +++ b/app/services/user_role_service.rb @@ -38,7 +38,7 @@ class UserRoleService if params[:scholar] == "1" @user.add_role(:workshop_pass) @user.update(workshop_expiration: params[:workshop_expiration]) - NotifyMailer.delay.scholarship_awarded_email(@user) if params[:scholar_email] == "1" + ScholarshipMailer.delay.scholarship_awarded_email(@user) if params[:scholar_email] == "1" else @user.remove_role(:workshop_pass) end diff --git a/app/views/layouts/_mailer_content.html.erb b/app/views/layouts/_mailer_content.html.erb index 0e62c7631..e69de29bb 100644 --- a/app/views/layouts/_mailer_content.html.erb +++ b/app/views/layouts/_mailer_content.html.erb @@ -1,222 +0,0 @@ -<% if @comment %> -

<%= link_to(@comment.user.name, "https://dev.to/#{@comment.user.username}") %> replied to you on dev.to

-
- <% unless @comment.is_root? %> - <%= truncate(strip_tags(@comment.parent_or_root_article.processed_html.html_safe), length: 80) %> - <% end %> -
-

re: <%= @comment.commentable.title %>

- <%= @comment.processed_html.html_safe %> - read & reply read original post -
-<% elsif @follower %> - <% if Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size > 1 %> -

You have <%= Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size %> new DEV followers in the past day!

- <% end %> - -

<%= @follower.name %> just followed you 🤗

-

You now have <%= pluralize(@user.followers_count, 'total follower') %>. See all of your recent followers right here.

-

- When someone follows you on dev.to, your posts will be prioritized in their feed and notifications. The perks of popularity I suppose. -

-<% elsif @unread_notifications_count %> -

You're popular!

-

- Read my notifications -

-<% elsif @mentioner %> -

<%= @mentioner.name %> just mentioned you in their <%= @mention.mentionable_type.downcase %>!

-
- -
- <%= @mentionable.processed_html.html_safe %> - read & reply -
-<% elsif @subscription_type %> - - <% if @subscription_type == "triple_unicorn_member" %> -

- Whoa! You’re the best, and so generous. We tip our hats to you. -

-

- As a triple-unicorn, you have full access to all dev.to workshops! We’ll be releasing our workshop schedule Early February. -

-

- You’ll see your name at the featured position on our ‘Wall of Patrons and Scholars’ within the next few days, and you can claim your swag pack now by visiting your settings page. -

-

- We’ll be in touch to schedule a time for all of us to chat together, and we’ll also be putting together some additional goodies. -

-

- Thank you again for supporting The DEV Community. Your membership means a lot to us, and all the recipients of our scholarship fund. You went above and beyond on this one. -

- <% elsif @subscription_type == "level_4_member" %> -

- Thank you for becoming a DEV sustaining member. Your support means the world to us. -

-

- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. -

-

- On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. -

-

- Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. -

-

- Above all, thank you for supporting The DEV Community. Your additional contribution means so much to us, and to all the recipients of our scholarship fund. You really went above and beyond on this one. -

-

- With sincere gratitude... -

-

- ❤️ -
- PBJ -

-

- PS — feel free to reply to this email with any questions. -

- <% elsif @subscription_type == "level_3_member" %> -

- Thank you for becoming a DEV sustaining member. Your support means the world to us. -

-

- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. -

-

- On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. -

-

- Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. -

-

- Feel free to reply to this email with any questions :) -

-

- Thanks again! ❤️ -
- PBJ -

- <% elsif @subscription_type == "level_2_member" %> -

- Thank you for becoming a DEV sustaining member. Your support means the world to us. -

-

- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. -

-

- On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack. Within the next few days, you’ll be appearing on our ‘Wall of Patrons and Scholars.’ -

-

- Feel free to reply to this email with any questions :) -

-

- Thanks again! ❤️ -
- PBJ -

- <% elsif @subscription_type == "level_1_member" %> -

- Thank you for becoming a DEV sustaining member. Your support means the world to us. -

-

- As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. -

-

- Within the next few days, you’ll also appear on our ‘Wall of Patrons and Scholars.’ -

-

- Feel free to reply to this email with any questions :) -

-

- Thanks again! ❤️ -
- PBJ -

- <% end %> -

Thank you so much for your support.

-

- Visit Your membership settings page for all details. -

-<% elsif @update_subscription %> - -

- Your DEV sustaining membership monthly contribution amount has been updated. Be sure to check your membership settings page to see the most up-to-date information. -

-

- Thank you so much for the support, and please email members@dev.to with any questions. -

-<% elsif @cancel_subscription %> -

- Your DEV sustaining membership has been cancelled. Thank you so much for your support to date. -

-

- If you have any feedback that can help us improve the membership experience, please feel free to reply to this email. -

-

-

- Thanks again, -
- PBJ -

-<% elsif @scholarship_awarded %> - -

Congratulations!

-

- We’ve received your DEV scholarship application and are excited to provide you with a workshop pass for - the year. You’ll get full access to all DEV talks and workshops by visiting dev.to/live during an event. See our events page - to check out the latest schedule. We appreciate your dedication to programming and hope you’ll benefit from these additional - resources. -

- -

- Thanks again for applying and if within your means, please consider becoming a level 1 or 2 sustaining member. -

-

- Best, -
- PBJ -

-<% elsif @digest_email %> -

- DEV Digest -

-

Recent posts you might find valuable based on your interests ❤️

- <% @articles.each do |article| %> - - <% end %> - -
- - <% if @user.follows.size == 0 %> - - DEV Digest is a new periodic email featuring the best posts from our community of developers. - -

- Your digest is not yet customized. Follow the people and technologies on dev.to that interest you in order to receive the most relevant posts in your inbox. - <% else %> - <% tip_rand = rand(5) %> - <% if tip_rand == 0 %> - Thanks for being a valued member of the community. - <% elsif tip_rand == 1 %> - Follow the authors you want to see more of! - <% elsif tip_rand == 2 %> - And there's so much more dev goodness to discover. - <% elsif tip_rand == 3 %> - You're a better dev today than you were yesterday. - <% elsif tip_rand == 4 %> - <% if @user.articles.where(published: true).any? %> - Can't wait to see your next DEV post! - <% else %> - Can't wait to see your first DEV post! - <% end %> - <% end %> - <% end %> -
-
-<% end %> diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index 81ededaef..0baa67ad5 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -3,7 +3,7 @@ diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb index 20319cdfd..d6e80c741 100644 --- a/app/views/layouts/mailer.text.erb +++ b/app/views/layouts/mailer.text.erb @@ -1 +1,2 @@ <%= strip_tags @body %> +<%= yield %> diff --git a/app/views/mailers/digest_mailer/digest_email.html.erb b/app/views/mailers/digest_mailer/digest_email.html.erb new file mode 100644 index 000000000..d875803d1 --- /dev/null +++ b/app/views/mailers/digest_mailer/digest_email.html.erb @@ -0,0 +1,40 @@ +

+ DEV Digest +

+

Recent posts you might find valuable based on your interests ❤️

+<% @articles.each do |article| %> + +<% end %> + +
+ + <% if @user.follows.size == 0 %> + + DEV Digest is a new periodic email featuring the best posts from our community of developers. + +

+ Your digest is not yet customized. Follow the people and technologies on dev.to that interest you in order to receive the most relevant posts in your inbox. + <% else %> + <% tip_rand = rand(5) %> + <% if tip_rand == 0 %> + Thanks for being a valued member of the community. + <% elsif tip_rand == 1 %> + Follow the authors you want to see more of! + <% elsif tip_rand == 2 %> + And there's so much more dev goodness to discover. + <% elsif tip_rand == 3 %> + You're a better dev today than you were yesterday. + <% elsif tip_rand == 4 %> + <% if @user.articles.where(published: true).any? %> + Can't wait to see your next DEV post! + <% else %> + Can't wait to see your first DEV post! + <% end %> + <% end %> + <% end %> +
+
diff --git a/app/views/mailers/membership_mailer/new_membership_subscription_email.html.erb b/app/views/mailers/membership_mailer/new_membership_subscription_email.html.erb new file mode 100644 index 000000000..b49bb57f3 --- /dev/null +++ b/app/views/mailers/membership_mailer/new_membership_subscription_email.html.erb @@ -0,0 +1,106 @@ + +<% if @subscription_type == "triple_unicorn_member" %> +

+ Whoa! You’re the best, and so generous. We tip our hats to you. +

+

+ As a triple-unicorn, you have full access to all dev.to workshops! We’ll be releasing our workshop schedule Early February. +

+

+ You’ll see your name at the featured position on our ‘Wall of Patrons and Scholars’ within the next few days, and you can claim your swag pack now by visiting your settings page. +

+

+ We’ll be in touch to schedule a time for all of us to chat together, and we’ll also be putting together some additional goodies. +

+

+ Thank you again for supporting The DEV Community. Your membership means a lot to us, and all the recipients of our scholarship fund. You went above and beyond on this one. +

+<% elsif @subscription_type == "level_4_member" %> +

+ Thank you for becoming a DEV sustaining member. Your support means the world to us. +

+

+ As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. +

+

+ On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. +

+

+ Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. +

+

+ Above all, thank you for supporting The DEV Community. Your additional contribution means so much to us, and to all the recipients of our scholarship fund. You really went above and beyond on this one. +

+

+ With sincere gratitude... +

+

+ ❤️ +
+ PBJ +

+

+ PS — feel free to reply to this email with any questions. +

+<% elsif @subscription_type == "level_3_member" %> +

+ Thank you for becoming a DEV sustaining member. Your support means the world to us. +

+

+ As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. +

+

+ On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack and t-shirt combo. +

+

+ Your name will appear on our “Wall of Patrons and Scholars” soon, and you’ll also be receiving full access to all dev.to workshops! We’ll be releasing our first workshop schedule in early February. +

+

+ Feel free to reply to this email with any questions :) +

+

+ Thanks again! ❤️ +
+ PBJ +

+<% elsif @subscription_type == "level_2_member" %> +

+ Thank you for becoming a DEV sustaining member. Your support means the world to us. +

+

+ As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. +

+

+ On your membership settings page, you’ll find the coupon that you’ll use to request your exclusive sticker pack. Within the next few days, you’ll be appearing on our ‘Wall of Patrons and Scholars.’ +

+

+ Feel free to reply to this email with any questions :) +

+

+ Thanks again! ❤️ +
+ PBJ +

+<% elsif @subscription_type == "level_1_member" %> +

+ Thank you for becoming a DEV sustaining member. Your support means the world to us. +

+

+ As part of your membership, you’ll have early access to beta features on the site. For instance, post analytics have now been added to your dashboard. +

+

+ Within the next few days, you’ll also appear on our ‘Wall of Patrons and Scholars.’ +

+

+ Feel free to reply to this email with any questions :) +

+

+ Thanks again! ❤️ +
+ PBJ +

+<% end %> +

Thank you so much for your support.

+

+Visit Your membership settings page for all details. +

diff --git a/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb b/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb new file mode 100644 index 000000000..bab3ceb18 --- /dev/null +++ b/app/views/mailers/membership_mailer/new_membership_subscription_email.text.erb @@ -0,0 +1 @@ +Visit https://dev.to/settings/membership for full details diff --git a/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb b/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb new file mode 100644 index 000000000..653393d4f --- /dev/null +++ b/app/views/mailers/membership_mailer/subscription_cancellation_email.html.erb @@ -0,0 +1,12 @@ +

+Your DEV sustaining membership has been cancelled. Thank you so much for your support to date. +

+

+If you have any feedback that can help us improve the membership experience, please feel free to reply to this email. +

+

+

+Thanks again, +
+PBJ +

diff --git a/app/views/mailers/membership_mailer/subscription_cancellation_email.text.erb b/app/views/mailers/membership_mailer/subscription_cancellation_email.text.erb new file mode 100644 index 000000000..8f0de6ef3 --- /dev/null +++ b/app/views/mailers/membership_mailer/subscription_cancellation_email.text.erb @@ -0,0 +1 @@ + If you could send feedback to yo@dev.to to help us improve it would be much appreciated. diff --git a/app/views/mailers/membership_mailer/subscription_update_confirm_email.html.erb b/app/views/mailers/membership_mailer/subscription_update_confirm_email.html.erb new file mode 100644 index 000000000..8b41354a7 --- /dev/null +++ b/app/views/mailers/membership_mailer/subscription_update_confirm_email.html.erb @@ -0,0 +1,7 @@ + +

+Your DEV sustaining membership monthly contribution amount has been updated. Be sure to check your membership settings page to see the most up-to-date information. +

+

+Thank you so much for the support, and please email members@dev.to with any questions. +

diff --git a/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb b/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb new file mode 100644 index 000000000..b0f611113 --- /dev/null +++ b/app/views/mailers/membership_mailer/subscription_update_confirm_email.text.erb @@ -0,0 +1 @@ +Visit https://dev.to/settings/membership for updated details diff --git a/app/views/mailers/notify_mailer/new_follower_email.html.erb b/app/views/mailers/notify_mailer/new_follower_email.html.erb new file mode 100644 index 000000000..1eef900cc --- /dev/null +++ b/app/views/mailers/notify_mailer/new_follower_email.html.erb @@ -0,0 +1,9 @@ +<% if Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size > 1 %> +

You have <%= Follow.where(followable_id: @user.id, followable_type: "User").where("created_at > ?", 24.hours.ago).size %> new DEV followers in the past day!

+<% end %> + +

<%= @follower.name %> just followed you 🤗

+

You now have <%= pluralize(@user.followers_count, 'total follower') %>. See all of your recent followers right here.

+

+When someone follows you on dev.to, your posts will be prioritized in their feed and notifications. The perks of popularity I suppose. +

diff --git a/app/views/mailers/notify_mailer/new_follower_email.text.erb b/app/views/mailers/notify_mailer/new_follower_email.text.erb new file mode 100644 index 000000000..6b058a3c0 --- /dev/null +++ b/app/views/mailers/notify_mailer/new_follower_email.text.erb @@ -0,0 +1 @@ +<%= @follower.name %> just followed you. When someone follows you, your posts will be prioritized on their personalized home feed. This new feature is one step towards offering a more customized experience. diff --git a/app/views/mailers/notify_mailer/new_mention_email.html.erb b/app/views/mailers/notify_mailer/new_mention_email.html.erb new file mode 100644 index 000000000..ce73da01b --- /dev/null +++ b/app/views/mailers/notify_mailer/new_mention_email.html.erb @@ -0,0 +1,7 @@ +

<%= @mentioner.name %> just mentioned you in their <%= @mention.mentionable_type.downcase %>!

+
- <%= render "layouts/mailer_content" %> + <%= yield %>
+ +
+ <%= @mentionable.processed_html.html_safe %> + read & reply +
diff --git a/app/views/mailers/notify_mailer/new_mention_email.text.erb b/app/views/mailers/notify_mailer/new_mention_email.text.erb new file mode 100644 index 000000000..6d9762749 --- /dev/null +++ b/app/views/mailers/notify_mailer/new_mention_email.text.erb @@ -0,0 +1,5 @@ +<%= @mentioner.name %> just mentioned you in their <%= @mention.mentionable_type.downcase %> + +<%= ActionController::Base.helpers.strip_tags(@mentionable.processed_html.html_safe) %> + +View now: https://dev.to<%= @mention.mentionable.path %> diff --git a/app/views/mailers/notify_mailer/new_reply_email.html.erb b/app/views/mailers/notify_mailer/new_reply_email.html.erb new file mode 100644 index 000000000..d48c137c1 --- /dev/null +++ b/app/views/mailers/notify_mailer/new_reply_email.html.erb @@ -0,0 +1,10 @@ +

<%= link_to(@comment.user.name, "https://dev.to/#{@comment.user.username}") %> replied to you on dev.to

+
+ <% unless @comment.is_root? %> + <%= truncate(strip_tags(@comment.parent_or_root_article.processed_html.html_safe), length: 80) %> + <% end %> +
+

re: <%= @comment.commentable.title %>

+ <%= @comment.processed_html.html_safe %> + read & reply read original post +
diff --git a/app/views/mailers/notify_mailer/new_reply_email.text.erb b/app/views/mailers/notify_mailer/new_reply_email.text.erb new file mode 100644 index 000000000..827090bce --- /dev/null +++ b/app/views/mailers/notify_mailer/new_reply_email.text.erb @@ -0,0 +1,5 @@ +<%= @comment.user.name %> replied to your <%= @comment.parent_type %>: + +<%= ActionController::Base.helpers.strip_tags(@comment.processed_html.html_safe) %> + +View now: https://dev.to<%= @comment.path %> diff --git a/app/views/mailers/notify_mailer/unread_notifications_email.html.erb b/app/views/mailers/notify_mailer/unread_notifications_email.html.erb new file mode 100644 index 000000000..6760e8b25 --- /dev/null +++ b/app/views/mailers/notify_mailer/unread_notifications_email.html.erb @@ -0,0 +1,4 @@ +

You're popular!

+

+Read my notifications +

diff --git a/app/views/mailers/notify_mailer/unread_notifications_email.text.erb b/app/views/mailers/notify_mailer/unread_notifications_email.text.erb new file mode 100644 index 000000000..fd117beb8 --- /dev/null +++ b/app/views/mailers/notify_mailer/unread_notifications_email.text.erb @@ -0,0 +1 @@ +Visit https://dev.to/notifications to read all of your notifications diff --git a/app/views/mailers/scholarship_mailer/scholarship_awarded_email.html.erb b/app/views/mailers/scholarship_mailer/scholarship_awarded_email.html.erb new file mode 100644 index 000000000..da8ea7136 --- /dev/null +++ b/app/views/mailers/scholarship_mailer/scholarship_awarded_email.html.erb @@ -0,0 +1,17 @@ + +

Congratulations!

+

+We’ve received your DEV scholarship application and are excited to provide you with a workshop pass for +the year. You’ll get full access to all DEV talks and workshops by visiting dev.to/live during an event. See our events page +to check out the latest schedule. We appreciate your dedication to programming and hope you’ll benefit from these additional +resources. +

+ +

+Thanks again for applying and if within your means, please consider becoming a level 1 or 2 sustaining member. +

+

+Best, +
+PBJ +

diff --git a/app/views/mailers/scholarship_mailer/scholarship_awarded_email.text.erb b/app/views/mailers/scholarship_mailer/scholarship_awarded_email.text.erb new file mode 100644 index 000000000..71568bfc5 --- /dev/null +++ b/app/views/mailers/scholarship_mailer/scholarship_awarded_email.text.erb @@ -0,0 +1 @@ + Congratulations on your dev.to Scholarship! See https://dev.to/settings/misc for updated details diff --git a/spec/mailers/membership_mailer_spec.rb b/spec/mailers/membership_mailer_spec.rb new file mode 100644 index 000000000..cb8bceb40 --- /dev/null +++ b/spec/mailers/membership_mailer_spec.rb @@ -0,0 +1,31 @@ +require "rails_helper" + +RSpec.describe MembershipMailer, type: :mailer do + let(:user) { create(:user) } + + describe "#new_membership_subscription_email" do + it "renders proper subject" do + user = create(:user) + new_membership_subscription_email = described_class.new_membership_subscription_email(user, "level_1_member") + expect(new_membership_subscription_email.subject).to include("Thanks for subscribing") + end + it "renders proper receiver" do + user = create(:user) + new_membership_subscription_email = described_class.new_membership_subscription_email(user, "level_1_member") + expect(new_membership_subscription_email.to).to eq([user.email]) + end + end + + describe "#subscription_cancellation_email" do + it "renders proper subject" do + user = create(:user) + subscription_cancellation_email = described_class.subscription_cancellation_email(user) + expect(subscription_cancellation_email.subject).to include("Sorry to lose you") + end + it "renders proper receiver" do + user = create(:user) + subscription_cancellation_email = described_class.subscription_cancellation_email(user) + expect(subscription_cancellation_email.to).to eq([user.email]) + end + end +end diff --git a/spec/mailers/notify_mailer_spec.rb b/spec/mailers/notify_mailer_spec.rb index 723617672..4b3c82540 100644 --- a/spec/mailers/notify_mailer_spec.rb +++ b/spec/mailers/notify_mailer_spec.rb @@ -1,84 +1,47 @@ require "rails_helper" -RSpec.describe NotifyMailer, :type => :mailer do +RSpec.describe NotifyMailer, type: :mailer do describe "notify" do let(:user) { create(:user) } let(:user2) { create(:user) } let(:article) { create(:article, user_id: user.id) } let(:comment) { create(:comment, user_id: user.id, commentable_id: article.id) } - describe "new_reply_email" do + describe "#new_reply_email" do it "renders proper subject" do - new_reply_email = NotifyMailer.new_reply_email(comment) + new_reply_email = described_class.new_reply_email(comment) expect(new_reply_email.subject).to include("replied to your") end it "renders proper receiver" do - new_reply_email = NotifyMailer.new_reply_email(comment) + new_reply_email = described_class.new_reply_email(comment) expect(new_reply_email.to).to eq([comment.user.email]) end end - describe "new_follower_email" do + describe "#new_follower_email" do it "renders proper subject" do user2.follow(user) - new_follower_email = NotifyMailer.new_follower_email(Follow.last) + new_follower_email = described_class.new_follower_email(Follow.last) expect(new_follower_email.subject).to eq("#{user2.name} just followed you on dev.to") end it "renders proper receiver" do user2.follow(user) - new_follower_email = NotifyMailer.new_follower_email(Follow.last) + new_follower_email = described_class.new_follower_email(Follow.last) expect(new_follower_email.to).to eq([user.email]) end end - describe "new_mention_email" do + + describe "#new_mention_email" do it "renders proper subject" do mention = create(:mention, user_id: user2.id, mentionable_id: comment.id) - new_mention_email = NotifyMailer.new_mention_email(mention) + new_mention_email = described_class.new_mention_email(mention) expect(new_mention_email.subject).to include("#{comment.user.name} just mentioned you") end it "renders proper receiver" do mention = create(:mention, user_id: user2.id, mentionable_id: comment.id) - new_mention_email = NotifyMailer.new_mention_email(mention) + new_mention_email = described_class.new_mention_email(mention) expect(new_mention_email.to).to eq([user2.email]) end end - describe "new_membership_subscription_email" do - it "renders proper subject" do - user = create(:user) - new_membership_subscription_email = NotifyMailer.new_membership_subscription_email(user,"level_1_member") - expect(new_membership_subscription_email.subject).to include("Thanks for subscribing") - end - it "renders proper receiver" do - user = create(:user) - new_membership_subscription_email = NotifyMailer.new_membership_subscription_email(user,"level_1_member") - expect(new_membership_subscription_email.to).to eq([user.email]) - end - end - describe "subscription_cancellation_email" do - it "renders proper subject" do - user = create(:user) - subscription_cancellation_email = NotifyMailer.subscription_cancellation_email(user) - expect(subscription_cancellation_email.subject).to include("Sorry to lose you") - end - it "renders proper receiver" do - user = create(:user) - subscription_cancellation_email = NotifyMailer.subscription_cancellation_email(user) - expect(subscription_cancellation_email.to).to eq([user.email]) - end - end - - describe "scholarship_awarded_email" do - it "renders proper subject" do - user = create(:user) - scholarship_awarded_email = NotifyMailer.scholarship_awarded_email(user) - expect(scholarship_awarded_email.subject).to eq("Congrats on your DEV Scholarship!") - end - - it "renders proper receiver" do - user = create(:user) - scholarship_awarded_email = NotifyMailer.scholarship_awarded_email(user) - expect(scholarship_awarded_email.to).to eq([user.email]) - end - end end end diff --git a/spec/mailers/previews/membership_mailer_preview.rb b/spec/mailers/previews/membership_mailer_preview.rb new file mode 100644 index 000000000..6b4ca2738 --- /dev/null +++ b/spec/mailers/previews/membership_mailer_preview.rb @@ -0,0 +1,13 @@ +class MembershipMailerPreview < ActionMailer::Preview + def new_membership_subscription_email + MembershipMailer.new_membership_subscription_email(User.last, "level_2_member") + end + + def subscription_update_confirm_email + MembershipMailer.subscription_update_confirm_email(User.last) + end + + def subscription_cancellation_email + MembershipMailer.subscription_cancellation_email(User.last) + end +end diff --git a/spec/mailers/previews/notify_mailer_preview.rb b/spec/mailers/previews/notify_mailer_preview.rb index a356ab85f..1f8ee9f63 100644 --- a/spec/mailers/previews/notify_mailer_preview.rb +++ b/spec/mailers/previews/notify_mailer_preview.rb @@ -15,24 +15,4 @@ class NotifyMailerPreview < ActionMailer::Preview def new_mention_email NotifyMailer.new_mention_email(Mention.last) end - - def new_membership_subscription_email - NotifyMailer.new_membership_subscription_email(User.last, "level_2_member") - end - - def subscription_update_confirm_email - NotifyMailer.subscription_update_confirm_email(User.last) - end - - def subscription_cancellation_email - NotifyMailer.subscription_cancellation_email(User.last) - end - - def scholarship_awarded_email - NotifyMailer.scholarship_awarded_email(User.last) - end - - def digest_email - NotifyMailer.digest_email(User.last, Article.all) - end end diff --git a/spec/mailers/previews/scholarship_mailer_preview.rb b/spec/mailers/previews/scholarship_mailer_preview.rb new file mode 100644 index 000000000..1b1486570 --- /dev/null +++ b/spec/mailers/previews/scholarship_mailer_preview.rb @@ -0,0 +1,5 @@ +class ScholarshipMailerPreview < ActionMailer::Preview + def scholarship_awarded_email + ScholarshipMailer.scholarship_awarded_email(User.last) + end +end diff --git a/spec/mailers/scholarship_mailer_spec.rb b/spec/mailers/scholarship_mailer_spec.rb new file mode 100644 index 000000000..79ab7eaa4 --- /dev/null +++ b/spec/mailers/scholarship_mailer_spec.rb @@ -0,0 +1,19 @@ +require "rails_helper" + +RSpec.describe ScholarshipMailer, type: :mailer do + let(:user) { create(:user) } + + describe "#scholarship_awarded_email" do + it "renders proper subject" do + user = create(:user) + scholarship_awarded_email = described_class.scholarship_awarded_email(user) + expect(scholarship_awarded_email.subject).to eq("Congrats on your DEV Scholarship!") + end + + it "renders proper receiver" do + user = create(:user) + scholarship_awarded_email = described_class.scholarship_awarded_email(user) + expect(scholarship_awarded_email.to).to eq([user.email]) + end + end +end