{"action":"created","comment":{"url":"https://api.github.com/repos/zendesk/radar/pulls/comments/44325352","id":44325352,"diff_hunk":"@@ -245,13 +282,19 @@ Server.prototype._handleResourceMessage = function(socket, message, messageType)\n       (this.subs[to] ? 'is subscribed' : 'not subscribed')\n     );\n \n-    this._persistClientData(socket, message);\n-    this._storeResource(resource);\n-    this._persistenceSubscribe(resource.to, socket.id);\n-    this._updateLimits(socket, message, resource.options);\n-    this._stampMessage(socket, message);\n-    resource.handleMessage(socket, message);\n-    this.emit(message.op, socket, message);\n+    this._runMiddleware('post', socket, message, messageType, function (err) {","path":"server/server.js","position":139,"original_position":133,"commit_id":"ec7e202ac91af9de3e8cf9570af48cb6715b9d2d","original_commit_id":"c9987bad92086406af75fd81d8d6ae37881a7188","user":{"login":"vanchi-zendesk","id":1341591,"avatar_url":"https://avatars.githubusercontent.com/u/1341591?v=3","gravatar_id":"","url":"https://api.github.com/users/vanchi-zendesk","html_url":"https://github.com/vanchi-zendesk","followers_url":"https://api.github.com/users/vanchi-zendesk/followers","following_url":"https://api.github.com/users/vanchi-zendesk/following{/other_user}","gists_url":"https://api.github.com/users/vanchi-zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/vanchi-zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanchi-zendesk/subscriptions","organizations_url":"https://api.github.com/users/vanchi-zendesk/orgs","repos_url":"https://api.github.com/users/vanchi-zendesk/repos","events_url":"https://api.github.com/users/vanchi-zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/vanchi-zendesk/received_events","type":"User","site_admin":false},"body":"ok, here's a suggestion: call them \"message\" filter and \"resource\" filter maybe. Both are essentially \"before/pre\" filters. All message filters get called upon receipt of the message (maybe in future, after validation). All resource filters get called after message -> resource has been done. Please also add documentation to reflect these changes.","created_at":"2015-11-09T20:19:18Z","updated_at":"2015-11-09T20:19:18Z","html_url":"https://github.com/zendesk/radar/pull/183#discussion_r44325352","pull_request_url":"https://api.github.com/repos/zendesk/radar/pulls/183","_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar/pulls/comments/44325352"},"html":{"href":"https://github.com/zendesk/radar/pull/183#discussion_r44325352"},"pull_request":{"href":"https://api.github.com/repos/zendesk/radar/pulls/183"}}},"pull_request":{"url":"https://api.github.com/repos/zendesk/radar/pulls/183","id":49927449,"html_url":"https://github.com/zendesk/radar/pull/183","diff_url":"https://github.com/zendesk/radar/pull/183.diff","patch_url":"https://github.com/zendesk/radar/pull/183.patch","issue_url":"https://api.github.com/repos/zendesk/radar/issues/183","number":183,"state":"open","locked":false,"title":"Feature suggestion: Filters support","user":{"login":"lucasefe","id":2702,"avatar_url":"https://avatars.githubusercontent.com/u/2702?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasefe","html_url":"https://github.com/lucasefe","followers_url":"https://api.github.com/users/lucasefe/followers","following_url":"https://api.github.com/users/lucasefe/following{/other_user}","gists_url":"https://api.github.com/users/lucasefe/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasefe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasefe/subscriptions","organizations_url":"https://api.github.com/users/lucasefe/orgs","repos_url":"https://api.github.com/users/lucasefe/repos","events_url":"https://api.github.com/users/lucasefe/events{/privacy}","received_events_url":"https://api.github.com/users/lucasefe/received_events","type":"User","site_admin":false},"body":"(UPDATED) \r\n\r\nSo, based on our need to change radar OSS all the time in order to accommodate some of our needs, I'm suggesting adding support for filters, and later implement authentication, quota, limiting or whatever as a filter. \r\n\r\nConsider the following example:\r\n\r\n    var AuthManager = function() { };\r\n\r\n    AuthManager.prototype.pre = function(client, message, options, next) {\r\n        next();\r\n    }\r\n\r\n    AuthManager.prototype.post = function(client, message, options, next) {\r\n        next();\r\n    }\r\n\r\n    var Radar = require('radar').server;\r\n    radarServer = new Radar();\r\n    radarServer.filter(new AuthManager);\r\n\r\nThis interface allows multiple filters, where the order will be respected. \r\n\r\n    radarServer.use(new AuthManager);\r\n    radarServer.use(new QuotaManager);\r\n\r\n### Steps to merge\r\n - [ ] :+1: of the @zendesk/zendesk-radar team\r\n\r\n### Risks\r\n - None\r\n","created_at":"2015-11-06T08:30:05Z","updated_at":"2015-11-09T20:19:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"affef2d73c3af4c46c8d1b060bd2f14e6d37e423","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/zendesk/radar/pulls/183/commits","review_comments_url":"https://api.github.com/repos/zendesk/radar/pulls/183/comments","review_comment_url":"https://api.github.com/repos/zendesk/radar/pulls/comments{/number}","comments_url":"https://api.github.com/repos/zendesk/radar/issues/183/comments","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/ec7e202ac91af9de3e8cf9570af48cb6715b9d2d","head":{"label":"zendesk:lflorio/filters_support","ref":"lflorio/filters_support","sha":"ec7e202ac91af9de3e8cf9570af48cb6715b9d2d","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050800,"name":"radar","full_name":"zendesk/radar","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar","description":"High level API and backend for writing web apps that use push messaging","fork":false,"url":"https://api.github.com/repos/zendesk/radar","forks_url":"https://api.github.com/repos/zendesk/radar/forks","keys_url":"https://api.github.com/repos/zendesk/radar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar/teams","hooks_url":"https://api.github.com/repos/zendesk/radar/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar/events","assignees_url":"https://api.github.com/repos/zendesk/radar/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar/tags","blobs_url":"https://api.github.com/repos/zendesk/radar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar/subscription","commits_url":"https://api.github.com/repos/zendesk/radar/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar/merges","archive_url":"https://api.github.com/repos/zendesk/radar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar/downloads","issues_url":"https://api.github.com/repos/zendesk/radar/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar/releases{/id}","created_at":"2012-10-02T20:15:07Z","updated_at":"2015-11-04T14:02:15Z","pushed_at":"2015-11-09T18:56:14Z","git_url":"git://github.com/zendesk/radar.git","ssh_url":"git@github.com:zendesk/radar.git","clone_url":"https://github.com/zendesk/radar.git","svn_url":"https://github.com/zendesk/radar","homepage":"http://radar.zendesk.com/","size":5392,"stargazers_count":165,"watchers_count":165,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":165,"default_branch":"master"}},"base":{"label":"zendesk:master","ref":"master","sha":"a3e6357567e300e4bdd5562236ac642c860b5114","user":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"repo":{"id":6050800,"name":"radar","full_name":"zendesk/radar","owner":{"login":"zendesk","id":11525,"avatar_url":"https://avatars.githubusercontent.com/u/11525?v=3","gravatar_id":"","url":"https://api.github.com/users/zendesk","html_url":"https://github.com/zendesk","followers_url":"https://api.github.com/users/zendesk/followers","following_url":"https://api.github.com/users/zendesk/following{/other_user}","gists_url":"https://api.github.com/users/zendesk/gists{/gist_id}","starred_url":"https://api.github.com/users/zendesk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zendesk/subscriptions","organizations_url":"https://api.github.com/users/zendesk/orgs","repos_url":"https://api.github.com/users/zendesk/repos","events_url":"https://api.github.com/users/zendesk/events{/privacy}","received_events_url":"https://api.github.com/users/zendesk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/zendesk/radar","description":"High level API and backend for writing web apps that use push messaging","fork":false,"url":"https://api.github.com/repos/zendesk/radar","forks_url":"https://api.github.com/repos/zendesk/radar/forks","keys_url":"https://api.github.com/repos/zendesk/radar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zendesk/radar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zendesk/radar/teams","hooks_url":"https://api.github.com/repos/zendesk/radar/hooks","issue_events_url":"https://api.github.com/repos/zendesk/radar/issues/events{/number}","events_url":"https://api.github.com/repos/zendesk/radar/events","assignees_url":"https://api.github.com/repos/zendesk/radar/assignees{/user}","branches_url":"https://api.github.com/repos/zendesk/radar/branches{/branch}","tags_url":"https://api.github.com/repos/zendesk/radar/tags","blobs_url":"https://api.github.com/repos/zendesk/radar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zendesk/radar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zendesk/radar/git/refs{/sha}","trees_url":"https://api.github.com/repos/zendesk/radar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zendesk/radar/statuses/{sha}","languages_url":"https://api.github.com/repos/zendesk/radar/languages","stargazers_url":"https://api.github.com/repos/zendesk/radar/stargazers","contributors_url":"https://api.github.com/repos/zendesk/radar/contributors","subscribers_url":"https://api.github.com/repos/zendesk/radar/subscribers","subscription_url":"https://api.github.com/repos/zendesk/radar/subscription","commits_url":"https://api.github.com/repos/zendesk/radar/commits{/sha}","git_commits_url":"https://api.github.com/repos/zendesk/radar/git/commits{/sha}","comments_url":"https://api.github.com/repos/zendesk/radar/comments{/number}","issue_comment_url":"https://api.github.com/repos/zendesk/radar/issues/comments{/number}","contents_url":"https://api.github.com/repos/zendesk/radar/contents/{+path}","compare_url":"https://api.github.com/repos/zendesk/radar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zendesk/radar/merges","archive_url":"https://api.github.com/repos/zendesk/radar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zendesk/radar/downloads","issues_url":"https://api.github.com/repos/zendesk/radar/issues{/number}","pulls_url":"https://api.github.com/repos/zendesk/radar/pulls{/number}","milestones_url":"https://api.github.com/repos/zendesk/radar/milestones{/number}","notifications_url":"https://api.github.com/repos/zendesk/radar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zendesk/radar/labels{/name}","releases_url":"https://api.github.com/repos/zendesk/radar/releases{/id}","created_at":"2012-10-02T20:15:07Z","updated_at":"2015-11-04T14:02:15Z","pushed_at":"2015-11-09T18:56:14Z","git_url":"git://github.com/zendesk/radar.git","ssh_url":"git@github.com:zendesk/radar.git","clone_url":"https://github.com/zendesk/radar.git","svn_url":"https://github.com/zendesk/radar","homepage":"http://radar.zendesk.com/","size":5392,"stargazers_count":165,"watchers_count":165,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":9,"forks":23,"open_issues":9,"watchers":165,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/zendesk/radar/pulls/183"},"html":{"href":"https://github.com/zendesk/radar/pull/183"},"issue":{"href":"https://api.github.com/repos/zendesk/radar/issues/183"},"comments":{"href":"https://api.github.com/repos/zendesk/radar/issues/183/comments"},"review_comments":{"href":"https://api.github.com/repos/zendesk/radar/pulls/183/comments"},"review_comment":{"href":"https://api.github.com/repos/zendesk/radar/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/zendesk/radar/pulls/183/commits"},"statuses":{"href":"https://api.github.com/repos/zendesk/radar/statuses/ec7e202ac91af9de3e8cf9570af48cb6715b9d2d"}}}}