diff --git a/app/mailers/maintainer_mailer.rb b/app/mailers/maintainer_mailer.rb index 18204dc..0b6acfa 100644 --- a/app/mailers/maintainer_mailer.rb +++ b/app/mailers/maintainer_mailer.rb @@ -9,4 +9,16 @@ def invitation_email(maintainer_email, package, funders, amount, invite_token, d mail(to: maintainer_email, subject: "Thank you for your work maintaining #{@project}") end + + def expense_email(invitation, maintainer_email, package, funders, amount, invite_token, decline_deadline, fund) + @invitation = invitation + @project = package + @funders = funders + @fund = fund + @amount = amount + @invite_token = invite_token + @decline_deadline = decline_deadline + + mail(to: maintainer_email, subject: "Payment details for your work maintaining #{@project}") + end end diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 315e507..eb70bc4 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -67,6 +67,20 @@ def send_email ).deliver_now end + def send_expense_invite_email + return if draft_key.blank? + MaintainerMailer.expense_email( + self, + email, + project_allocation.project.to_s, + project_allocation.funder_names, + "$#{project_allocation.amount_cents / 100.0}", + token, + decline_deadline.strftime("%B %d, %Y"), + fund + ).deliver_now + end + def draft_key data['draftKey'] end diff --git a/app/views/maintainer_mailer/expense_email.html.erb b/app/views/maintainer_mailer/expense_email.html.erb new file mode 100644 index 0000000..3dfd2b9 --- /dev/null +++ b/app/views/maintainer_mailer/expense_email.html.erb @@ -0,0 +1,121 @@ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ <%= image_tag("ecosystems-funds-logo-purplebg-png@2x.png", alt: "ecosyste.ms", size: "282x68") %> +

Collaboratively funding the software we all depend upon

+
+
+ + + + +
+

Dear Maintainer,

+

<%= @funders %> would like to donate <%= @amount %> to <%= @project %> as part of the <%= link_to "#{@fund} Ecosystem Fund", fund_url(@fund) %>. If you’d like to accept this invitation, read on…

+
+
+ + + + + +
+ <%= image_tag("stone-1.png", alt: " ", class: "bullet-image", size: "24x24") %> + +

What’s this all about?

+

Open Source Collective is a non-profit organisation committed to supporting those who create and use open-source software. We’ve created a way to fund the most critical open source projects within their respective ecosystems. Read more here.

+ +

You’re receiving this message because this email address is publicly linked to <%= @project %>.

+
+
+ + + + +
+

Accepting this invitation personally

+ +

If you complete the enclosed invitation, we will pay you <%= @amount %> directly within the next two weeks for your work maintaining <%= @project %>:

+ +

Respond to the invite

+ +

Accepting as part of a community

+

If you or your community already accept financial support for <%= @project %>, add this information to your funding.yml file in your repository, and we’ll direct this and future contributions there. For more information on formats, see GitHub’s documentation — your repository does not have to be on GitHub.

+
+
+ + + + + +
+ <%= image_tag("stone-2.png", alt: " ", class: "bullet-image", size: "24x24") %> + +

Not thought about funding yet?

+

Many open-source communities accept donations and sponsorships to support their work. Whether it’s paying for hosting, tools, hardware, travel, or paying contributors for their time, money is an essential resource for modern open-source projects. Read more about funding platforms here.

+
+
+ + + + +
+

Declining this invitation (and future participation)

+

This invitation will remain open until <%= @decline_deadline %>. If you wish to decline this invitation, and future invitations, please indicate so using the invitation itself:

+

Respond to the invite

+ +

If you decline this invitation, we will not contact you again concerning <%= @project %>.

+ +

Thanks,

+
+
+ + + + + +
+ <%= image_tag("stone-3.png", alt: " ", class: "bullet-image", size: "24x24") %> + +

Find out more

+

If you’d like to know more about Open Source Collective, ecosyste.ms, and this project check out <%= about_url %>

+
+
+
+ + + + + diff --git a/app/views/maintainer_mailer/expense_email.text.erb b/app/views/maintainer_mailer/expense_email.text.erb new file mode 100644 index 0000000..bccc349 --- /dev/null +++ b/app/views/maintainer_mailer/expense_email.text.erb @@ -0,0 +1,36 @@ +Dear Maintainer, + +<%= @funders %> would like to donate <%= @amount %> to <%= @project %> as part of the <%="#{@fund} Ecosystem Fund" %>. + +<% if @invitation.accepted? %> +It's time to submit an expense for this donation. Please follow the link below to submit your expense: + +<%= @invitation.invite_url %> +<% else %> +You're receiving this message because this email address is publicly linked to <%= @project %>. + +We're still waiting for you to accept the invitation. Please follow the link below to accept the invitation and submit your expense: + +<%= @invitation.invite_url %> + +Declining this invitation (and future participation): +This invitation will remain open until <%= @decline_deadline %>. If you wish to decline this invitation, and future invitations, please indicate so using the invitation itself: + +<%= invitation_url(token: @invite_token) %> + +If you decline this invitation, we will not contact you again concerning <%= @project %>. + +<% end %> + +Accepting as part of a community: +If you or your community already accept financial support for <%= @project %>, add this information to your funding.yml file in your repository, and we’ll direct this and future contributions there. For more information on formats, see GitHub’s documentation <%= 'https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/displaying-a-sponsor-button-in-your-repository' %> — your repository does not have to be on GitHub. + +Not thought about funding yet? +Many open-source communities accept donations and sponsorships to support their work. Whether it’s paying for hosting, tools, hardware, travel, or paying contributors for their time, money is an essential resource for modern open-source projects. Read more about funding platforms here: <%= faq_url %>. + +Thanks, + +Find out more +If you’d like to know more about Open Source Collective, ecosyste.ms, and this project check out <%= about_url %>. + +Open Source Collective is a non-profit organisation committed to supporting those who create and use open-source software. We’ve created a way to fund the most critical open source projects within their respective ecosystems. Read more at <%= overview_url %>. \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index f902362..e0d795e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,7 @@ # These are extensions that must be enabled in order to support this database enable_extension "citext" enable_extension "pg_catalog.plpgsql" + enable_extension "pg_stat_statements" create_table "allocations", force: :cascade do |t| t.integer "fund_id" diff --git a/test/mailers/previews/maintainer_mailer_preview.rb b/test/mailers/previews/maintainer_mailer_preview.rb index 27b4cc0..cdf7540 100644 --- a/test/mailers/previews/maintainer_mailer_preview.rb +++ b/test/mailers/previews/maintainer_mailer_preview.rb @@ -11,4 +11,19 @@ def invitation_email Fund.first ) end + + def expense_email + data = {"draftKey" => "123"} + invitation = Invitation.create!(email: "maintainer@example.com", project_allocation: ProjectAllocation.first, data: data, member_invitation_id: 123) + MaintainerMailer.expense_email( + invitation, + "maintainer@example.com", + "example-project", + "Sentry", + "$500.00", + "123456", + (Time.now + 14.days).strftime("%B %d, %Y"), + Fund.first + ) + end end \ No newline at end of file