YesNoOk
#1
15 Replies
Oct 28
2011

User tagging

October 28, 2011, 23:43:11 | by Nightwish
User tagging

The idea isn't new and it has been posted as a feature request for various forum products and I believe, there are at least some mods for it (not for SMF though).

Basically, what user tagging does is kinda simple. Using a special @Name,name1,name2: syntax, the mentioned member names will be converted into user profile links and, if the activity stream feature is enabled, the tagged (or "mentioned") member(s) will receive a notification that someone mentioned them in a message.

Example:

You write: @Velvet: look here... The member name will be converted into a profile link and the member will receive a notification (see attached image).
  • The feature is totally optional. It can be disabled forum-wide with a single check box (in fact, like most of the new features, it is disabled by default and must be explicitly enabled).
  • There is a permission that controls which member groups can use it, so if you wish, you could enable this only for a group of trusted members to prevent new members (possible spammers) from abusing this feature. If a member lacks the necessary permission, tags are simply not parsed at all.
  • The maximum number of unique member IDs that can be tagged in a single message is limited to 10. That should be way, way enough for most situations.
  • The notifications sent out to tagged members depend on the activity stream feature and like all other notifications, users can opt-out from seeing them.
  • You cannot mention or tag yourself (well, obviously... doesn't make sense anyway :) )
  • Member-name matching is case-insensitive, so @nightwish works even when the user name is actually Nightwish.
  • Integrating this into the editor with a possible AJAX-powered lookup and auto-complete is considered, however, I'm a bit unsure about possible performance issues with such a feature. Member table lookups can be heavy, especially when looking for a name, not a member ID.
  • Mis-spelled or non-existing names are filtered out. The message preview will show this, so it's possible to correct it before submitting a message.
  • Tags are converted into profile links when a message is submitted, so when you later modify the message or another user quotes it, the tags are gone, so it isn't possible to get repeated notifications from the very same message.
  • The characters that start and end a user tag are customizable. By default, a double @ will start a user tag, followed by a comma-separated list of one or more user names and finalized by a colon character. This format can be changed though and it is planned to add support to the message editor to allow easy insertion of the necessary code.
  • A message can contain multiple tags with one or more members per tag, but overall, no more than 10 unique users can be tagged in a single message, unless you are the forum administrator or have permission to moderate the board.
The notification will contain a link to the message that contains the tag and like for all other notifications, visiting this link will mark the notification as seen and remove it from the list of unseen notifications.
2 Like It 
Last Edit: May 22, 2015, 21:46:40} by Nightwish
Share this topic:
 

  • avatar
mortons,  January 08, 2012, 19:03:32
Re: User tagging #2
I'm liking what I am seeing, I can't wait for full version, but no pressure.
  • avatar
Suki,  July 12, 2012, 14:21:46
Re: User tagging #3
* Suki ignores the warning because I'm sure I want to reply :P

I'm doing this with a slightly different approach, instead of @@ or some other customized character the username would be wrapped in {} as in {Suki} that is actually because I'm lazy and I don't want to implement the SMF auto-complete thing when an user starts typing a @ nor do I want to implement customizable characters :P

I like all of your ideas, allow me to "borrow" them :P
Nightwish,  July 12, 2012, 16:00:45
Re: User tagging #4
I'm doing this with a slightly different approach, instead of @@ or some other customized character the username would be wrapped in {} as in {Suki} that is actually because I'm lazy and I don't want to implement the SMF auto-complete thing when an user starts typing a @ nor do I want to implement customizable characters :P
Well, I plan to make the pattern customizable - something like {%s:} (where %s is then replaced with the list of users to tag). Right now, it is hardcoded with @@%s:, which is of course a bit ugly. Should be fairly easy, just a matter of modifying the regexp pattern.
Quote
I like all of your ideas, allow me to "borrow" them :P
You can just take a look at the code - all can be found on GitHub and it's open source :) The tagging code isn't exactly complex, it's all in a single function in Subs-Post.php

Of course, without a working notification system, the tagging is not exactly useful
Last Edit: July 12, 2012, 16:16:54 by Nightwish
  • avatar
Valodim,  July 12, 2012, 16:31:00
Re: User tagging #5
Oh, so this is already implemented? I thought it was a planned feature, since that tag above was not linked to a user profile. giving this a shot..

@Nightwish: test~

\\ edit

neat.
Last Edit: July 12, 2012, 16:34:03 by Valodim
Nightwish,  July 12, 2012, 16:40:36
Re: User tagging #6
  • avatar
CamKrist,  May 24, 2013, 13:41:33
Re: User tagging #7
I decided to give a hand and sent a post into social bookmarks. I hope the popularity will rise in.
  • avatar
Suki,  May 24, 2013, 14:19:32
Re: User tagging #8
yeah, most likely a spam user :(

Anyways, for my neeeds I end up using a really nice plugin for notifications: https://github.com/ichord/At.js

The script fetches a list of possible eligible users whenever the textarea is focused using jquery focus() (of course the list is cached) the query returns a json list of users, the noty then inserts the data using a predefined format @(username, ID)  that can be easily converted to a link when parsing. Thats how I solved the space on names issue, of course having a lit of possible users whenever you type @ sure is a nice plus to have :)
Nightwish,  May 24, 2013, 16:42:14
Re: User tagging #9
yeah, most likely a spam user :(
Well, maybe, but since there are no annoying links in the post and new users cannot abuse signatures for spam, I don't mind :)
"Suki" said:
Anyways, for my neeeds I end up using a really nice plugin for notifications: https://github.com/ichord/At.js
That looks good, but imho not enough "lightweight" - maybe it can be stripped down a bit :)

I've planned to use a modified version of the already present username-lookup in SMF (what's being used for adding buddies, for example), but since there are still some unresolved difficulties, it's not yet implemented, so auto-complete doesn't work.

Notifications should, however, work :) @Suki: testing...
  • avatar
Suki,  May 24, 2013, 17:24:13
Re: User tagging #10
Well, thats as far as I could go really, the script itself fires up an ajax call everytime the user types the @, thats cool for simple queries to text files or simple demo pages but for something real like a forum userbase thats just not possible as it would kill the server. Thats why I end up wrapping the ajax call to be fire up only on focus() , that alone drastically reduced the number of ajax request the script does, the retrieved data gets appended to the DOM so all the sorting and juggling are done on client side which is really a nice plus to have.

I certainly don't know how can it be optimized and I only had tested it on local and on my site so I still don't know how it will behave with a large userbase. The things I did to minimize server hits were based upon assumptions and common sense :P

What was really nice is that the script lets you output the data back to the textarea in any way you want, I chose this format because that was an easy way to get the data with regex but I know I could write the data back in a fancy and more stylish way like @username and pass the real data on some hidden post var then do the replace on parsing.

I tried the SMF autosuggest feature, perhaps it was me but I didn't find it easy to customize and besides it wasn't designed to work on textareas.

Nightwish,  May 24, 2013, 18:05:55
Re: User tagging #11
Well, thats as far as I could go really, the script itself fires up an ajax call everytime the user types the @, thats cool for simple queries to text files or simple demo pages but for something real like a forum userbase thats just not possible as it would kill the server. Thats why I end up wrapping the ajax call to be fire up only on focus() , that alone drastically reduced the number of ajax request the script does, the retrieved data gets appended to the DOM so all the sorting and juggling are done on client side which is really a nice plus to have.
But how exactly do you perform the database lookups for the user names?

I know, it's a performance thing - looking up on every letter typed by the user would generate way too many requests, so that's not a solution.

At some point, I had the idea of implementing "lightweight" requests, particularly for requesting json responses. Such a lightweight request would skip all the heavy initializations like loadTheme(), loadBoard() and so on, because this isn't really needed for a simple database lookup. Loading the session, permissions and user data would still be required though, and with some testing, I found out that you don't gain much from skipping a few initializations, so I quickly forgot the idea.

For small forums (probably for the majority of all forums out there) you could simply fetch all username at once and cache them using our caching system - refreshing this cache every couple of hours or maybe every time a new member registers would be enough.

Still, you would need to fetch the username cache when a member performs a lookup and store it somewhere (preferably in the browser to make lookups completely client-sided). With a large member base, the cache could easily be a couple of megabytes in size, but memory isn't really the problem here, it would just generate a lot of traffic.

Quote
I tried the SMF autosuggest feature, perhaps it was me but I didn't find it easy to customize and besides it wasn't designed to work on textareas.
The latter can be done quite easily (just a bit work on the JS). What autosuggest does is that it requires the user to know the first 3 letters of the username - it will only query the database after the first three letters have been typed. This is a reasonable compromise, but with a large member base, the list of names sharing the first three letters can be large enough to present the user a very long list of names.
  • avatar
Suki,  May 25, 2013, 03:41:34
Re: User tagging #12
But how exactly do you perform the database lookups for the user names?

Its just a plain query to the users table, the query fetches the real_name ad the ID and return the data as a json file, the mention script fires an ajx call to this special action and it gets the daa in json format.

This special action handles all my ajax calls https://github.com/MissAllSunday/Breeze/blob/develop/Sources/Breeze/BreezeAjax.php via subactions it strips all data and headers before printing the response back.
Nightwish,  May 26, 2013, 07:06:46
Re: User tagging #13
But how exactly do you perform the database lookups for the user names?

Its just a plain query to the users table, the query fetches the real_name ad the ID and return the data as a json file, the mention script fires an ajx call to this special action and it gets the daa in json format.
But you're returning the entire user db in this call?
  • avatar
Suki,  May 26, 2013, 12:21:58
Re: User tagging #14
Nope, I only fetch active users (is_activated = 1) and users with X post or more where X can be defined by the admin, other than that yes I fetch the entire table. I know this can be a problem with a large forum but then again most of the features on this mod will be a problem with a large forum.
1 Like It 
Nightwish,  May 29, 2013, 00:10:45
Re: User tagging #15
Nope, I only fetch active users (is_activated = 1) and users with X post or more where X can be defined by the admin, other than that yes I fetch the entire table. I know this can be a problem with a large forum but then again most of the features on this mod will be a problem with a large forum.
Well, I always try to avoid potential performance issues, though there are a few, especially with the rating + notifications system in EoS - completely untested, but my guess is that thousands of post ratings every hour (something that can happen on a very busy forum) could pose a potential performance issue.

Simple idea: Why not fetch the user data after the first letter has been typed? This could reduce the number of possible matches significantly. Of course, it would be a problem when the user mistyped the first letter and decides to go back, in which case, you would have to repeat the query for a different starting letter.
  • avatar
Suki,  May 31, 2013, 19:33:26
Re: User tagging #16
I don't know, that would imply having a lot of potential calls to the server if the user is allowed to tag multiple times.  In this kind of cases where theres two options, having a very big query versus having multiple smaller queries I always tend to go for the big single query, specially if this query would be used across several users at the same time (since it would be basically fetching a text file). You can always put limits to the query if things get complicated or disable the ability to tag altogether.
Last Edit: May 31, 2013, 19:36:39 by Suki
0 Members and 2 Guests are viewing this.