{"action":"created","comment":{"url":"https://api.github.com/repos/vanilla/vanilla/pulls/comments/137829978","pull_request_review_id":61552400,"id":137829978,"diff_hunk":"@@ -0,0 +1,115 @@\n+<?php\n+/**\n+ * @author Alexandre (DaazKu) Chouinard <alexandre.c@vanillaforums.com>\n+ * @copyright 2009-2017 Vanilla Forums Inc.\n+ * @license GPLv2\n+ */\n+\n+namespace VanillaTests\\APIv2;\n+\n+/**\n+ * Test the /api/v2/messages endpoints.\n+ */\n+class MessagesTest extends AbstractResourceTest {\n+\n+    private static $userID;\n+\n+    private static $conversationID;\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function __construct($name = null, array $data = [], $dataName = '') {\n+        $this->baseUrl = '/messages';\n+\n+        parent::__construct($name, $data, $dataName);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public static function setUpBeforeClass() {\n+        parent::setupBeforeClass();\n+\n+        /** @var \\UsersApiController $usersAPIController */\n+        $usersAPIController = static::container()->get('UsersAPIController');\n+\n+        $user = $usersAPIController->post([\n+            'name' => \"MessagesUser1\",\n+            'email' => \"MessagesUser1@example.com\",\n+            'password' => \"$%#$&ADSFBNYI*&WBV1\",\n+        ]);\n+        self::$userID = $user['userID'];\n+\n+        /** @var \\ConversationsApiController $conversationsAPiController */\n+        $conversationsAPiController = static::container()->get('ConversationsAPiController');\n+\n+        $conversation = $conversationsAPiController->post([\n+            'participantIDs' => [self::$userID]\n+        ]);\n+        self::$conversationID = $conversation['conversationID'];\n+\n+        // Disable email sending.\n+        /** @var \\Gdn_Configuration $config */\n+        $config = static::container()->get('Config');\n+        $config->set('Garden.Email.Disabled', true, true, false);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function record() {\n+        return array_merge(parent::record(), ['conversationID' => self::$conversationID]);\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function indexUrl() {\n+        $indexUrl = $this->baseUrl;\n+        $indexUrl .= '?'.http_build_query(['conversationID' => self::$conversationID]);\n+        return $indexUrl;\n+    }\n+\n+ /**\n+     * {@inheritdoc}\n+     */\n+    public function testDelete() {","path":"tests/APIv2/MessagesTest.php","position":77,"original_position":77,"commit_id":"af02e374368e3a4e592ba972ec5c4e037df053f8","original_commit_id":"af02e374368e3a4e592ba972ec5c4e037df053f8","user":{"login":"DaazKu","id":2412909,"avatar_url":"https://avatars0.githubusercontent.com/u/2412909?v=4","gravatar_id":"","url":"https://api.github.com/users/DaazKu","html_url":"https://github.com/DaazKu","followers_url":"https://api.github.com/users/DaazKu/followers","following_url":"https://api.github.com/users/DaazKu/following{/other_user}","gists_url":"https://api.github.com/users/DaazKu/gists{/gist_id}","starred_url":"https://api.github.com/users/DaazKu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaazKu/subscriptions","organizations_url":"https://api.github.com/users/DaazKu/orgs","repos_url":"https://api.github.com/users/DaazKu/repos","events_url":"https://api.github.com/users/DaazKu/events{/privacy}","received_events_url":"https://api.github.com/users/DaazKu/received_events","type":"User","site_admin":false},"body":"I totally misread that. That's way better actually.","created_at":"2017-09-08T16:11:10Z","updated_at":"2017-09-08T16:11:10Z","html_url":"https://github.com/vanilla/vanilla/pull/5929#discussion_r137829978","pull_request_url":"https://api.github.com/repos/vanilla/vanilla/pulls/5929","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/comments/137829978"},"html":{"href":"https://github.com/vanilla/vanilla/pull/5929#discussion_r137829978"},"pull_request":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/5929"}},"in_reply_to_id":137632094},"pull_request":{"url":"https://api.github.com/repos/vanilla/vanilla/pulls/5929","id":139430171,"html_url":"https://github.com/vanilla/vanilla/pull/5929","diff_url":"https://github.com/vanilla/vanilla/pull/5929.diff","patch_url":"https://github.com/vanilla/vanilla/pull/5929.patch","issue_url":"https://api.github.com/repos/vanilla/vanilla/issues/5929","number":5929,"state":"open","locked":false,"title":"Add conversations and messages API controllers","user":{"login":"DaazKu","id":2412909,"avatar_url":"https://avatars0.githubusercontent.com/u/2412909?v=4","gravatar_id":"","url":"https://api.github.com/users/DaazKu","html_url":"https://github.com/DaazKu","followers_url":"https://api.github.com/users/DaazKu/followers","following_url":"https://api.github.com/users/DaazKu/following{/other_user}","gists_url":"https://api.github.com/users/DaazKu/gists{/gist_id}","starred_url":"https://api.github.com/users/DaazKu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DaazKu/subscriptions","organizations_url":"https://api.github.com/users/DaazKu/orgs","repos_url":"https://api.github.com/users/DaazKu/repos","events_url":"https://api.github.com/users/DaazKu/events{/privacy}","received_events_url":"https://api.github.com/users/DaazKu/received_events","type":"User","site_admin":false},"body":"**The blockers need to be merged before this can be fully reviewed.**\r\n\r\nCreates 2 new API Controllers and their unit tests.\r\n\r\nYou can see that we used Message instead of ConversationMessage. We want the API to be simple for the user and ConversationMessage was a bad name. We know that we have a \"message\" feature in Vanilla but that will called something else. (alert, info, sitemessage...)\r\nThis was requested by Todd.\r\n\r\nI could not use the `AbstractApiController` class for the Conversation message because it was assuming too many things about the controller. A refactoring of the base class will be likely needed if we want to accommodate controllers.\r\n\r\nNote that the unit tests are using other controllers to setup themselves. That was a first and I had to make it work properly! See #5926\r\n\r\nUnit tests were also hanging out for no apparent reason. I thought it was because of a recursion with that could have happen with this fix #5928 while being in the unit test environment but it turned out to be because of the `$email->send()` function that was waiting for a timeout.\r\n\r\nSpeaking of unit tests I [made an improvement](https://github.com/vanilla/vanilla/pull/5931) on error reporting because debugging them while testing the API v2 was laborious.\r\n\r\nThere are missing methods on the controllers because the model does not handle them properly.\r\n\r\nAt first I made the controller work as the model did. That means that we had to supply a message with the first conversation. We decided that it was not good for the API and I had to refactor the models (see #5908) to allow conversations to be created without a message without breaking anything else.\r\n\r\nI also had to [refactor the ConversationsModel](https://github.com/vanilla/vanilla/pull/5932) to fetch members properly.\r\n\r\nLast thing, I decided that `prepareRow()` was a bad name in the other models. I decided to go with `normalizeInput()` and `normalize{NameOfTheRecord}()` which I think is more appropriate. The second one could be named `normalizeRecord`() and both could be added to a base class some day. Open to criticisms on this.","created_at":"2017-09-05T21:55:46Z","updated_at":"2017-09-08T16:11:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d84e439508d9300616dad7f7eb992f561920f0cc","assignee":{"login":"initvector","id":1390241,"avatar_url":"https://avatars0.githubusercontent.com/u/1390241?v=4","gravatar_id":"","url":"https://api.github.com/users/initvector","html_url":"https://github.com/initvector","followers_url":"https://api.github.com/users/initvector/followers","following_url":"https://api.github.com/users/initvector/following{/other_user}","gists_url":"https://api.github.com/users/initvector/gists{/gist_id}","starred_url":"https://api.github.com/users/initvector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/initvector/subscriptions","organizations_url":"https://api.github.com/users/initvector/orgs","repos_url":"https://api.github.com/users/initvector/repos","events_url":"https://api.github.com/users/initvector/events{/privacy}","received_events_url":"https://api.github.com/users/initvector/received_events","type":"User","site_admin":false},"assignees":[{"login":"initvector","id":1390241,"avatar_url":"https://avatars0.githubusercontent.com/u/1390241?v=4","gravatar_id":"","url":"https://api.github.com/users/initvector","html_url":"https://github.com/initvector","followers_url":"https://api.github.com/users/initvector/followers","following_url":"https://api.github.com/users/initvector/following{/other_user}","gists_url":"https://api.github.com/users/initvector/gists{/gist_id}","starred_url":"https://api.github.com/users/initvector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/initvector/subscriptions","organizations_url":"https://api.github.com/users/initvector/orgs","repos_url":"https://api.github.com/users/initvector/repos","events_url":"https://api.github.com/users/initvector/events{/privacy}","received_events_url":"https://api.github.com/users/initvector/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":{"url":"https://api.github.com/repos/vanilla/vanilla/milestones/62","html_url":"https://github.com/vanilla/vanilla/milestone/62","labels_url":"https://api.github.com/repos/vanilla/vanilla/milestones/62/labels","id":2265089,"number":62,"title":"2017-Q3-5","description":"","creator":{"login":"linc","id":117672,"avatar_url":"https://avatars1.githubusercontent.com/u/117672?v=4","gravatar_id":"","url":"https://api.github.com/users/linc","html_url":"https://github.com/linc","followers_url":"https://api.github.com/users/linc/followers","following_url":"https://api.github.com/users/linc/following{/other_user}","gists_url":"https://api.github.com/users/linc/gists{/gist_id}","starred_url":"https://api.github.com/users/linc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linc/subscriptions","organizations_url":"https://api.github.com/users/linc/orgs","repos_url":"https://api.github.com/users/linc/repos","events_url":"https://api.github.com/users/linc/events{/privacy}","received_events_url":"https://api.github.com/users/linc/received_events","type":"User","site_admin":false},"open_issues":26,"closed_issues":28,"state":"open","created_at":"2017-01-19T19:19:16Z","updated_at":"2017-09-07T20:31:32Z","due_on":"2017-09-09T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/vanilla/vanilla/pulls/5929/commits","review_comments_url":"https://api.github.com/repos/vanilla/vanilla/pulls/5929/comments","review_comment_url":"https://api.github.com/repos/vanilla/vanilla/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vanilla/vanilla/issues/5929/comments","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/af02e374368e3a4e592ba972ec5c4e037df053f8","head":{"label":"vanilla:feature/conversations-api-controller","ref":"feature/conversations-api-controller","sha":"af02e374368e3a4e592ba972ec5c4e037df053f8","user":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"repo":{"id":232390,"name":"vanilla","full_name":"vanilla/vanilla","owner":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vanilla/vanilla","description":"Vanilla is a powerfully simple discussion forum you can easily customize to make as unique as your community.","fork":false,"url":"https://api.github.com/repos/vanilla/vanilla","forks_url":"https://api.github.com/repos/vanilla/vanilla/forks","keys_url":"https://api.github.com/repos/vanilla/vanilla/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanilla/vanilla/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanilla/vanilla/teams","hooks_url":"https://api.github.com/repos/vanilla/vanilla/hooks","issue_events_url":"https://api.github.com/repos/vanilla/vanilla/issues/events{/number}","events_url":"https://api.github.com/repos/vanilla/vanilla/events","assignees_url":"https://api.github.com/repos/vanilla/vanilla/assignees{/user}","branches_url":"https://api.github.com/repos/vanilla/vanilla/branches{/branch}","tags_url":"https://api.github.com/repos/vanilla/vanilla/tags","blobs_url":"https://api.github.com/repos/vanilla/vanilla/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanilla/vanilla/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanilla/vanilla/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanilla/vanilla/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/{sha}","languages_url":"https://api.github.com/repos/vanilla/vanilla/languages","stargazers_url":"https://api.github.com/repos/vanilla/vanilla/stargazers","contributors_url":"https://api.github.com/repos/vanilla/vanilla/contributors","subscribers_url":"https://api.github.com/repos/vanilla/vanilla/subscribers","subscription_url":"https://api.github.com/repos/vanilla/vanilla/subscription","commits_url":"https://api.github.com/repos/vanilla/vanilla/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanilla/vanilla/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanilla/vanilla/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanilla/vanilla/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanilla/vanilla/contents/{+path}","compare_url":"https://api.github.com/repos/vanilla/vanilla/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanilla/vanilla/merges","archive_url":"https://api.github.com/repos/vanilla/vanilla/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanilla/vanilla/downloads","issues_url":"https://api.github.com/repos/vanilla/vanilla/issues{/number}","pulls_url":"https://api.github.com/repos/vanilla/vanilla/pulls{/number}","milestones_url":"https://api.github.com/repos/vanilla/vanilla/milestones{/number}","notifications_url":"https://api.github.com/repos/vanilla/vanilla/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanilla/vanilla/labels{/name}","releases_url":"https://api.github.com/repos/vanilla/vanilla/releases{/id}","deployments_url":"https://api.github.com/repos/vanilla/vanilla/deployments","created_at":"2009-06-21T01:41:25Z","updated_at":"2017-09-08T16:04:09Z","pushed_at":"2017-09-07T20:29:02Z","git_url":"git://github.com/vanilla/vanilla.git","ssh_url":"git@github.com:vanilla/vanilla.git","clone_url":"https://github.com/vanilla/vanilla.git","svn_url":"https://github.com/vanilla/vanilla","homepage":"https://open.vanillaforums.com","size":51994,"stargazers_count":1694,"watchers_count":1694,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":617,"mirror_url":null,"open_issues_count":490,"forks":617,"open_issues":490,"watchers":1694,"default_branch":"master"}},"base":{"label":"vanilla:master","ref":"master","sha":"d933a1f0905efcc84685259c9d310755fa700b5f","user":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"repo":{"id":232390,"name":"vanilla","full_name":"vanilla/vanilla","owner":{"login":"vanilla","id":7443552,"avatar_url":"https://avatars1.githubusercontent.com/u/7443552?v=4","gravatar_id":"","url":"https://api.github.com/users/vanilla","html_url":"https://github.com/vanilla","followers_url":"https://api.github.com/users/vanilla/followers","following_url":"https://api.github.com/users/vanilla/following{/other_user}","gists_url":"https://api.github.com/users/vanilla/gists{/gist_id}","starred_url":"https://api.github.com/users/vanilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanilla/subscriptions","organizations_url":"https://api.github.com/users/vanilla/orgs","repos_url":"https://api.github.com/users/vanilla/repos","events_url":"https://api.github.com/users/vanilla/events{/privacy}","received_events_url":"https://api.github.com/users/vanilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vanilla/vanilla","description":"Vanilla is a powerfully simple discussion forum you can easily customize to make as unique as your community.","fork":false,"url":"https://api.github.com/repos/vanilla/vanilla","forks_url":"https://api.github.com/repos/vanilla/vanilla/forks","keys_url":"https://api.github.com/repos/vanilla/vanilla/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vanilla/vanilla/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vanilla/vanilla/teams","hooks_url":"https://api.github.com/repos/vanilla/vanilla/hooks","issue_events_url":"https://api.github.com/repos/vanilla/vanilla/issues/events{/number}","events_url":"https://api.github.com/repos/vanilla/vanilla/events","assignees_url":"https://api.github.com/repos/vanilla/vanilla/assignees{/user}","branches_url":"https://api.github.com/repos/vanilla/vanilla/branches{/branch}","tags_url":"https://api.github.com/repos/vanilla/vanilla/tags","blobs_url":"https://api.github.com/repos/vanilla/vanilla/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vanilla/vanilla/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vanilla/vanilla/git/refs{/sha}","trees_url":"https://api.github.com/repos/vanilla/vanilla/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vanilla/vanilla/statuses/{sha}","languages_url":"https://api.github.com/repos/vanilla/vanilla/languages","stargazers_url":"https://api.github.com/repos/vanilla/vanilla/stargazers","contributors_url":"https://api.github.com/repos/vanilla/vanilla/contributors","subscribers_url":"https://api.github.com/repos/vanilla/vanilla/subscribers","subscription_url":"https://api.github.com/repos/vanilla/vanilla/subscription","commits_url":"https://api.github.com/repos/vanilla/vanilla/commits{/sha}","git_commits_url":"https://api.github.com/repos/vanilla/vanilla/git/commits{/sha}","comments_url":"https://api.github.com/repos/vanilla/vanilla/comments{/number}","issue_comment_url":"https://api.github.com/repos/vanilla/vanilla/issues/comments{/number}","contents_url":"https://api.github.com/repos/vanilla/vanilla/contents/{+path}","compare_url":"https://api.github.com/repos/vanilla/vanilla/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vanilla/vanilla/merges","archive_url":"https://api.github.com/repos/vanilla/vanilla/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vanilla/vanilla/downloads","issues_url":"https://api.github.com/repos/vanilla/vanilla/issues{/number}","pulls_url":"https://api.github.com/repos/vanilla/vanilla/pulls{/number}","milestones_url":"https://api.github.com/repos/vanilla/vanilla/milestones{/number}","notifications_url":"https://api.github.com/repos/vanilla/vanilla/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vanilla/vanilla/labels{/name}","releases_url":"https://api.github.com/repos/vanilla/vanilla/releases{/id}","deployments_url":"https://api.github.com/repos/vanilla/vanilla/deployments","created_at":"2009-06-21T01:41:25Z","updated_at":"2017-09-08T16:04:09Z","pushed_at":"2017-09-07T20:29:02Z","git_url":"git://github.com/vanilla/vanilla.git","ssh_url":"git@github.com:vanilla/vanilla.git","clone_url":"https://github.com/vanilla/vanilla.git","svn_url":"https://github.com/vanilla/vanilla","homepage":"https://open.vanillaforums.com","size":51994,"stargazers_count":1694,"watchers_count":1694,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":617,"mirror_url":null,"open_issues_count":490,"forks":617,"open_issues":490,"watchers":1694,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/5929"},"html":{"href":"https://github.com/vanilla/vanilla/pull/5929"},"issue":{"href":"https://api.github.com/repos/vanilla/vanilla/issues/5929"},"comments":{"href":"https://api.github.com/repos/vanilla/vanilla/issues/5929/comments"},"review_comments":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/5929/comments"},"review_comment":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vanilla/vanilla/pulls/5929/commits"},"statuses":{"href":"https://api.github.com/repos/vanilla/vanilla/statuses/af02e374368e3a4e592ba972ec5c4e037df053f8"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"DaazKu"}}