{"action":"created","issue":{"url":"https://api.github.com/repos/inaturalist/inaturalist/issues/179","labels_url":"https://api.github.com/repos/inaturalist/inaturalist/issues/179/labels{/name}","comments_url":"https://api.github.com/repos/inaturalist/inaturalist/issues/179/comments","events_url":"https://api.github.com/repos/inaturalist/inaturalist/issues/179/events","html_url":"https://github.com/inaturalist/inaturalist/issues/179","id":23412439,"number":179,"title":"Mentioning Users in Observation Comments","user":{"login":"loarie","id":598026,"avatar_url":"https://avatars.githubusercontent.com/u/598026?v=3","gravatar_id":"","url":"https://api.github.com/users/loarie","html_url":"https://github.com/loarie","followers_url":"https://api.github.com/users/loarie/followers","following_url":"https://api.github.com/users/loarie/following{/other_user}","gists_url":"https://api.github.com/users/loarie/gists{/gist_id}","starred_url":"https://api.github.com/users/loarie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loarie/subscriptions","organizations_url":"https://api.github.com/users/loarie/orgs","repos_url":"https://api.github.com/users/loarie/repos","events_url":"https://api.github.com/users/loarie/events{/privacy}","received_events_url":"https://api.github.com/users/loarie/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/inaturalist/inaturalist/labels/features","name":"features","color":"fbca04"},{"url":"https://api.github.com/repos/inaturalist/inaturalist/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"pleary","id":48566,"avatar_url":"https://avatars.githubusercontent.com/u/48566?v=3","gravatar_id":"","url":"https://api.github.com/users/pleary","html_url":"https://github.com/pleary","followers_url":"https://api.github.com/users/pleary/followers","following_url":"https://api.github.com/users/pleary/following{/other_user}","gists_url":"https://api.github.com/users/pleary/gists{/gist_id}","starred_url":"https://api.github.com/users/pleary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pleary/subscriptions","organizations_url":"https://api.github.com/users/pleary/orgs","repos_url":"https://api.github.com/users/pleary/repos","events_url":"https://api.github.com/users/pleary/events{/privacy}","received_events_url":"https://api.github.com/users/pleary/received_events","type":"User","site_admin":false},"milestone":null,"comments":11,"created_at":"2013-11-27T20:10:52Z","updated_at":"2015-09-15T18:30:30Z","closed_at":null,"body":"Often people don't know how to ID an observation but they know someone who might. \r\n\r\nI propose functionality that would recognize the @login notation in observation comments as a mention. This would render the notation as a hyperlink to a users profile within the comment while subscribing the mentioned user to the observation and generating an update that would appear in their dashboard similar to:\r\n![screen shot 2013-11-27 at 12 02 00 pm](https://f.cloud.github.com/assets/598026/1634669/f6e8ccf0-579e-11e3-87c2-8a96d0287f9e.png)\r\n\r\nImplementation (from Ken-ichi's comment below):\r\n\r\nCreate a plugin that allows any model to have a text field with mentions, so that we can write code like this:\r\n\r\n```\r\nclass Comment < ActiveRecord::Base\r\n  mentions_in :body\r\nend\r\n```\r\n\r\n`mentions_in :attribute_name` should add an `after_save` callback that creates a delayed job to perform the mention scan. The mention scan should look through the record attribute for instances of `@username` and for each user, create an Update for which the resource is the record. So if Jenn mentions kueda in a comment 123, then the Update looks like\r\n\r\n```\r\nsubscriber: kueda\r\nresource: comment 123\r\n```\r\n\r\nThe existing `has_subscribers` module behaves a lot like this and should be a good starting point. Mentioning could then be integrated into a variety of models, definitely Comment and Identification, but also Observation and Post.\r\n\r\nIf you're working on this and you're not Ken-ichi, please do all your work in your own fork and in a separate branch called \"mentions.\""},"comment":{"url":"https://api.github.com/repos/inaturalist/inaturalist/issues/comments/140491613","html_url":"https://github.com/inaturalist/inaturalist/issues/179#issuecomment-140491613","issue_url":"https://api.github.com/repos/inaturalist/inaturalist/issues/179","id":140491613,"user":{"login":"kueda","id":22691,"avatar_url":"https://avatars.githubusercontent.com/u/22691?v=3","gravatar_id":"","url":"https://api.github.com/users/kueda","html_url":"https://github.com/kueda","followers_url":"https://api.github.com/users/kueda/followers","following_url":"https://api.github.com/users/kueda/following{/other_user}","gists_url":"https://api.github.com/users/kueda/gists{/gist_id}","starred_url":"https://api.github.com/users/kueda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kueda/subscriptions","organizations_url":"https://api.github.com/users/kueda/orgs","repos_url":"https://api.github.com/users/kueda/repos","events_url":"https://api.github.com/users/kueda/events{/privacy}","received_events_url":"https://api.github.com/users/kueda/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T18:30:29Z","updated_at":"2015-09-15T18:30:29Z","body":"> At this point I could use a final word on what we want the dashboard and emails to look like.\r\n\r\nI think I prefer the alternative at the end of the spec: mentioning user icon on the left, snippet of text including the mention as the main body of the update, and a small preview of the observation for mentions in comments and IDs. @joellebel , thoughts from UX perspective?\r\n\r\n> I have a few more detail questions. On the dashboard, most items have a gear icon in the top right of each update asking to unsubscribe, but mentions are different in that we have two user settings to manage them. I have disabled the gear icon, but we could use it and just have it say something like 'go to your settings to manage mentions'.\r\n\r\nHaving the gear show a link to http://www.inaturalist.org/users/edit seems ideal to me. Let's do that.\r\n\r\n> If a user is mentioned in a comment, and the comment is later edited to remove the user's mention, should we delete the updates created the first time? (we do the opposite - if a comment doesn't mention a user and later is edited to mention a user, the user will then get updates)\r\n\r\nHm, I feel like we should, thought that sounds really annoying to do. I guess the main problem is when you have an unviewed update that someone mentioned you, then you click through to see it and there's no mention, or the snipped of the text on the dashboard doesn't show the mention. Yeah, I guess we should delete them.\r\n\r\n> What do we do about repeated updates? @alexshepard noted that I can mention someone in a comment their own observation, and they'll get an update about the comment and an update about the mention. Should one take priority? Or should we continue to show both. Maybe a better example is a post from a user you follow that mentions you. You'll get both updates, but the latter will display the user mention with some context rather than the first paragraph.\r\n\r\nHm again. For activity updates like comments, IDs, and mentions, I feel like we should not show duplicates and mentions should get the lowest priority, so if Alex comments on my observation and mentions me, I should get an update about the comment, not the mention. For content updates like observations and posts, I feel like we should show duplicates, so if I follow Alex and he posts and observation that mentions me, I will get the mention update in the header AND the observation update on my dashboard.\r\n\r\n> Similar to this, can I mention the same user in several different comments on the same ticket? I can see a valid use for this - I mention someone and they come and change something. A little later on I get new evidence or something and mention the person to get their attention again for the new detail - which could warrant two separate updates.\r\n\r\nYes, I think we should generate one update per mentioned user per mentionable record, so if I leave 2 comments on an observation and mention Alex in each, he should get 2 updates. If I leave one comment and mention Alex twice in that single comment, he should get 1 update."}}