User mention limit: clarify the error message?

Hello,

There’s a feature in Discourse that limits the number of user mentions in messages, and limits it even more for “new” users (trust level 0).

If you don’t know what I mean, here is the implementation in the source code of Discourse:

That’s a fine feature, but as it happens, we’ve had a few users hit that limit by mistake and being confused. The thing is, they did not mean to mention a user. They just “forgot” (or didn’t know how) to format a snippet of code included in their message, and that snippet being Java code, it included annotations, which start with @ and get interpreted as user mentions.

An example of such code:

public class MyCode {

@NotNull 
private String foo;

@NotNull 
private String bar;

@NotNull 
private String foobar;

}

The error message is simply this:

Sorry, new users can only mention 2 users in a post

You can imagine that a user who is unfamiliar with how to format code in markdown may also be unfamiliar with what a user mention is, and even if they’re familiar with it, they may not understand that what they meant as a Java annotation was interpreted as a user mention.

So… maybe the user experience of that feature can be improved?

We could talk of Discourse automatically detecting source code and suggesting to format it, or highlighting the parts of the message whose validation failed, but either of these solutions would probably require a lot of effort.

I was thinking of just expanding the error message to explain what a user mention is, and maybe give some advice?

So at least this:

Sorry, new users can only mention 2 users in a post.
User mentions are words prefixed with `@`, for example `@johnsmith`.

And maybe even this:

Sorry, new users can only mention 2 users in a post.
User mentions are words prefixed with `@`, for example `@johnsmith`.
If your post includes source code, make sure to surround it with backticks to avoid having parts of your code interpreted as user mentions; see <insert some links to documentation about formatting code on discourse>.

Thoughts, opinions? Should I send a pull request? I’m afraid I can only update the English and French locales, though.

For reference, some examples of confused users:

There is a #theme-component doing that

2 Likes

Thanks! That’s great, I didn’t know it existed. Hopefully it will prevent users from getting in this situation in the first place :slight_smile:

1 Like

If it still remains an issue even with the Unformatted Code Detector theme component, you can also change the text of this message for your site from the /admin/customize/site_texts page, as well as tweaking the newuser max mentions per post admin setting itself if it’s causing more snags than it’s solving. :slight_smile:

3 Likes

Awesome, I didn’t know I could customize just any text appearing in Discourse. Done!

Then I suppose there’s really no need for a pull request :slight_smile:

1 Like