{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/app/pulls/comments/27841129","id":27841129,"diff_hunk":"@@ -0,0 +1,215 @@\n+<?php\n+\n+namespace Email\\Controller;\n+\n+use Email\\Check;\n+use Email\\EmailController;\n+\n+class WatchedPageController extends EmailController {\n+\n+\tconst AVATAR_SIZE = 50;\n+\n+\t/* @var \\Title */\n+\tprivate $title;\n+\tprivate $summary;\n+\tprivate $currentRevId;\n+\tprivate $previousRevId;\n+\tprivate $replyToAddress;\n+\tprivate $fromAddress;\n+\n+\tpublic function getSubject() {\n+\t\treturn wfMessage( 'emailext-watchedpage-subject',\n+\t\t\t$this->title->getPrefixedText(),\n+\t\t\t$this->getEditorUserName() )->inLanguage( $this->getTargetLang() )->text();\n+\t}\n+\n+\tpublic function initEmail() {\n+\t\t$this->title = \\Title::newFromText( $this->request->getVal( 'title' ) );\n+\t\t$this->summary = $this->request->getVal( 'summary' );\n+\t\t$this->currentRevId = $this->request->getVal( 'currentRevId' );\n+\t\t$this->previousRevId = $this->request->getVal( 'previousRevId' );\n+\t\t$this->replyToAddress = $this->request->getVal( 'replyToAddress' );\n+\t\t$this->fromAddress = new \\MailAddress( $this->request->getVal( 'fromAddress', '' ), $this->getVal( 'fromName', '' ) );\n+\n+\t\t$this->assertValidParams();\n+\t}\n+\n+\t/**\n+\t * Validate the params passed in by the client\n+\t */\n+\tprivate function assertValidParams() {\n+\t\t$this->assertValidTitle();\n+\t\t$this->assertValidRevIds();\n+\t\t$this->assertValiFromAddress();\n+\t}\n+\n+\t/**\n+\t * @throws \\Email\\Check\n+\t */\n+\tprivate function assertValidTitle() {\n+\t\tif ( !$this->title instanceof \\Title ) {\n+\t\t\tthrow new Check( \"Invalid value passed for title\" );\n+\t\t}\n+\n+\t\tif ( !$this->title->exists() ) {\n+\t\t\tthrow new Check( \"Title doesn't exist.\" );\n+\t\t}\n+\t}\n+\n+\tprivate function assertValidRevIds() {\n+\t\tif ( empty( $this->currentRevId ) ) {\n+\t\t\tthrow new Check( \"Empty current Revision Id\" );\n+\t\t}\n+\n+\t\tif ( empty( $this->previousRevId ) ) {\n+\t\t\tthrow new Check( \"Empty previous Revision Id\" );\n+\t\t}\n+\t}\n+\n+\tprivate function assertValiFromAddress() {\n+\t\tif ( $this->fromAddress->toString() == \"\" ) {\n+\t\t\tthrow new Check( \"Empty from address\" );\n+\t\t}\n+\t}\n+\n+\tprotected function getFromAddress() {\n+\t\treturn $this->fromAddress;\n+\t}\n+\n+\tprotected function getReplyToAddress() {\n+\t\treturn $this->replyToAddress;\n+\t}\n+\n+\tprotected function getFooterMessages() {\n+\t\t$footerMessages = [\n+\t\t\twfMessage( 'emailext-watchedpage-unfollow-text',\n+\t\t\t\t$this->title->getCanonicalUrl( 'action=unwatch' ),\n+\t\t\t\t$this->title->getPrefixedText() )->inLanguage( $this->getTargetLang() )->parse()\n+\t\t];\n+\t\treturn array_merge( $footerMessages, parent::getFooterMessages() );\n+\t}\n+\n+\t/**\n+\t * @template avatarLayout\n+\t */\n+\tpublic function body() {\n+\t\t$this->response->setData( [\n+\t\t\t'salutation' => $this->getSalutation(),\n+\t\t\t'articleEditedText' => $this->getArticleEditedText(),\n+\t\t\t'editorProfilePage' => $this->getEditorProfilePage(),\n+\t\t\t'editorUserName' => $this->getEditorUserName(),\n+\t\t\t'editorAvatarURL' => $this->getEditorAvatarUR(),\n+\t\t\t'summary' => $this->getSummary(),\n+\t\t\t'buttonText' => $this->getCompareChangesLabel(),\n+\t\t\t'buttonLink' => $this->getCompareChangesLink(),\n+\t\t\t'contentFooterMessages' => [\n+\t\t\t\t$this->getArticleLinkText(),\n+\t\t\t\t$this->getAllChangesText(),\n+\t\t\t],\n+\t\t] );\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t * Get rendered html for content unique to this email\n+\t * @todo We may want to make this available more generically for other emails to use the avatar layout.\n+\t */\n+\tprotected function getContent() {\n+\t\t$css = file_get_contents( __DIR__ . '/../styles/avatarLayout.css' );\n+\t\t$html = $this->app->renderView(\n+\t\t\tget_class( $this ),\n+\t\t\t'body',\n+\t\t\t$this->request->getParams()\n+\t\t);\n+\n+\t\t$html = $this->inlineStyles( $html, $css );\n+\n+\t\treturn $html;\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getSalutation() {\n+\t\treturn wfMessage( 'emailext-watchedpage-salutation',\n+\t\t\t$this->targetUser->getName() )->inLanguage( $this->getTargetLang() )->text();\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getArticleEditedText() {\n+\t\treturn wfMessage( 'emailext-watchedpage-article-edited',\n+\t\t\t$this->title->getFullURL(),\n+\t\t\t$this->title->getPrefixedText() )->inLanguage( $this->getTargetLang() )->parse();\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getEditorProfilePage() {\n+\t\tif ( $this->currentUser->isLoggedIn() ) {\n+\t\t\treturn $this->currentUser->getUserPage()->getFullURL();\n+\t\t}\n+\t\treturn \"\";\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getEditorUserName() {\n+\t\tif ( $this->currentUser->isLoggedIn() )\t {\n+\t\t\treturn $this->currentUser->getName();\n+\t\t}\n+\t\treturn wfMessage( \"emailext-watchedpage-anonymous-editor\" )->inLanguage( $this->getTargetLang() )->text();\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getEditorAvatarUR() {\n+\t\treturn \\AvatarService::getAvatarUrl( $this->currentUser, self::AVATAR_SIZE );\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getSummary() {\n+\t\tif ( !empty( $this->summary ) ) {\n+\t\t\treturn $this->summary;\n+\t\t}\n+\t\treturn wfMessage( 'enotif_no_summary' )->inLanguage( $this->getTargetLang() )->text();\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getCompareChangesLabel() {\n+\t\treturn wfMessage( 'emailext-watchedpage-diff-button-text' )->inLanguage( $this->getTargetLang() )->text();\n+\t}\n+\n+\t/**\n+\t * @return String\n+\t */\n+\tprivate function getCompareChangesLink() {\n+\t\treturn $this->title->getFullUrl( 'diff=' . $this->currentRevId . '&oldid=' . $this->previousRevId );","path":"extensions/wikia/Email/Controller/WatchedPageController.class.php","position":195,"original_position":195,"commit_id":"7116534d187433d4de416401b8bc58d32ebfd4b4","original_commit_id":"b933f7ba2abe3b59d089017539fcb9193167a8d7","user":{"login":"jsutterfield","id":1657792,"avatar_url":"https://avatars.githubusercontent.com/u/1657792?v=3","gravatar_id":"","url":"https://api.github.com/users/jsutterfield","html_url":"https://github.com/jsutterfield","followers_url":"https://api.github.com/users/jsutterfield/followers","following_url":"https://api.github.com/users/jsutterfield/following{/other_user}","gists_url":"https://api.github.com/users/jsutterfield/gists{/gist_id}","starred_url":"https://api.github.com/users/jsutterfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsutterfield/subscriptions","organizations_url":"https://api.github.com/users/jsutterfield/orgs","repos_url":"https://api.github.com/users/jsutterfield/repos","events_url":"https://api.github.com/users/jsutterfield/events{/privacy}","received_events_url":"https://api.github.com/users/jsutterfield/received_events","type":"User","site_admin":false},"body":"I think this second way reads better. I'll update.","created_at":"2015-04-06T23:42:57Z","updated_at":"2015-04-06T23:42:57Z","html_url":"https://github.com/Wikia/app/pull/6862#discussion_r27841129","pull_request_url":"https://api.github.com/repos/Wikia/app/pulls/6862","_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments/27841129"},"html":{"href":"https://github.com/Wikia/app/pull/6862#discussion_r27841129"},"pull_request":{"href":"https://api.github.com/repos/Wikia/app/pulls/6862"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/app/pulls/6862","id":32474609,"html_url":"https://github.com/Wikia/app/pull/6862","diff_url":"https://github.com/Wikia/app/pull/6862.diff","patch_url":"https://github.com/Wikia/app/pull/6862.patch","issue_url":"https://api.github.com/repos/Wikia/app/issues/6862","number":6862,"state":"open","locked":false,"title":"SOC-558 Update Watched Page edit emails to use new extension and templates","user":{"login":"jsutterfield","id":1657792,"avatar_url":"https://avatars.githubusercontent.com/u/1657792?v=3","gravatar_id":"","url":"https://api.github.com/users/jsutterfield","html_url":"https://github.com/jsutterfield","followers_url":"https://api.github.com/users/jsutterfield/followers","following_url":"https://api.github.com/users/jsutterfield/following{/other_user}","gists_url":"https://api.github.com/users/jsutterfield/gists{/gist_id}","starred_url":"https://api.github.com/users/jsutterfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsutterfield/subscriptions","organizations_url":"https://api.github.com/users/jsutterfield/orgs","repos_url":"https://api.github.com/users/jsutterfield/repos","events_url":"https://api.github.com/users/jsutterfield/events{/privacy}","received_events_url":"https://api.github.com/users/jsutterfield/received_events","type":"User","site_admin":false},"body":"This is the first email which we're porting over to use the new Email extension and new email templates. It combines both the backend work of SOC-588 and front-end work of SOC-498.\r\n\r\nIncluded in these tickets are creating a foundational email template (main.mustache and avatarLayour.mustache), including the \"CssToInlineStyles\" PHP library to inline css for the emails, and adjusting the backend logic so that watched page edits are handled by the new email extension.\r\n\r\nTicket: https://wikia-inc.atlassian.net/browse/SOC-558","created_at":"2015-04-02T00:45:31Z","updated_at":"2015-04-06T23:42:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c32afcfb24e1f8a08540bf92112910b77c54ba9","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/app/pulls/6862/commits","review_comments_url":"https://api.github.com/repos/Wikia/app/pulls/6862/comments","review_comment_url":"https://api.github.com/repos/Wikia/app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/app/issues/6862/comments","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/7116534d187433d4de416401b8bc58d32ebfd4b4","head":{"label":"Wikia:SOC-558","ref":"SOC-558","sha":"7116534d187433d4de416401b8bc58d32ebfd4b4","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","created_at":"2012-08-23T20:55:58Z","updated_at":"2015-04-06T18:03:24Z","pushed_at":"2015-04-06T23:14:13Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":1387210,"stargazers_count":76,"watchers_count":76,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":64,"forks":56,"open_issues":64,"watchers":76,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"0f8ad4a2c7918ff7284e646a829f9ad3d36fcf6b","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","created_at":"2012-08-23T20:55:58Z","updated_at":"2015-04-06T18:03:24Z","pushed_at":"2015-04-06T23:14:13Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":1387210,"stargazers_count":76,"watchers_count":76,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":56,"mirror_url":null,"open_issues_count":64,"forks":56,"open_issues":64,"watchers":76,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/6862"},"html":{"href":"https://github.com/Wikia/app/pull/6862"},"issue":{"href":"https://api.github.com/repos/Wikia/app/issues/6862"},"comments":{"href":"https://api.github.com/repos/Wikia/app/issues/6862/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/app/pulls/6862/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/app/pulls/6862/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/app/statuses/7116534d187433d4de416401b8bc58d32ebfd4b4"}}}}