Skip to content

Conversation

@Dcano-png
Copy link

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7035

Purpose

This PR introduces the Invitation Mailer Preview functionality and conducts a required I18n refactoring of the invitation email. The refactoring eliminates unsafe practices (like html_safe and view helpers for formatting) to improve code maintainability, rendering safety, and compliance with current I18n standards.

Changes Included

  • Added Mailer Preview (invitation_mailer_preview.rb): A new preview class was added, featuring two necessary variants:
    • invitation_by_other_user: Previews the mailer when an inviter's username is present in the greeting.
    • invitation_by_queue: Previews the generic mailer greeting when the invitation is system-generated.
  • Refactored I18n Keys (config/locales/*.en.yml) and Templates(app/views/user_mailer/invitation.*.erb):
    • Eliminated the use of html_safe from all calls in app/views/user_mailer/invitation.*.erb.
    • Refactored Locale Keys (config/locales/*.en.yml): Separated nested keys (e.g., .html.about) into the standard structure (.about.html and .about.text). This ensures the I18n system correctly prevents raw HTML from showing in the final message while allowing helpers to be used in the HTML view.
    • Resolved Issue: This refactoring inherently fixed the issues with exposed HTML tags and eliminated the variable mismatch errors encountered during development.

Credit

Dcano-png (She/Her)

@Bilka2
Copy link
Contributor

Bilka2 commented Nov 29, 2025

Hi!

Thank you so much for this pull request. Someone will be along to review it soon.

I've updated the Jira issue status to In Review so no one will mistakenly create a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. Since part of this issue is to do a style cleanup, I've pointed out a lot of places where we should make modifications to follow the latest version of our i18n standards.

<%= t(".has_invited", user_name: style_bold(@user_name)).html_safe %>
<%= t(".has_invited.html", user_name: style_bold(@user_name)) %>
<% else %>
<%= t ".been_invited" %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update all t method calls in these emails to use parentheses, as explained in our i18n standards:

Suggested change
<%= t ".been_invited" %>
<%= t(".been_invited") %>


<p>
<%= t(".html.activation_support", support_link: style_link(t(".html.support_link_text"), new_feedback_report_url)).html_safe %>
<%= t(".activation_support.html", support_link: style_link(t(".activation_support.support_link_text"), new_feedback_report_url)) %>
Copy link
Contributor

Choose a reason for hiding this comment

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

Like slavalamp said, please update all link variables and keys in this email to conform to our i18n standards for hyperlinks:

Suggested change
<%= t(".activation_support.html", support_link: style_link(t(".activation_support.support_link_text"), new_feedback_report_url)) %>
<%= t(".activation_support.html", contact_support_link: style_link(t(".activation_support.contact_support"), new_feedback_report_url)) %>

Comment on lines 3 to +4
<% if !@user_name.blank? %>
<%= t(".has_invited", user_name: style_bold(@user_name)).html_safe %>
<%= t(".has_invited.html", user_name: style_bold(@user_name)) %>
Copy link
Contributor

Choose a reason for hiding this comment

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

We prefer username without a space, please update these variables here for that

subject: "[%{app_name}][%{collection_title}] Invalid sign-ups found"
invitation:
about:
html: The Archive of Our Own (AO3) is a free, noncommercial archive built by and for fans. Our servers are owned by our parent nonprofit, the %{otw_link}, which works to protect fan rights and preserve fanworks. We welcome all kinds of fanworks, including fanfiction, fanart, fanvids, and podfic from any fandom.
Copy link
Contributor

Choose a reason for hiding this comment

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

In all these strings, please replace "AO3" with the %{app_name} variable and set that to ArchiveConfig.APP_SHORT_NAME instead of using AO3 directly (refer the general i18n guidelines). Same goes for the longform Archive of Our Own, it should be using a variable that is set to ArchiveConfig.APP_NAME


# URL: /rails/mailers/user_mailer/invitation
def invitation_by_other_user
inviting_user = create(:user)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please give this user the for_mailer_preview trait.

faq:
faq_link_text: our FAQ
html: For more information, please check %{faq_link}.
text: For more information, please check %{faq_url}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the exact text to the new location without modifying it:

Suggested change
text: For more information, please check %{faq_url}.
text: 'For more information, please check our FAQ: %{faq_url}.'

join: If you'd like to join us, please %{invitation_link}.
otw_link_text: Organization for Transformative Works
support_link_text: contact Support
text: If you'd like to join us, please follow this link to sign up %{invitation_url}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
text: If you'd like to join us, please follow this link to sign up %{invitation_url}.
text: 'If you''d like to join us, please follow this link to sign up: %{invitation_url}.'

activation_support:
html: After you sign up, you'll receive an account activation email. If you do not receive this email after 48 hours, please %{support_link}.
support_link_text: contact Support
text: After you sign up, you'll receive an account activation email. If you do not receive this email after 48 hours, please %{support_url}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
text: After you sign up, you'll receive an account activation email. If you do not receive this email after 48 hours, please %{support_url}.
text: 'After you sign up, you''ll receive an account activation email. If you do not receive this email after 48 hours, please contact Support: %{support_url}.'

Comment on lines +668 to +670
has_invited:
html: "%{user_name} has invited you to join the Archive of Our Own!"
text: "%{user_name} has invited you to join the Archive of Our Own!"
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is the same text in both emails it can just be one key. If it needs the html suffix to avoid html_safe, make the key has_invited_html instead of giving it variants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants