1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 11:30:55 +01:00

Add mailKeys to Countdown

Summary: Adds mailkeys and reply handler support

Test Plan: Edit Countdown, New Countdown, no errors.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D13713
This commit is contained in:
Chad Little 2015-07-25 15:47:07 -07:00
parent 82edde8876
commit a962aeaf85
6 changed files with 66 additions and 1 deletions

View file

@ -0,0 +1,2 @@
ALTER TABLE {$NAMESPACE}_countdown.countdown
ADD mailKey binary(20) NOT NULL;

View file

@ -0,0 +1,18 @@
<?php
$table = new PhabricatorCountdown();
$conn_w = $table->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);
}

View file

@ -1832,6 +1832,7 @@ phutil_register_library_map(array(
'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 @@ phutil_register_library_map(array(
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
'PhabricatorCountdownEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
'PhabricatorCountdownMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorCountdownRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PhabricatorCountdownReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',

View file

@ -172,6 +172,13 @@ final class PhabricatorCountdownEditor
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'),

View file

@ -0,0 +1,28 @@
<?php
final class PhabricatorCountdownMailReceiver
extends PhabricatorObjectMailReceiver {
public function isEnabled() {
return PhabricatorApplication::isClassInstalled(
'PhabricatorCountdownApplication');
}
protected function getObjectPattern() {
return 'C[1-9]\d*';
}
protected function loadObject($pattern, PhabricatorUser $viewer) {
$id = (int)substr($pattern, 4);
return id(new PhabricatorCountdownQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
}
protected function getTransactionReplyHandler() {
return new PhabricatorCountdownReplyHandler();
}
}

View file

@ -16,7 +16,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
protected $description;
protected $viewPolicy;
protected $editPolicy;
protected $mailKey;
protected $spacePHID;
public static function initializeNewCountdown(PhabricatorUser $actor) {
@ -41,6 +41,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
self::CONFIG_COLUMN_SCHEMA => array(
'title' => 'text255',
'description' => 'text',
'mailKey' => 'bytes20',
),
) + parent::getConfiguration();
}
@ -54,6 +55,13 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
return 'C'.$this->getID();
}
public function save() {
if (!$this->getMailKey()) {
$this->setMailKey(Filesystem::readRandomCharacters(20));
}
return parent::save();
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */