diff --git a/resources/sql/autopatches/20150725.countdown.mailkey.1.sql b/resources/sql/autopatches/20150725.countdown.mailkey.1.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150725.countdown.mailkey.1.sql @@ -0,0 +1,2 @@ +ALTER TABLE {$NAMESPACE}_countdown.countdown + ADD mailKey binary(20) NOT NULL; diff --git a/resources/sql/autopatches/20150725.countdown.mailkey.2.php b/resources/sql/autopatches/20150725.countdown.mailkey.2.php new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150725.countdown.mailkey.2.php @@ -0,0 +1,18 @@ +establishConnection('w'); +$iterator = new LiskMigrationIterator($table); +foreach ($iterator as $countdown) { + $id = $countdown->getID(); + + echo pht('Adding mail key for countdown %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 @@ -1832,6 +1832,7 @@ 'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php', 'PhabricatorCountdownEditor' => 'applications/countdown/editor/PhabricatorCountdownEditor.php', 'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php', + 'PhabricatorCountdownMailReceiver' => 'applications/countdown/mail/PhabricatorCountdownMailReceiver.php', 'PhabricatorCountdownQuery' => 'applications/countdown/query/PhabricatorCountdownQuery.php', 'PhabricatorCountdownRemarkupRule' => 'applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php', 'PhabricatorCountdownReplyHandler' => 'applications/countdown/mail/PhabricatorCountdownReplyHandler.php', @@ -5648,6 +5649,7 @@ 'PhabricatorCountdownEditController' => 'PhabricatorCountdownController', 'PhabricatorCountdownEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorCountdownListController' => 'PhabricatorCountdownController', + 'PhabricatorCountdownMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorCountdownRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PhabricatorCountdownReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', diff --git a/src/applications/countdown/editor/PhabricatorCountdownEditor.php b/src/applications/countdown/editor/PhabricatorCountdownEditor.php --- a/src/applications/countdown/editor/PhabricatorCountdownEditor.php +++ b/src/applications/countdown/editor/PhabricatorCountdownEditor.php @@ -172,6 +172,13 @@ array $xactions) { $body = parent::buildMailBody($object, $xactions); + $description = $object->getDescription(); + + if (strlen($description)) { + $body->addTextSection( + pht('COUNTDOWN DESCRIPTION'), + $object->getDescription()); + } $body->addLinkSection( pht('COUNTDOWN DETAIL'), diff --git a/src/applications/countdown/mail/PhabricatorCountdownMailReceiver.php b/src/applications/countdown/mail/PhabricatorCountdownMailReceiver.php new file mode 100644 --- /dev/null +++ b/src/applications/countdown/mail/PhabricatorCountdownMailReceiver.php @@ -0,0 +1,28 @@ +setViewer($viewer) + ->withIDs(array($id)) + ->executeOne(); + } + + protected function getTransactionReplyHandler() { + return new PhabricatorCountdownReplyHandler(); + } + +} diff --git a/src/applications/countdown/storage/PhabricatorCountdown.php b/src/applications/countdown/storage/PhabricatorCountdown.php --- a/src/applications/countdown/storage/PhabricatorCountdown.php +++ b/src/applications/countdown/storage/PhabricatorCountdown.php @@ -16,7 +16,7 @@ protected $description; protected $viewPolicy; protected $editPolicy; - + protected $mailKey; protected $spacePHID; public static function initializeNewCountdown(PhabricatorUser $actor) { @@ -41,6 +41,7 @@ self::CONFIG_COLUMN_SCHEMA => array( 'title' => 'text255', 'description' => 'text', + 'mailKey' => 'bytes20', ), ) + parent::getConfiguration(); } @@ -54,6 +55,13 @@ return 'C'.$this->getID(); } + public function save() { + if (!$this->getMailKey()) { + $this->setMailKey(Filesystem::readRandomCharacters(20)); + } + return parent::save(); + } + /* -( PhabricatorSubscribableInterface )----------------------------------- */