{"action":"created","comment":{"url":"https://api.github.com/repos/diaspora/diaspora/pulls/comments/72975943","id":72975943,"diff_hunk":"@@ -13,19 +13,26 @@ def deleted_translation_key\n     end\n \n     def linked_object\n-      target.post\n+      target.mentions_container\n     end\n \n     def self.notify(mentionable, recipient_user_ids)\n       actor = mentionable.author\n+      relevant_mentions = filter_mentions(\n+        mentionable.mentions.local.where.not(person: mentionable.author),\n+        mentionable,\n+        recipient_user_ids\n+      )\n \n-      mentionable.mentions.select {|mention| mention.person.local? }.each do |mention|\n+      relevant_mentions.each do |mention|\n         recipient = mention.person\n-\n-        next if recipient == actor || !(mentionable.public || recipient_user_ids.include?(recipient.owner_id))\n-\n         create_notification(recipient.owner_id, mention, actor).email_the_user(mention, actor)\n       end\n     end\n+\n+    def self.filter_mentions(mentions, mentionable, recipient_user_ids)","path":"app/models/notifications/mentioned.rb","position":26,"original_position":26,"commit_id":"dd54baa79b83e39fc48adbbadbb2a0183de740dc","original_commit_id":"0b948e5a6d01a23a5184c8ed934f06bfc17294ea","user":{"login":"cmrd-senya","id":10187586,"avatar_url":"https://avatars.githubusercontent.com/u/10187586?v=3","gravatar_id":"","url":"https://api.github.com/users/cmrd-senya","html_url":"https://github.com/cmrd-senya","followers_url":"https://api.github.com/users/cmrd-senya/followers","following_url":"https://api.github.com/users/cmrd-senya/following{/other_user}","gists_url":"https://api.github.com/users/cmrd-senya/gists{/gist_id}","starred_url":"https://api.github.com/users/cmrd-senya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmrd-senya/subscriptions","organizations_url":"https://api.github.com/users/cmrd-senya/orgs","repos_url":"https://api.github.com/users/cmrd-senya/repos","events_url":"https://api.github.com/users/cmrd-senya/events{/privacy}","received_events_url":"https://api.github.com/users/cmrd-senya/received_events","type":"User","site_admin":false},"body":"Sounds convincing. So is everybody ok with putting the shared module with common code in `app/models/notification`? I think I can call it `MentionedShared` or `MentionedCommon`, or something like that.\r\n\r\nI see that we already have some extension modules for `User` in our `app/models/user` folder which I can consider as an acceptable decision then.","created_at":"2016-08-01T13:20:11Z","updated_at":"2016-08-01T13:20:11Z","html_url":"https://github.com/diaspora/diaspora/pull/6818#discussion_r72975943","pull_request_url":"https://api.github.com/repos/diaspora/diaspora/pulls/6818","_links":{"self":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/comments/72975943"},"html":{"href":"https://github.com/diaspora/diaspora/pull/6818#discussion_r72975943"},"pull_request":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/6818"}}},"pull_request":{"url":"https://api.github.com/repos/diaspora/diaspora/pulls/6818","id":68418226,"html_url":"https://github.com/diaspora/diaspora/pull/6818","diff_url":"https://github.com/diaspora/diaspora/pull/6818.diff","patch_url":"https://github.com/diaspora/diaspora/pull/6818.patch","issue_url":"https://api.github.com/repos/diaspora/diaspora/issues/6818","number":6818,"state":"open","locked":false,"title":"[WIP] Mentions in comments backend changes","user":{"login":"cmrd-senya","id":10187586,"avatar_url":"https://avatars.githubusercontent.com/u/10187586?v=3","gravatar_id":"","url":"https://api.github.com/users/cmrd-senya","html_url":"https://github.com/cmrd-senya","followers_url":"https://api.github.com/users/cmrd-senya/followers","following_url":"https://api.github.com/users/cmrd-senya/following{/other_user}","gists_url":"https://api.github.com/users/cmrd-senya/gists{/gist_id}","starred_url":"https://api.github.com/users/cmrd-senya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmrd-senya/subscriptions","organizations_url":"https://api.github.com/users/cmrd-senya/orgs","repos_url":"https://api.github.com/users/cmrd-senya/repos","events_url":"https://api.github.com/users/cmrd-senya/events{/privacy}","received_events_url":"https://api.github.com/users/cmrd-senya/received_events","type":"User","site_admin":false},"body":"This is an early preliminary PR with backend-changes to support mentions in comments (#1851).\r\n\r\nIt introduces changes to the DB schema making Mention model polymorphic and allowing a mention to belong to a comment. It also creates module Diaspora::MentionsContainer which incapsulates the logic of an object that supports keeping mentions. Now it includes logic I picked from the StatusMessage model.\r\n\r\nATM the mentions in comments are supported to the extent of placing user profile links instead of mention code in the mobile version (it is so because the mobile version doesn't require javascript code changes).\r\n\r\nTODO:\r\n- [x] Implement notifications for mentioning in comments\r\n- [x] Implement restrictions of mentioning some kind of people (see [comment](https://github.com/diaspora/diaspora/issues/1851#issuecomment-36557842))\r\n- [x] Ensure comment is federated to new discussion participants\r\n- [ ] Ensure mentions in comment are filtered on federation receive\r\n- [ ] Ensure the filtered out mentions are replaced with links properly\r\n- [ ] Don't send redundant second notification when mentioned in comment.\r\n- [ ] Ensure email notifications work properly\r\n- [ ] ~~Implement frontend javascript changes for comments publisher~~","created_at":"2016-04-29T19:00:47Z","updated_at":"2016-08-01T13:20:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a42a26e0ccb4c9878f6e38b9418dba56a09509a3","assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/diaspora/diaspora/milestones/23","html_url":"https://github.com/diaspora/diaspora/milestones/0.7.0.0","labels_url":"https://api.github.com/repos/diaspora/diaspora/milestones/23/labels","id":1580816,"number":23,"title":"0.7.0.0","description":"","creator":{"login":"denschub","id":344777,"avatar_url":"https://avatars.githubusercontent.com/u/344777?v=3","gravatar_id":"","url":"https://api.github.com/users/denschub","html_url":"https://github.com/denschub","followers_url":"https://api.github.com/users/denschub/followers","following_url":"https://api.github.com/users/denschub/following{/other_user}","gists_url":"https://api.github.com/users/denschub/gists{/gist_id}","starred_url":"https://api.github.com/users/denschub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/denschub/subscriptions","organizations_url":"https://api.github.com/users/denschub/orgs","repos_url":"https://api.github.com/users/denschub/repos","events_url":"https://api.github.com/users/denschub/events{/privacy}","received_events_url":"https://api.github.com/users/denschub/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":0,"state":"open","created_at":"2016-02-13T03:23:01Z","updated_at":"2016-07-11T20:34:55Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/diaspora/diaspora/pulls/6818/commits","review_comments_url":"https://api.github.com/repos/diaspora/diaspora/pulls/6818/comments","review_comment_url":"https://api.github.com/repos/diaspora/diaspora/pulls/comments{/number}","comments_url":"https://api.github.com/repos/diaspora/diaspora/issues/6818/comments","statuses_url":"https://api.github.com/repos/diaspora/diaspora/statuses/dd54baa79b83e39fc48adbbadbb2a0183de740dc","head":{"label":"cmrd-senya:1851-mentions-in-comments.new","ref":"1851-mentions-in-comments.new","sha":"dd54baa79b83e39fc48adbbadbb2a0183de740dc","user":{"login":"cmrd-senya","id":10187586,"avatar_url":"https://avatars.githubusercontent.com/u/10187586?v=3","gravatar_id":"","url":"https://api.github.com/users/cmrd-senya","html_url":"https://github.com/cmrd-senya","followers_url":"https://api.github.com/users/cmrd-senya/followers","following_url":"https://api.github.com/users/cmrd-senya/following{/other_user}","gists_url":"https://api.github.com/users/cmrd-senya/gists{/gist_id}","starred_url":"https://api.github.com/users/cmrd-senya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmrd-senya/subscriptions","organizations_url":"https://api.github.com/users/cmrd-senya/orgs","repos_url":"https://api.github.com/users/cmrd-senya/repos","events_url":"https://api.github.com/users/cmrd-senya/events{/privacy}","received_events_url":"https://api.github.com/users/cmrd-senya/received_events","type":"User","site_admin":false},"repo":{"id":38250193,"name":"diaspora","full_name":"cmrd-senya/diaspora","owner":{"login":"cmrd-senya","id":10187586,"avatar_url":"https://avatars.githubusercontent.com/u/10187586?v=3","gravatar_id":"","url":"https://api.github.com/users/cmrd-senya","html_url":"https://github.com/cmrd-senya","followers_url":"https://api.github.com/users/cmrd-senya/followers","following_url":"https://api.github.com/users/cmrd-senya/following{/other_user}","gists_url":"https://api.github.com/users/cmrd-senya/gists{/gist_id}","starred_url":"https://api.github.com/users/cmrd-senya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmrd-senya/subscriptions","organizations_url":"https://api.github.com/users/cmrd-senya/orgs","repos_url":"https://api.github.com/users/cmrd-senya/repos","events_url":"https://api.github.com/users/cmrd-senya/events{/privacy}","received_events_url":"https://api.github.com/users/cmrd-senya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmrd-senya/diaspora","description":"Distributed and contextual social networking","fork":true,"url":"https://api.github.com/repos/cmrd-senya/diaspora","forks_url":"https://api.github.com/repos/cmrd-senya/diaspora/forks","keys_url":"https://api.github.com/repos/cmrd-senya/diaspora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmrd-senya/diaspora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmrd-senya/diaspora/teams","hooks_url":"https://api.github.com/repos/cmrd-senya/diaspora/hooks","issue_events_url":"https://api.github.com/repos/cmrd-senya/diaspora/issues/events{/number}","events_url":"https://api.github.com/repos/cmrd-senya/diaspora/events","assignees_url":"https://api.github.com/repos/cmrd-senya/diaspora/assignees{/user}","branches_url":"https://api.github.com/repos/cmrd-senya/diaspora/branches{/branch}","tags_url":"https://api.github.com/repos/cmrd-senya/diaspora/tags","blobs_url":"https://api.github.com/repos/cmrd-senya/diaspora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmrd-senya/diaspora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmrd-senya/diaspora/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmrd-senya/diaspora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmrd-senya/diaspora/statuses/{sha}","languages_url":"https://api.github.com/repos/cmrd-senya/diaspora/languages","stargazers_url":"https://api.github.com/repos/cmrd-senya/diaspora/stargazers","contributors_url":"https://api.github.com/repos/cmrd-senya/diaspora/contributors","subscribers_url":"https://api.github.com/repos/cmrd-senya/diaspora/subscribers","subscription_url":"https://api.github.com/repos/cmrd-senya/diaspora/subscription","commits_url":"https://api.github.com/repos/cmrd-senya/diaspora/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmrd-senya/diaspora/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmrd-senya/diaspora/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmrd-senya/diaspora/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmrd-senya/diaspora/contents/{+path}","compare_url":"https://api.github.com/repos/cmrd-senya/diaspora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmrd-senya/diaspora/merges","archive_url":"https://api.github.com/repos/cmrd-senya/diaspora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmrd-senya/diaspora/downloads","issues_url":"https://api.github.com/repos/cmrd-senya/diaspora/issues{/number}","pulls_url":"https://api.github.com/repos/cmrd-senya/diaspora/pulls{/number}","milestones_url":"https://api.github.com/repos/cmrd-senya/diaspora/milestones{/number}","notifications_url":"https://api.github.com/repos/cmrd-senya/diaspora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmrd-senya/diaspora/labels{/name}","releases_url":"https://api.github.com/repos/cmrd-senya/diaspora/releases{/id}","deployments_url":"https://api.github.com/repos/cmrd-senya/diaspora/deployments","created_at":"2015-06-29T13:51:58Z","updated_at":"2016-04-01T15:23:28Z","pushed_at":"2016-07-29T17:52:10Z","git_url":"git://github.com/cmrd-senya/diaspora.git","ssh_url":"git@github.com:cmrd-senya/diaspora.git","clone_url":"https://github.com/cmrd-senya/diaspora.git","svn_url":"https://github.com/cmrd-senya/diaspora","homepage":"https://diasporafoundation.org/","size":98765,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"stable"}},"base":{"label":"diaspora:develop","ref":"develop","sha":"c5849b47243d94a005ba497622c5a5ed2686fda7","user":{"login":"diaspora","id":293207,"avatar_url":"https://avatars.githubusercontent.com/u/293207?v=3","gravatar_id":"","url":"https://api.github.com/users/diaspora","html_url":"https://github.com/diaspora","followers_url":"https://api.github.com/users/diaspora/followers","following_url":"https://api.github.com/users/diaspora/following{/other_user}","gists_url":"https://api.github.com/users/diaspora/gists{/gist_id}","starred_url":"https://api.github.com/users/diaspora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diaspora/subscriptions","organizations_url":"https://api.github.com/users/diaspora/orgs","repos_url":"https://api.github.com/users/diaspora/repos","events_url":"https://api.github.com/users/diaspora/events{/privacy}","received_events_url":"https://api.github.com/users/diaspora/received_events","type":"Organization","site_admin":false},"repo":{"id":911765,"name":"diaspora","full_name":"diaspora/diaspora","owner":{"login":"diaspora","id":293207,"avatar_url":"https://avatars.githubusercontent.com/u/293207?v=3","gravatar_id":"","url":"https://api.github.com/users/diaspora","html_url":"https://github.com/diaspora","followers_url":"https://api.github.com/users/diaspora/followers","following_url":"https://api.github.com/users/diaspora/following{/other_user}","gists_url":"https://api.github.com/users/diaspora/gists{/gist_id}","starred_url":"https://api.github.com/users/diaspora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diaspora/subscriptions","organizations_url":"https://api.github.com/users/diaspora/orgs","repos_url":"https://api.github.com/users/diaspora/repos","events_url":"https://api.github.com/users/diaspora/events{/privacy}","received_events_url":"https://api.github.com/users/diaspora/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/diaspora/diaspora","description":"A privacy-aware, distributed, open source social network.","fork":false,"url":"https://api.github.com/repos/diaspora/diaspora","forks_url":"https://api.github.com/repos/diaspora/diaspora/forks","keys_url":"https://api.github.com/repos/diaspora/diaspora/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diaspora/diaspora/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diaspora/diaspora/teams","hooks_url":"https://api.github.com/repos/diaspora/diaspora/hooks","issue_events_url":"https://api.github.com/repos/diaspora/diaspora/issues/events{/number}","events_url":"https://api.github.com/repos/diaspora/diaspora/events","assignees_url":"https://api.github.com/repos/diaspora/diaspora/assignees{/user}","branches_url":"https://api.github.com/repos/diaspora/diaspora/branches{/branch}","tags_url":"https://api.github.com/repos/diaspora/diaspora/tags","blobs_url":"https://api.github.com/repos/diaspora/diaspora/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diaspora/diaspora/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diaspora/diaspora/git/refs{/sha}","trees_url":"https://api.github.com/repos/diaspora/diaspora/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diaspora/diaspora/statuses/{sha}","languages_url":"https://api.github.com/repos/diaspora/diaspora/languages","stargazers_url":"https://api.github.com/repos/diaspora/diaspora/stargazers","contributors_url":"https://api.github.com/repos/diaspora/diaspora/contributors","subscribers_url":"https://api.github.com/repos/diaspora/diaspora/subscribers","subscription_url":"https://api.github.com/repos/diaspora/diaspora/subscription","commits_url":"https://api.github.com/repos/diaspora/diaspora/commits{/sha}","git_commits_url":"https://api.github.com/repos/diaspora/diaspora/git/commits{/sha}","comments_url":"https://api.github.com/repos/diaspora/diaspora/comments{/number}","issue_comment_url":"https://api.github.com/repos/diaspora/diaspora/issues/comments{/number}","contents_url":"https://api.github.com/repos/diaspora/diaspora/contents/{+path}","compare_url":"https://api.github.com/repos/diaspora/diaspora/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diaspora/diaspora/merges","archive_url":"https://api.github.com/repos/diaspora/diaspora/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diaspora/diaspora/downloads","issues_url":"https://api.github.com/repos/diaspora/diaspora/issues{/number}","pulls_url":"https://api.github.com/repos/diaspora/diaspora/pulls{/number}","milestones_url":"https://api.github.com/repos/diaspora/diaspora/milestones{/number}","notifications_url":"https://api.github.com/repos/diaspora/diaspora/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diaspora/diaspora/labels{/name}","releases_url":"https://api.github.com/repos/diaspora/diaspora/releases{/id}","deployments_url":"https://api.github.com/repos/diaspora/diaspora/deployments","created_at":"2010-09-15T05:20:04Z","updated_at":"2016-07-31T10:53:01Z","pushed_at":"2016-08-01T11:27:46Z","git_url":"git://github.com/diaspora/diaspora.git","ssh_url":"git@github.com:diaspora/diaspora.git","clone_url":"https://github.com/diaspora/diaspora.git","svn_url":"https://github.com/diaspora/diaspora","homepage":"https://diasporafoundation.org/","size":243518,"stargazers_count":10816,"watchers_count":10816,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2770,"mirror_url":null,"open_issues_count":414,"forks":2770,"open_issues":414,"watchers":10816,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/6818"},"html":{"href":"https://github.com/diaspora/diaspora/pull/6818"},"issue":{"href":"https://api.github.com/repos/diaspora/diaspora/issues/6818"},"comments":{"href":"https://api.github.com/repos/diaspora/diaspora/issues/6818/comments"},"review_comments":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/6818/comments"},"review_comment":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/diaspora/diaspora/pulls/6818/commits"},"statuses":{"href":"https://api.github.com/repos/diaspora/diaspora/statuses/dd54baa79b83e39fc48adbbadbb2a0183de740dc"}}}}
{"actor":{"display_login":"cmrd-senya"}}