{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/77308393","id":77308393,"diff_hunk":"@@ -0,0 +1,18 @@\n+module Api\n+  class NotificationsController < BaseController\n+    def notifications_search_conditions\n+      {:user_id => @auth_user_obj.id}\n+    end\n+\n+    def find_notifications(id)\n+      @auth_user_obj.notification_recipients.find(id)\n+    end\n+\n+    def mark_as_seen_resource_notifications(type, id = nil, _data = nil)","path":"app/controllers/api/notifications_controller.rb","position":11,"original_position":11,"commit_id":"e48adf05ed09bfb3838457dadb2f03198246a414","original_commit_id":"e48adf05ed09bfb3838457dadb2f03198246a414","user":{"login":"isimluk","id":6666052,"avatar_url":"https://avatars.githubusercontent.com/u/6666052?v=3","gravatar_id":"","url":"https://api.github.com/users/isimluk","html_url":"https://github.com/isimluk","followers_url":"https://api.github.com/users/isimluk/followers","following_url":"https://api.github.com/users/isimluk/following{/other_user}","gists_url":"https://api.github.com/users/isimluk/gists{/gist_id}","starred_url":"https://api.github.com/users/isimluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isimluk/subscriptions","organizations_url":"https://api.github.com/users/isimluk/orgs","repos_url":"https://api.github.com/users/isimluk/repos","events_url":"https://api.github.com/users/isimluk/events{/privacy}","received_events_url":"https://api.github.com/users/isimluk/received_events","type":"User","site_admin":false},"body":"I have a test for that case called\r\n```\r\nit 'rejects on notification that is not owned by current user' do\r\n```\r\n\r\nWe use `resource_search` here. The `resource_search` uses `find_notifications` that returns only those notifications that are owned by user.","created_at":"2016-09-02T08:08:12Z","updated_at":"2016-09-02T08:08:12Z","html_url":"https://github.com/ManageIQ/manageiq/pull/10696#discussion_r77308393","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/77308393"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/10696#discussion_r77308393"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696","id":82374171,"html_url":"https://github.com/ManageIQ/manageiq/pull/10696","diff_url":"https://github.com/ManageIQ/manageiq/pull/10696.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/10696.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/10696","number":10696,"state":"open","locked":false,"title":"Api for Notification Drawer","user":{"login":"isimluk","id":6666052,"avatar_url":"https://avatars.githubusercontent.com/u/6666052?v=3","gravatar_id":"","url":"https://api.github.com/users/isimluk","html_url":"https://github.com/isimluk","followers_url":"https://api.github.com/users/isimluk/followers","following_url":"https://api.github.com/users/isimluk/following{/other_user}","gists_url":"https://api.github.com/users/isimluk/gists{/gist_id}","starred_url":"https://api.github.com/users/isimluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isimluk/subscriptions","organizations_url":"https://api.github.com/users/isimluk/orgs","repos_url":"https://api.github.com/users/isimluk/repos","events_url":"https://api.github.com/users/isimluk/events{/privacy}","received_events_url":"https://api.github.com/users/isimluk/received_events","type":"User","site_admin":false},"body":"Purpose\r\n-----------------\r\nThe API will be used by UI to fill in the [Patternfly Drawer](https://www.patternfly.org/pattern-library/communication/notification-drawer/#/api). The sample markup wip was in #10055.\r\n\r\n**EDIT**: Firstly, I suggested slightly non-standard API. However after feedback from @abellotti, and hours of head scratching, I concluded it will be better to have /api/notifications behaving 100% consistently with the rest of the rest api.\r\n\r\n**Updated** example output of `GET /api/notifications?expand=resources&attributes=details&filter[]=seen=false`\r\n```\r\n    {\r\n        \"name\": \"notifications\",\r\n        \"count\": 5,\r\n        \"subcount\": 1,\r\n        \"resources\":\r\n        [\r\n            {\r\n                \"href\": \"http://localhost:3000/api/notifications/1000000000013\",\r\n                \"id\": 1000000000013,\r\n                \"notification_id\": 1000000000005,\r\n                \"user_id\": 1000000000001,\r\n                \"seen\": false,\r\n                \"details\":\r\n                {\r\n                    \"level\": \"success\",\r\n                    \"created_at\": \"2016-08-23T07:18:20Z\",\r\n                    \"text\": \"Virtual Machine %{subject} has been powered off\",\r\n                    \"bindings\":\r\n                    {\r\n                        \"subject\":\r\n                        {\r\n                            \"text\": \"smoketest_provider.SmoketestRHEV\",\r\n                            \"link\": \"TODO\"\r\n                        }\r\n                    },\r\n                    \"seen\": false\r\n                },\r\n                \"actions\":\r\n                [\r\n                    {\r\n                        \"name\": \"mark_as_seen\",\r\n                        \"method\": \"post\",\r\n                        \"href\": \"http://localhost:3000/api/notifications/1000000000013\"\r\n                    }\r\n                ]\r\n            },\r\n        ]\r\n    }\r\n```\r\nAs you can see, we expect to text interpolation to be done on the client. That is because we want to render links in future. Also, the internationalization will be done on the client in next stages.\r\n\r\n**Updated** also introduce `mark_as_read` action, that can be used on a single resource or on a collection.\r\n\r\nMark single notification as a seen `POST /api/notifications/:id` body:\r\n```\r\n      { \"action\" : \"mark_as_seen\" }\r\n```\r\nMark set of notifications as a seen `POST /api/notifications` body:\r\n```\r\n      { \"action\" : \"mark_as_seen\",\r\n        \"resources\": [\r\n         { \"href\" : \"http://localhost:3000/api/notifications/:id\" },\r\n         { \"href\" : \"http://localhost:3000/api/notifications/:id\" },\r\n         ...\r\n       ]\r\n      }\r\n```\r\n\r\n@miq-bot add_label api, enhancement, wip, darga/no\r\n@miq-bot assign @skateman \r\n","created_at":"2016-08-23T14:22:25Z","updated_at":"2016-09-02T08:08:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6769eda1406b631d4472f4cc311ff61626a56f55","assignee":{"login":"abellotti","id":5797328,"avatar_url":"https://avatars.githubusercontent.com/u/5797328?v=3","gravatar_id":"","url":"https://api.github.com/users/abellotti","html_url":"https://github.com/abellotti","followers_url":"https://api.github.com/users/abellotti/followers","following_url":"https://api.github.com/users/abellotti/following{/other_user}","gists_url":"https://api.github.com/users/abellotti/gists{/gist_id}","starred_url":"https://api.github.com/users/abellotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abellotti/subscriptions","organizations_url":"https://api.github.com/users/abellotti/orgs","repos_url":"https://api.github.com/users/abellotti/repos","events_url":"https://api.github.com/users/abellotti/events{/privacy}","received_events_url":"https://api.github.com/users/abellotti/received_events","type":"User","site_admin":false},"assignees":[{"login":"abellotti","id":5797328,"avatar_url":"https://avatars.githubusercontent.com/u/5797328?v=3","gravatar_id":"","url":"https://api.github.com/users/abellotti","html_url":"https://github.com/abellotti","followers_url":"https://api.github.com/users/abellotti/followers","following_url":"https://api.github.com/users/abellotti/following{/other_user}","gists_url":"https://api.github.com/users/abellotti/gists{/gist_id}","starred_url":"https://api.github.com/users/abellotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abellotti/subscriptions","organizations_url":"https://api.github.com/users/abellotti/orgs","repos_url":"https://api.github.com/users/abellotti/repos","events_url":"https://api.github.com/users/abellotti/events{/privacy}","received_events_url":"https://api.github.com/users/abellotti/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/10696/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/e48adf05ed09bfb3838457dadb2f03198246a414","head":{"label":"isimluk:async-notification-api","ref":"async-notification-api","sha":"e48adf05ed09bfb3838457dadb2f03198246a414","user":{"login":"isimluk","id":6666052,"avatar_url":"https://avatars.githubusercontent.com/u/6666052?v=3","gravatar_id":"","url":"https://api.github.com/users/isimluk","html_url":"https://github.com/isimluk","followers_url":"https://api.github.com/users/isimluk/followers","following_url":"https://api.github.com/users/isimluk/following{/other_user}","gists_url":"https://api.github.com/users/isimluk/gists{/gist_id}","starred_url":"https://api.github.com/users/isimluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isimluk/subscriptions","organizations_url":"https://api.github.com/users/isimluk/orgs","repos_url":"https://api.github.com/users/isimluk/repos","events_url":"https://api.github.com/users/isimluk/events{/privacy}","received_events_url":"https://api.github.com/users/isimluk/received_events","type":"User","site_admin":false},"repo":{"id":52110040,"name":"manageiq","full_name":"isimluk/manageiq","owner":{"login":"isimluk","id":6666052,"avatar_url":"https://avatars.githubusercontent.com/u/6666052?v=3","gravatar_id":"","url":"https://api.github.com/users/isimluk","html_url":"https://github.com/isimluk","followers_url":"https://api.github.com/users/isimluk/followers","following_url":"https://api.github.com/users/isimluk/following{/other_user}","gists_url":"https://api.github.com/users/isimluk/gists{/gist_id}","starred_url":"https://api.github.com/users/isimluk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isimluk/subscriptions","organizations_url":"https://api.github.com/users/isimluk/orgs","repos_url":"https://api.github.com/users/isimluk/repos","events_url":"https://api.github.com/users/isimluk/events{/privacy}","received_events_url":"https://api.github.com/users/isimluk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/isimluk/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/isimluk/manageiq","forks_url":"https://api.github.com/repos/isimluk/manageiq/forks","keys_url":"https://api.github.com/repos/isimluk/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/isimluk/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/isimluk/manageiq/teams","hooks_url":"https://api.github.com/repos/isimluk/manageiq/hooks","issue_events_url":"https://api.github.com/repos/isimluk/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/isimluk/manageiq/events","assignees_url":"https://api.github.com/repos/isimluk/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/isimluk/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/isimluk/manageiq/tags","blobs_url":"https://api.github.com/repos/isimluk/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/isimluk/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/isimluk/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/isimluk/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/isimluk/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/isimluk/manageiq/languages","stargazers_url":"https://api.github.com/repos/isimluk/manageiq/stargazers","contributors_url":"https://api.github.com/repos/isimluk/manageiq/contributors","subscribers_url":"https://api.github.com/repos/isimluk/manageiq/subscribers","subscription_url":"https://api.github.com/repos/isimluk/manageiq/subscription","commits_url":"https://api.github.com/repos/isimluk/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/isimluk/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/isimluk/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/isimluk/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/isimluk/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/isimluk/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/isimluk/manageiq/merges","archive_url":"https://api.github.com/repos/isimluk/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/isimluk/manageiq/downloads","issues_url":"https://api.github.com/repos/isimluk/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/isimluk/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/isimluk/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/isimluk/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/isimluk/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/isimluk/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/isimluk/manageiq/deployments","created_at":"2016-02-19T19:09:23Z","updated_at":"2016-02-19T19:09:40Z","pushed_at":"2016-09-01T15:37:42Z","git_url":"git://github.com/isimluk/manageiq.git","ssh_url":"git@github.com:isimluk/manageiq.git","clone_url":"https://github.com/isimluk/manageiq.git","svn_url":"https://github.com/isimluk/manageiq","homepage":"manageiq.org","size":151629,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"a156a43ee3c62811674d8cb15f61ee4595b0f662","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Open-Source Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq/deployments","created_at":"2014-06-13T02:31:26Z","updated_at":"2016-09-01T16:18:08Z","pushed_at":"2016-09-02T07:44:22Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":198763,"stargazers_count":312,"watchers_count":312,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":344,"mirror_url":null,"open_issues_count":812,"forks":344,"open_issues":812,"watchers":312,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/10696"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/10696"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/10696/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/10696/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/e48adf05ed09bfb3838457dadb2f03198246a414"}}}}
{"actor":{"display_login":"isimluk"}}