Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14029278
D14434.id34879.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D14434.id34879.diff
View Options
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
@@ -3255,6 +3255,7 @@
'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',
@@ -7519,6 +7520,7 @@
'PhameBlogListController' => 'PhameBlogController',
'PhameBlogLiveController' => 'PhameBlogController',
'PhameBlogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhameBlogReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
'PhameBlogSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhameBlogSite' => 'PhameSite',
'PhameBlogSkin' => 'PhabricatorController',
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
@@ -158,15 +158,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/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);
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();
File Metadata
Details
Attached
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
6763397
Default Alt Text
D14434.id34879.diff (6 KB)
Attached To
Mode
D14434: Add mail support to PhameBlog
Attached
Detach File
Event Timeline
Log In to Comment