Page MenuHomePhabricator

D14434.id.diff
No OneTemporary

D14434.id.diff

diff --git a/resources/sql/autopatches/20151107.phame.blog.mailkey.1.sql b/resources/sql/autopatches/20151107.phame.blog.mailkey.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151107.phame.blog.mailkey.1.sql
@@ -0,0 +1,2 @@
+ALTER TABLE {$NAMESPACE}_phame.phame_blog
+ ADD mailKey binary(20) NOT NULL;
diff --git a/resources/sql/autopatches/20151107.phame.blog.mailkey.2.php b/resources/sql/autopatches/20151107.phame.blog.mailkey.2.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20151107.phame.blog.mailkey.2.php
@@ -0,0 +1,18 @@
+<?php
+
+$table = new PhameBlog();
+$conn_w = $table->establishConnection('w');
+$iterator = new LiskMigrationIterator($table);
+foreach ($iterator as $blog) {
+ $id = $blog->getID();
+
+ echo pht('Adding mail key for Blog %d...', $id);
+ echo "\n";
+
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET mailKey = %s WHERE id = %d',
+ $table->getTableName(),
+ Filesystem::readRandomCharacters(20),
+ $id);
+}
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3256,10 +3256,12 @@
'PhameBlogListController' => 'applications/phame/controller/blog/PhameBlogListController.php',
'PhameBlogLiveController' => 'applications/phame/controller/blog/PhameBlogLiveController.php',
'PhameBlogQuery' => 'applications/phame/query/PhameBlogQuery.php',
+ 'PhameBlogReplyHandler' => 'applications/phame/mail/PhameBlogReplyHandler.php',
'PhameBlogSearchEngine' => 'applications/phame/query/PhameBlogSearchEngine.php',
'PhameBlogSite' => 'applications/phame/site/PhameBlogSite.php',
'PhameBlogSkin' => 'applications/phame/skins/PhameBlogSkin.php',
'PhameBlogTransaction' => 'applications/phame/storage/PhameBlogTransaction.php',
+ 'PhameBlogTransactionQuery' => 'applications/phame/query/PhameBlogTransactionQuery.php',
'PhameBlogViewController' => 'applications/phame/controller/blog/PhameBlogViewController.php',
'PhameCelerityResources' => 'applications/phame/celerity/PhameCelerityResources.php',
'PhameConduitAPIMethod' => 'applications/phame/conduit/PhameConduitAPIMethod.php',
@@ -7521,10 +7523,12 @@
'PhameBlogListController' => 'PhameBlogController',
'PhameBlogLiveController' => 'PhameBlogController',
'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhameBlogReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PhameBlogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhameBlogSite' => 'PhameSite',
'PhameBlogSkin' => 'PhabricatorController',
'PhameBlogTransaction' => 'PhabricatorApplicationTransaction',
+ 'PhameBlogTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhameBlogViewController' => 'PhameBlogController',
'PhameCelerityResources' => 'CelerityResources',
'PhameConduitAPIMethod' => 'ConduitAPIMethod',
diff --git a/src/applications/phame/editor/PhameBlogEditor.php b/src/applications/phame/editor/PhameBlogEditor.php
--- a/src/applications/phame/editor/PhameBlogEditor.php
+++ b/src/applications/phame/editor/PhameBlogEditor.php
@@ -162,15 +162,66 @@
protected function shouldSendMail(
PhabricatorLiskDAO $object,
array $xactions) {
- return false;
+ return true;
}
protected function shouldPublishFeedStory(
PhabricatorLiskDAO $object,
array $xactions) {
- return false;
+ return true;
+ }
+
+ protected function getMailTo(PhabricatorLiskDAO $object) {
+ $phids = array();
+ $phids[] = $this->requireActor()->getPHID();
+ $phids[] = $object->getCreatorPHID();
+
+ return $phids;
+ }
+
+ protected function buildMailTemplate(PhabricatorLiskDAO $object) {
+ $phid = $object->getPHID();
+ $name = $object->getName();
+
+ return id(new PhabricatorMetaMTAMail())
+ ->setSubject($name)
+ ->addHeader('Thread-Topic', $phid);
+ }
+
+ protected function buildReplyHandler(PhabricatorLiskDAO $object) {
+ return id(new PhameBlogReplyHandler())
+ ->setMailReceiver($object);
+ }
+
+ protected function buildMailBody(
+ PhabricatorLiskDAO $object,
+ array $xactions) {
+
+ $body = parent::buildMailBody($object, $xactions);
+
+ $body->addLinkSection(
+ pht('BLOG DETAIL'),
+ PhabricatorEnv::getProductionURI($object->getViewURI()));
+
+ return $body;
}
+ public function getMailTagsMap() {
+ return array(
+ PhameBlogTransaction::MAILTAG_DETAILS =>
+ pht("A blog's details change."),
+ PhameBlogTransaction::MAILTAG_SUBSCRIBERS =>
+ pht("A blog's subscribers change."),
+ PhameBlogTransaction::MAILTAG_OTHER =>
+ pht('Other blog activity not listed above occurs.'),
+ );
+ }
+
+ protected function getMailSubjectPrefix() {
+ return '[Phame]';
+ }
+
+
protected function supportsSearch() {
return false;
}
diff --git a/src/applications/phame/mail/PhameBlogReplyHandler.php b/src/applications/phame/mail/PhameBlogReplyHandler.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/mail/PhameBlogReplyHandler.php
@@ -0,0 +1,21 @@
+<?php
+
+final class PhameBlogReplyHandler
+ extends PhabricatorApplicationTransactionReplyHandler {
+
+ public function validateMailReceiver($mail_receiver) {
+ if (!($mail_receiver instanceof PhameBlog)) {
+ throw new Exception(
+ pht('Mail receiver is not a %s.', 'PhameBlog'));
+ }
+ }
+
+ public function getObjectPrefix() {
+ return PhabricatorPhameBlogPHIDType::TYPECONST;
+ }
+
+ protected function shouldCreateCommentFromMailBody() {
+ return false;
+ }
+
+}
diff --git a/src/applications/phame/query/PhameBlogTransactionQuery.php b/src/applications/phame/query/PhameBlogTransactionQuery.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phame/query/PhameBlogTransactionQuery.php
@@ -0,0 +1,10 @@
+<?php
+
+final class PhameBlogTransactionQuery
+ extends PhabricatorApplicationTransactionQuery {
+
+ public function getTemplateApplicationTransaction() {
+ return new PhameBlogTransaction();
+ }
+
+}
diff --git a/src/applications/phame/storage/PhameBlog.php b/src/applications/phame/storage/PhameBlog.php
--- a/src/applications/phame/storage/PhameBlog.php
+++ b/src/applications/phame/storage/PhameBlog.php
@@ -21,6 +21,7 @@
protected $viewPolicy;
protected $editPolicy;
protected $joinPolicy;
+ protected $mailKey;
private static $requestBlog;
@@ -34,6 +35,7 @@
'name' => 'text64',
'description' => 'text',
'domain' => 'text128?',
+ 'mailKey' => 'bytes20',
// T6203/NULLABILITY
// These policies should always be non-null.
@@ -55,6 +57,13 @@
) + parent::getConfiguration();
}
+ public function save() {
+ if (!$this->getMailKey()) {
+ $this->setMailKey(Filesystem::readRandomCharacters(20));
+ }
+ return parent::save();
+ }
+
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPhameBlogPHIDType::TYPECONST);
@@ -214,6 +223,11 @@
return $base;
}
+ public function getViewURI() {
+ $uri = '/phame/blog/view/'.$this->getID().'/';
+ return PhabricatorEnv::getProductionURI($uri);
+ }
+
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
diff --git a/src/applications/phame/storage/PhameBlogTransaction.php b/src/applications/phame/storage/PhameBlogTransaction.php
--- a/src/applications/phame/storage/PhameBlogTransaction.php
+++ b/src/applications/phame/storage/PhameBlogTransaction.php
@@ -8,6 +8,10 @@
const TYPE_DOMAIN = 'phame.blog.domain';
const TYPE_SKIN = 'phame.blog.skin';
+ const MAILTAG_DETAILS = 'phame-blog-details';
+ const MAILTAG_SUBSCRIBERS = 'phame-blog-subscribers';
+ const MAILTAG_OTHER = 'phame-blog-other';
+
public function getApplicationName() {
return 'phame';
}
@@ -44,6 +48,26 @@
return parent::getIcon();
}
+ public function getMailTags() {
+ $tags = parent::getMailTags();
+
+ switch ($this->getTransactionType()) {
+ case PhabricatorTransactions::TYPE_SUBSCRIBERS:
+ $tags[] = self::MAILTAG_SUBSCRIBERS;
+ break;
+ case self::TYPE_NAME:
+ case self::TYPE_DESCRIPTION:
+ case self::TYPE_DOMAIN:
+ case self::TYPE_SKIN:
+ $tags[] = self::MAILTAG_DETAILS;
+ break;
+ default:
+ $tags[] = self::MAILTAG_OTHER;
+ break;
+ }
+ return $tags;
+ }
+
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$object_phid = $this->getObjectPHID();
@@ -53,7 +77,7 @@
$type = $this->getTransactionType();
switch ($type) {
- case self:TYPE_NAME:
+ case self::TYPE_NAME:
if ($old === null) {
return pht(
'%s created this blog.',

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 8:24 PM (1 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6710780
Default Alt Text
D14434.id.diff (8 KB)

Event Timeline