Forem Creators and Builders

loading...
Forem Core Team

Changelog: Notifications for @-Mentions in Posts

vaidehijoshi profile image Vaidehi Joshi ・2 min read

I'm pleased to announce that, starting today, @-mentioning other Forem users in a post will trigger a notification for the mentioned user! This feature mirrors the functionality that already existed when mentioning a user in a comment, and extends that same behavior to posts as well.

How It Works

With this new feature, whenever a user mentions another user in a published post, the mentioned user will receive a notification informing them that they were mentioned.

A published post with an @-mention of another user

A notification icon with a "1" red badge

An @-mention notification

Notably, mentioning another user in a draft post will not trigger any notifications. We've also built this feature to ensure that you will only ever receive one notification per post; if you follow another author and that author mentions you, you will only receive a single @-mention notification (we don't want to spam you with notifications!).

Admin Configuration

We take safety seriously at Forem, and in order to mitigate the risk of potential spam and abuse, we've capped the maximum number of times a user can @-mention other users in posts and comments.

Forem admins can configure this setting in the "Rate Limits & Anti-Spam" section of the Admin Configuration page.

Screenshot of the Rate Limit Mention Creation input on the Admin Guide

How We Built It

For the code curious among us, check out this PR to see how this feature was implemented:

Expand @-mention functionality to posts #13367

What type of PR is this? (check all applicable)

  • [x] Feature

Description

This PR completes the final piece of functionality to fully ship RFC #22! 🥰

Per the RFC's design/definition of done, this PR does the following:

  • [x] Allows articles to have mentions
  • [x] Sends users who are mentioned in an article a single notification
  • [x] Ensures that the correct notification shows up on the mentioned user's /notification page
  • [x] Ensures that a user only receives one notification per article (if a user follows an author/organization but also happen to be @-mentioned in the article, they only receive the @-mention notification, and no other article notifications)
  • [x] Updates relevant views and mailer templates
  • [x] Adds a TON of specs

Related Tickets & Documents

Completes https://github.com/forem/rfcs/pull/22! 🎉

QA Instructions, Screenshots, Recordings

To QA this PR, open up two browser windows, each with two different users. In this case, I have User A (Admin user) and User B (my user, vaidehijoshi).

Part 1: Testing @-mentions while following a user

  1. Start by having User B follow User A. In User A's account, create an article, and mention User B:

Screen Shot 2021-05-10 at 11 07 32 AM

2. Publish the article written by User A:

Screen Shot 2021-05-10 at 11 07 47 AM

3. Go to User B's account, and check that you see a notification icon:

Screen Shot 2021-05-10 at 11 14 36 AM

4. Click on the icon, which takes you to the `/notifications` tab. You should see a notification that tells you that you were mentioned. You SHOULD NOT have received a notification telling you that User A published the article (which you normally would get if you follow User A). Instead, you should _only_ have a notification telling you that you were mentioned in the new post they published:

Screen Shot 2021-05-10 at 11 08 11 AM

5. Clicking on the notification itself should take you to the newly-published article, and you should see your username mentioned 👍🏽

Screen Shot 2021-05-10 at 11 08 27 AM

Part 2: Testing normal article published notifications

  1. Now, create a new article from User A's account. This time, DO NOT mention User B.

Screen Shot 2021-05-10 at 11 15 51 AM

2. In User B's account, check that you see a notification icon:

Screen Shot 2021-05-10 at 11 14 36 AM

3. You should see a normal "article published" notification:

Screen Shot 2021-05-10 at 11 14 45 AM

Part 3: Testing embedded mentions

  1. Find a comment that mentions User B (any comment should do!). For example:

Screen Shot 2021-05-10 at 1 59 12 PM

2. Create a new post from User A's account, using the `{% comment [id] %}` liquid tag syntax:

Screen Shot 2021-05-10 at 1 59 44 PM

3. Go to User B's account; if User B is still following User A, there should be a new notification, but it should NOT be a notification about being @-mentioned. Instead, it should only be a normal "article published" notification, and nothing else.

Screen Shot 2021-05-10 at 2 00 02 PM

4. You can try the same test after making User B "unfollow" User A, at which point User B should receive NO notifications.

Part 4: Other oddities

  1. Try testing this functionality out with both editors; the functionality should be exactly the same:

Screen Shot 2021-05-10 at 11 26 40 AM

Screen Shot 2021-05-10 at 12 59 35 PM

2. Test that a user doesn't get more than one notification, no matter how many times they are mentioned! ALso test that you can't @-mention more than 7 times:

Screen Shot 2021-05-10 at 11 24 05 AM

3. Test that you can [preview the new `new_article_mention_email` mailer](http://localhost:3000/rails/mailers/notify_mailer) locally, and that the job to send the email is enqueued when a mention notification is sent locally.

Screen Shot 2021-05-10 at 11 18 25 AM

Screen Shot 2021-05-10 at 11 31 38 AM

UI accessibility concerns?

This is mostly backend work, and the frontend work is reusing HTML markup code that already exists so, hopefully not!

Added tests?

  • [x] You bet I did 😉

[Forem core team only] How will this change be communicated?

  • [x] I will share this change in a Changelog or in a forem.dev post
  • [x] I will share this change internally with the appropriate teams

Are there any post deployment tasks we need to perform?

Nothing special, nope! Just want to be sure to QA thoroughly and try it out on DEV before rolling it out to the fleet.

What gif best describes this PR or how it makes you feel?

omg sloth

This feature rides on the coattails of the fantastic work that @s_aitchison recently shipped to overhaul our editor's handling of autocomplete for user mentions.

We're very excited to have this highly-requested feature live for all Forem users starting today! As always, you can report any issues in our repository. Please try it out and let us know what you think.

Happy mentioning! 🎉

Discussion (4)

Collapse
michaeltharrington profile image
Michael Tharrington

Love it!!! Thanks for this. 🙂

Collapse
kvaibhav01 profile image
Vaibhav Khulbe

Wonderful! I requested this feature in one of my issues!

Add autocomplete mention for users while writing articles #11635

Is your feature request related to a problem? Please describe.

When I want to add a post of another DEV user, currently I have to copy their profile link and make it look like the person is actually tagged. Like this in markdown:

There is this wonderful post written by [@ vaibhavkhulbe] (dev.to/vaibhavkhulbe).

Describe the solution you'd like

I want that we should have the following feature while we tag others in a post or a comment etc:

  1. As soon as I type '@' and type in a few letters of a username, a list should pop-up of a similar username from which I can pick the one I want.

  2. The tagged person should be notified.

  3. When someone clicks the tagged username, they should be redirected to their profile link.

Describe alternatives you've considered

N/A

Additional context

Here's something similar: Screenshot 2020-11-26 at 11 21 05 PM

Or this: Screenshot 2020-11-26 at 11 21 47 PM

Collapse
thomasbnt profile image
Thomas Bnt

Owwww niiiiiiiiiiiice !

Collapse
lee profile image
Lee

yipee!

Forem Open with the Forem app