{"action":"created","comment":{"url":"https://api.github.com/repos/spira/spira/pulls/comments/37596032","id":37596032,"diff_hunk":"@@ -0,0 +1,77 @@\n+<?php\n+\n+class ApiDiscussionController extends DiscussionController\n+{\n+    /**\n+     * Get a single discussion.\n+     *\n+     * @param  string $foreignId\n+     * @param  string $page\n+     * @param  int    $perPage\n+     *\n+     * @throws Gdn_UserException\n+     *\n+     * @return void\n+     */\n+    public function getByForeignId($foreignId = '', $page = '', $perPage = 10)\n+    {\n+        if (!$this->isValidUuid($foreignId)) {\n+            throw new Gdn_UserException('Bad Request', 400);\n+        }\n+\n+        if (!array_key_exists('Discussion', $this->Data)) {\n+            $this->setData('Discussion', $this->DiscussionModel->getForeignID($foreignId), true);\n+        }\n+\n+        if (!is_object($this->Discussion)) {\n+            throw notFoundException('Discussion');\n+        }\n+\n+        // Override the per page value with a custom setting\n+        saveToConfig('Vanilla.Comments.PerPage', (int) $perPage, false);\n+        $commentsPerPage = c('Vanilla.Comments.PerPage');\n+\n+        // Add comments per page to the response\n+        $this->setData('CommentsPerPage', $commentsPerPage);\n+\n+        $this->index($this->Discussion->DiscussionID, '', $page);\n+    }\n+\n+    /**\n+     * Delete a single discussion.\n+     *\n+     * @param  string $foreignId\n+     *\n+     * @throws Gdn_UserException\n+     *\n+     * @return void\n+     */\n+    public function deleteByForeignId($foreignId = '')\n+    {\n+        if (!$this->isValidUuid($foreignId)) {\n+            throw new Gdn_UserException('Bad Request', 400);\n+        }\n+\n+        $discussion = $this->DiscussionModel->getForeignID($foreignId);\n+\n+        if (!is_object($discussion)) {\n+            throw notFoundException('Discussion');\n+        }\n+\n+        $this->delete($discussion->DiscussionID);\n+    }\n+\n+    /**\n+     * Checks that a string appears to be in the format of a UUID.\n+     *\n+     * @param  string $uuid\n+     *\n+     * @return bool\n+     */\n+    protected function isValidUuid($uuid)\n+    {\n+        $pattern = '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}';","path":"forum/src/apiextended/controllers/class.apidiscussioncontroller.php","position":73,"original_position":73,"commit_id":"5658eddf0b3943d320af0c19015810cdf90562ee","original_commit_id":"5658eddf0b3943d320af0c19015810cdf90562ee","user":{"login":"xiphiaz","id":721513,"avatar_url":"https://avatars.githubusercontent.com/u/721513?v=3","gravatar_id":"","url":"https://api.github.com/users/xiphiaz","html_url":"https://github.com/xiphiaz","followers_url":"https://api.github.com/users/xiphiaz/followers","following_url":"https://api.github.com/users/xiphiaz/following{/other_user}","gists_url":"https://api.github.com/users/xiphiaz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiphiaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiphiaz/subscriptions","organizations_url":"https://api.github.com/users/xiphiaz/orgs","repos_url":"https://api.github.com/users/xiphiaz/repos","events_url":"https://api.github.com/users/xiphiaz/events{/privacy}","received_events_url":"https://api.github.com/users/xiphiaz/received_events","type":"User","site_admin":false},"body":"Can you use the pattern from Rhumsaa/UUID - `'^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$'`","created_at":"2015-08-21T00:25:31Z","updated_at":"2015-08-21T00:25:31Z","html_url":"https://github.com/spira/spira/pull/182#discussion_r37596032","pull_request_url":"https://api.github.com/repos/spira/spira/pulls/182","_links":{"self":{"href":"https://api.github.com/repos/spira/spira/pulls/comments/37596032"},"html":{"href":"https://github.com/spira/spira/pull/182#discussion_r37596032"},"pull_request":{"href":"https://api.github.com/repos/spira/spira/pulls/182"}}},"pull_request":{"url":"https://api.github.com/repos/spira/spira/pulls/182","id":42911142,"html_url":"https://github.com/spira/spira/pull/182","diff_url":"https://github.com/spira/spira/pull/182.diff","patch_url":"https://github.com/spira/spira/pull/182.patch","issue_url":"https://api.github.com/repos/spira/spira/issues/182","number":182,"state":"open","locked":false,"title":"Feature/vanilla forum article discussion","user":{"login":"artstorm","id":1165965,"avatar_url":"https://avatars.githubusercontent.com/u/1165965?v=3","gravatar_id":"","url":"https://api.github.com/users/artstorm","html_url":"https://github.com/artstorm","followers_url":"https://api.github.com/users/artstorm/followers","following_url":"https://api.github.com/users/artstorm/following{/other_user}","gists_url":"https://api.github.com/users/artstorm/gists{/gist_id}","starred_url":"https://api.github.com/users/artstorm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artstorm/subscriptions","organizations_url":"https://api.github.com/users/artstorm/orgs","repos_url":"https://api.github.com/users/artstorm/repos","events_url":"https://api.github.com/users/artstorm/events{/privacy}","received_events_url":"https://api.github.com/users/artstorm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-20T09:54:39Z","updated_at":"2015-08-21T00:25:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"43fab1818bd81b8ef9e110b94fdecd4534bf7178","assignee":{"login":"xiphiaz","id":721513,"avatar_url":"https://avatars.githubusercontent.com/u/721513?v=3","gravatar_id":"","url":"https://api.github.com/users/xiphiaz","html_url":"https://github.com/xiphiaz","followers_url":"https://api.github.com/users/xiphiaz/followers","following_url":"https://api.github.com/users/xiphiaz/following{/other_user}","gists_url":"https://api.github.com/users/xiphiaz/gists{/gist_id}","starred_url":"https://api.github.com/users/xiphiaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiphiaz/subscriptions","organizations_url":"https://api.github.com/users/xiphiaz/orgs","repos_url":"https://api.github.com/users/xiphiaz/repos","events_url":"https://api.github.com/users/xiphiaz/events{/privacy}","received_events_url":"https://api.github.com/users/xiphiaz/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/spira/spira/pulls/182/commits","review_comments_url":"https://api.github.com/repos/spira/spira/pulls/182/comments","review_comment_url":"https://api.github.com/repos/spira/spira/pulls/comments{/number}","comments_url":"https://api.github.com/repos/spira/spira/issues/182/comments","statuses_url":"https://api.github.com/repos/spira/spira/statuses/5658eddf0b3943d320af0c19015810cdf90562ee","head":{"label":"spira:feature/vanilla-forum-article-discussion","ref":"feature/vanilla-forum-article-discussion","sha":"5658eddf0b3943d320af0c19015810cdf90562ee","user":{"login":"spira","id":12660367,"avatar_url":"https://avatars.githubusercontent.com/u/12660367?v=3","gravatar_id":"","url":"https://api.github.com/users/spira","html_url":"https://github.com/spira","followers_url":"https://api.github.com/users/spira/followers","following_url":"https://api.github.com/users/spira/following{/other_user}","gists_url":"https://api.github.com/users/spira/gists{/gist_id}","starred_url":"https://api.github.com/users/spira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spira/subscriptions","organizations_url":"https://api.github.com/users/spira/orgs","repos_url":"https://api.github.com/users/spira/repos","events_url":"https://api.github.com/users/spira/events{/privacy}","received_events_url":"https://api.github.com/users/spira/received_events","type":"Organization","site_admin":false},"repo":{"id":35469223,"name":"spira","full_name":"spira/spira","owner":{"login":"spira","id":12660367,"avatar_url":"https://avatars.githubusercontent.com/u/12660367?v=3","gravatar_id":"","url":"https://api.github.com/users/spira","html_url":"https://github.com/spira","followers_url":"https://api.github.com/users/spira/followers","following_url":"https://api.github.com/users/spira/following{/other_user}","gists_url":"https://api.github.com/users/spira/gists{/gist_id}","starred_url":"https://api.github.com/users/spira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spira/subscriptions","organizations_url":"https://api.github.com/users/spira/orgs","repos_url":"https://api.github.com/users/spira/repos","events_url":"https://api.github.com/users/spira/events{/privacy}","received_events_url":"https://api.github.com/users/spira/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spira/spira","description":"Lumen + AngularJS with Docker project seed","fork":false,"url":"https://api.github.com/repos/spira/spira","forks_url":"https://api.github.com/repos/spira/spira/forks","keys_url":"https://api.github.com/repos/spira/spira/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spira/spira/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spira/spira/teams","hooks_url":"https://api.github.com/repos/spira/spira/hooks","issue_events_url":"https://api.github.com/repos/spira/spira/issues/events{/number}","events_url":"https://api.github.com/repos/spira/spira/events","assignees_url":"https://api.github.com/repos/spira/spira/assignees{/user}","branches_url":"https://api.github.com/repos/spira/spira/branches{/branch}","tags_url":"https://api.github.com/repos/spira/spira/tags","blobs_url":"https://api.github.com/repos/spira/spira/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spira/spira/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spira/spira/git/refs{/sha}","trees_url":"https://api.github.com/repos/spira/spira/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spira/spira/statuses/{sha}","languages_url":"https://api.github.com/repos/spira/spira/languages","stargazers_url":"https://api.github.com/repos/spira/spira/stargazers","contributors_url":"https://api.github.com/repos/spira/spira/contributors","subscribers_url":"https://api.github.com/repos/spira/spira/subscribers","subscription_url":"https://api.github.com/repos/spira/spira/subscription","commits_url":"https://api.github.com/repos/spira/spira/commits{/sha}","git_commits_url":"https://api.github.com/repos/spira/spira/git/commits{/sha}","comments_url":"https://api.github.com/repos/spira/spira/comments{/number}","issue_comment_url":"https://api.github.com/repos/spira/spira/issues/comments{/number}","contents_url":"https://api.github.com/repos/spira/spira/contents/{+path}","compare_url":"https://api.github.com/repos/spira/spira/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spira/spira/merges","archive_url":"https://api.github.com/repos/spira/spira/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spira/spira/downloads","issues_url":"https://api.github.com/repos/spira/spira/issues{/number}","pulls_url":"https://api.github.com/repos/spira/spira/pulls{/number}","milestones_url":"https://api.github.com/repos/spira/spira/milestones{/number}","notifications_url":"https://api.github.com/repos/spira/spira/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spira/spira/labels{/name}","releases_url":"https://api.github.com/repos/spira/spira/releases{/id}","created_at":"2015-05-12T05:44:10Z","updated_at":"2015-07-03T14:23:58Z","pushed_at":"2015-08-20T23:48:48Z","git_url":"git://github.com/spira/spira.git","ssh_url":"git@github.com:spira/spira.git","clone_url":"https://github.com/spira/spira.git","svn_url":"https://github.com/spira/spira","homepage":"http://spira.github.io","size":5445,"stargazers_count":7,"watchers_count":7,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":7,"default_branch":"master"}},"base":{"label":"spira:master","ref":"master","sha":"da9793255458ed29b8d852f8c1d7fc8f8197f869","user":{"login":"spira","id":12660367,"avatar_url":"https://avatars.githubusercontent.com/u/12660367?v=3","gravatar_id":"","url":"https://api.github.com/users/spira","html_url":"https://github.com/spira","followers_url":"https://api.github.com/users/spira/followers","following_url":"https://api.github.com/users/spira/following{/other_user}","gists_url":"https://api.github.com/users/spira/gists{/gist_id}","starred_url":"https://api.github.com/users/spira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spira/subscriptions","organizations_url":"https://api.github.com/users/spira/orgs","repos_url":"https://api.github.com/users/spira/repos","events_url":"https://api.github.com/users/spira/events{/privacy}","received_events_url":"https://api.github.com/users/spira/received_events","type":"Organization","site_admin":false},"repo":{"id":35469223,"name":"spira","full_name":"spira/spira","owner":{"login":"spira","id":12660367,"avatar_url":"https://avatars.githubusercontent.com/u/12660367?v=3","gravatar_id":"","url":"https://api.github.com/users/spira","html_url":"https://github.com/spira","followers_url":"https://api.github.com/users/spira/followers","following_url":"https://api.github.com/users/spira/following{/other_user}","gists_url":"https://api.github.com/users/spira/gists{/gist_id}","starred_url":"https://api.github.com/users/spira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spira/subscriptions","organizations_url":"https://api.github.com/users/spira/orgs","repos_url":"https://api.github.com/users/spira/repos","events_url":"https://api.github.com/users/spira/events{/privacy}","received_events_url":"https://api.github.com/users/spira/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spira/spira","description":"Lumen + AngularJS with Docker project seed","fork":false,"url":"https://api.github.com/repos/spira/spira","forks_url":"https://api.github.com/repos/spira/spira/forks","keys_url":"https://api.github.com/repos/spira/spira/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spira/spira/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spira/spira/teams","hooks_url":"https://api.github.com/repos/spira/spira/hooks","issue_events_url":"https://api.github.com/repos/spira/spira/issues/events{/number}","events_url":"https://api.github.com/repos/spira/spira/events","assignees_url":"https://api.github.com/repos/spira/spira/assignees{/user}","branches_url":"https://api.github.com/repos/spira/spira/branches{/branch}","tags_url":"https://api.github.com/repos/spira/spira/tags","blobs_url":"https://api.github.com/repos/spira/spira/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spira/spira/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spira/spira/git/refs{/sha}","trees_url":"https://api.github.com/repos/spira/spira/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spira/spira/statuses/{sha}","languages_url":"https://api.github.com/repos/spira/spira/languages","stargazers_url":"https://api.github.com/repos/spira/spira/stargazers","contributors_url":"https://api.github.com/repos/spira/spira/contributors","subscribers_url":"https://api.github.com/repos/spira/spira/subscribers","subscription_url":"https://api.github.com/repos/spira/spira/subscription","commits_url":"https://api.github.com/repos/spira/spira/commits{/sha}","git_commits_url":"https://api.github.com/repos/spira/spira/git/commits{/sha}","comments_url":"https://api.github.com/repos/spira/spira/comments{/number}","issue_comment_url":"https://api.github.com/repos/spira/spira/issues/comments{/number}","contents_url":"https://api.github.com/repos/spira/spira/contents/{+path}","compare_url":"https://api.github.com/repos/spira/spira/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spira/spira/merges","archive_url":"https://api.github.com/repos/spira/spira/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spira/spira/downloads","issues_url":"https://api.github.com/repos/spira/spira/issues{/number}","pulls_url":"https://api.github.com/repos/spira/spira/pulls{/number}","milestones_url":"https://api.github.com/repos/spira/spira/milestones{/number}","notifications_url":"https://api.github.com/repos/spira/spira/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spira/spira/labels{/name}","releases_url":"https://api.github.com/repos/spira/spira/releases{/id}","created_at":"2015-05-12T05:44:10Z","updated_at":"2015-07-03T14:23:58Z","pushed_at":"2015-08-20T23:48:48Z","git_url":"git://github.com/spira/spira.git","ssh_url":"git@github.com:spira/spira.git","clone_url":"https://github.com/spira/spira.git","svn_url":"https://github.com/spira/spira","homepage":"http://spira.github.io","size":5445,"stargazers_count":7,"watchers_count":7,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":9,"forks":4,"open_issues":9,"watchers":7,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spira/spira/pulls/182"},"html":{"href":"https://github.com/spira/spira/pull/182"},"issue":{"href":"https://api.github.com/repos/spira/spira/issues/182"},"comments":{"href":"https://api.github.com/repos/spira/spira/issues/182/comments"},"review_comments":{"href":"https://api.github.com/repos/spira/spira/pulls/182/comments"},"review_comment":{"href":"https://api.github.com/repos/spira/spira/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/spira/spira/pulls/182/commits"},"statuses":{"href":"https://api.github.com/repos/spira/spira/statuses/5658eddf0b3943d320af0c19015810cdf90562ee"}}}}