From 38f04ed46146331f9363b042dcd3c3784f6cc268 Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Sun, 1 Oct 2017 12:51:03 +0200 Subject: [PATCH] Add mailer and emails for contributor invitations --- app/mailers/application_mailer.rb | 4 +++ app/mailers/collaboration_mailer.rb | 13 ++++++++++ .../contributor_invitation.html.erb | 25 +++++++++++++++++++ .../contributor_invitation.text.erb | 11 ++++++++ app/views/layouts/mailer.html.erb | 5 ++++ app/views/layouts/mailer.text.erb | 1 + test/mailers/collaboration_mailer_test.rb | 7 ++++++ .../previews/collaboration_mailer_preview.rb | 10 ++++++++ 8 files changed, 76 insertions(+) create mode 100644 app/mailers/application_mailer.rb create mode 100644 app/mailers/collaboration_mailer.rb create mode 100644 app/views/collaboration_mailer/contributor_invitation.html.erb create mode 100644 app/views/collaboration_mailer/contributor_invitation.text.erb create mode 100644 app/views/layouts/mailer.html.erb create mode 100644 app/views/layouts/mailer.text.erb create mode 100644 test/mailers/collaboration_mailer_test.rb create mode 100644 test/mailers/previews/collaboration_mailer_preview.rb diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 00000000..d25d8892 --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: "from@example.com" + layout 'mailer' +end diff --git a/app/mailers/collaboration_mailer.rb b/app/mailers/collaboration_mailer.rb new file mode 100644 index 00000000..5bc1c99d --- /dev/null +++ b/app/mailers/collaboration_mailer.rb @@ -0,0 +1,13 @@ +class CollaborationMailer < ApplicationMailer + default from: "collaboration@notebook.ai" + + def contributor_invitation(inviter:, invite_email:, universe:) + @inviter = inviter + @universe = universe + + mail( + to: invite_email, + subject: "#{@inviter.name} requested your help collaborating on Notebook.ai." + ) + end +end diff --git a/app/views/collaboration_mailer/contributor_invitation.html.erb b/app/views/collaboration_mailer/contributor_invitation.html.erb new file mode 100644 index 00000000..86c8c54b --- /dev/null +++ b/app/views/collaboration_mailer/contributor_invitation.html.erb @@ -0,0 +1,25 @@ + + + + + + +

Hello!

+ +

+ <%= @inviter.name %> is creating their own universes on Notebook.ai and has invited you to collaborate on their <%= link_to @universe.name, @universe %> universe. +

+

+ To get started, simply sign up or sign in to <%= link_to 'Notebook.ai', 'https://www.notebook.ai/users/sign_in' %> with this email address and look for "<%= @universe.name %>" under your Universes tab. +

+ +

+ Happy worldbuilding! +

+ +


+

+ Please don't respond to this email as this email address is not watched. If you have any questions, comments, concerns, or want to unsubscribe to future collaboration invitations, please send an email directly to andrew@indentlabs.com. Thank you for your understanding. +

+ + diff --git a/app/views/collaboration_mailer/contributor_invitation.text.erb b/app/views/collaboration_mailer/contributor_invitation.text.erb new file mode 100644 index 00000000..7f1ecd36 --- /dev/null +++ b/app/views/collaboration_mailer/contributor_invitation.text.erb @@ -0,0 +1,11 @@ +Hello! + +<%= @inviter.name %> is creating their own universes on Notebook.ai and has invited you to collaborate on their <%= @universe.name %> universe. + +To get started, simply sign up or sign in to https://www.Notebook.ai/ with this email address and look for <%= @universe.name %> under your Universes tab. You can also navigate directly to the universe at https://www.notebook.ai<%= universe_path(@universe) %> and get started from there. + +Happy worldbuilding! + +- + +Please don't respond to this email as the address is not watched. If you have any questions, comments, concerns, or want to unsubscribe to future collaboration invitations, please send an email directly to andrew@indentlabs.com. Thank you for your understanding. \ No newline at end of file diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 00000000..991cf0ff --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,5 @@ + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 00000000..37f0bddb --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/test/mailers/collaboration_mailer_test.rb b/test/mailers/collaboration_mailer_test.rb new file mode 100644 index 00000000..3b66ec79 --- /dev/null +++ b/test/mailers/collaboration_mailer_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class CollaborationMailerTest < ActionMailer::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/mailers/previews/collaboration_mailer_preview.rb b/test/mailers/previews/collaboration_mailer_preview.rb new file mode 100644 index 00000000..77faab81 --- /dev/null +++ b/test/mailers/previews/collaboration_mailer_preview.rb @@ -0,0 +1,10 @@ +# Preview all emails at http://localhost:3000/rails/mailers/collaboration_mailer +class CollaborationMailerPreview < ActionMailer::Preview + def contributor_invitation + CollaborationMailer.contributor_invitation( + inviter: User.first, + invite_email: 'andrew@indentlabs.com', + universe: Universe.first + ) + end +end