notification_mailer_preview.rb 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # frozen_string_literal: true
  2. # Preview all emails at http://localhost:3000/rails/mailers/notification_mailer
  3. class NotificationMailerPreview < ActionMailer::Preview
  4. # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/mention
  5. def mention
  6. activity = Mention.last
  7. mailer_for(activity.account, activity).mention
  8. end
  9. # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow
  10. def follow
  11. activity = Follow.last
  12. mailer_for(activity.target_account, activity).follow
  13. end
  14. # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/follow_request
  15. def follow_request
  16. activity = Follow.last
  17. mailer_for(activity.target_account, activity).follow_request
  18. end
  19. # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/favourite
  20. def favourite
  21. activity = Favourite.last
  22. mailer_for(activity.status.account, activity).favourite
  23. end
  24. # Preview this email at http://localhost:3000/rails/mailers/notification_mailer/reblog
  25. def reblog
  26. activity = Status.where.not(reblog_of_id: nil).first
  27. mailer_for(activity.reblog.account, activity).reblog
  28. end
  29. private
  30. def mailer_for(account, activity)
  31. NotificationMailer.with(
  32. recipient: account,
  33. notification: Notification.find_by(activity: activity)
  34. )
  35. end
  36. end