Adding a link in the message invitations

AI-generated summary

A discussion is taking place about adding a link to message invitations. j127 noticed that the user_notifications.invited_to_private_message_body template doesn’t allow adding a link to the message. They tried %{base_url}%{url}, but it was invalid. As a workaround, they redirected users to the /my/messages path. However, they hoped to send users directly to the specific message they were invited to.

codinghorror finds it odd that the link isn’t included in the email, prompting techAPJ to investigate and discover a recent regression from the email HTML customization feature. techAPJ created a PR to fix the issue, which was later merged. The fix involves updating the existing user’s invite template to include a topic/PM link, allowing staff to customize the invite email template as needed. j127 is satisfied with the outcome.

When users are invited to a message, it sends them an email with the user_notifications.invited_to_private_message_body template:

%{username} invited you to a message

> **%{topic_title}**
>
> %{topic_excerpt}

at

> %{site_title} -- %{site_description}

Is there a way to add a link to the message in the template? I tried %{base_url}%{url}, but it seems to be invalid for that template.

Users are getting confused, since there is nothing to click. If it isn’t possible to link to the message, I can just send them to the /my/messages path, which seems to redirect them to their messages list.

Do you try to insert the direct link as https://meta.discourse.org or user html

<a href="https://meta.discourse.org">https://meta.discourse.org</a>

Currently, I’ve overridden the template to send users to forum.example.com/my/messages, but that’s just the list of all messages. I’m hoping to send them directly to the specific message that they have been invited to.

It seems odd that we don’t include a link in this email @techAPJ? Can you repro?

Yes, this seems like a recent regression from email HTML customization feature. We used to include “Visit Message” link in email footer, not anymore. Will fix on priority.

PR here:

https://github.com/discourse/discourse/pull/8194

Will merge once the PR is reviewed by @neil.

Note that this change is specific to inviting existing users. Inviting new user via email already includes topic/message link per template.

Instead of adding a new .html.erb template file I updated the existing user’s invite template to include topic/PM link (similar to what we do for new user invite link) in topic title and at the bottom of email. This also allows staff to use and repurpose topic_link as they see fit while customizing invite email template.

Topic:

PM:

Thanks, that looks great.