mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +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:
parent
82edde8876
commit
a962aeaf85
6 changed files with 66 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_countdown.countdown
|
||||||
|
ADD mailKey binary(20) NOT NULL;
|
18
resources/sql/autopatches/20150725.countdown.mailkey.2.php
Normal file
18
resources/sql/autopatches/20150725.countdown.mailkey.2.php
Normal 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);
|
||||||
|
}
|
|
@ -1832,6 +1832,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php',
|
'PhabricatorCountdownEditController' => 'applications/countdown/controller/PhabricatorCountdownEditController.php',
|
||||||
'PhabricatorCountdownEditor' => 'applications/countdown/editor/PhabricatorCountdownEditor.php',
|
'PhabricatorCountdownEditor' => 'applications/countdown/editor/PhabricatorCountdownEditor.php',
|
||||||
'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php',
|
'PhabricatorCountdownListController' => 'applications/countdown/controller/PhabricatorCountdownListController.php',
|
||||||
|
'PhabricatorCountdownMailReceiver' => 'applications/countdown/mail/PhabricatorCountdownMailReceiver.php',
|
||||||
'PhabricatorCountdownQuery' => 'applications/countdown/query/PhabricatorCountdownQuery.php',
|
'PhabricatorCountdownQuery' => 'applications/countdown/query/PhabricatorCountdownQuery.php',
|
||||||
'PhabricatorCountdownRemarkupRule' => 'applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php',
|
'PhabricatorCountdownRemarkupRule' => 'applications/countdown/remarkup/PhabricatorCountdownRemarkupRule.php',
|
||||||
'PhabricatorCountdownReplyHandler' => 'applications/countdown/mail/PhabricatorCountdownReplyHandler.php',
|
'PhabricatorCountdownReplyHandler' => 'applications/countdown/mail/PhabricatorCountdownReplyHandler.php',
|
||||||
|
@ -5648,6 +5649,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownEditController' => 'PhabricatorCountdownController',
|
||||||
'PhabricatorCountdownEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorCountdownEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
|
'PhabricatorCountdownListController' => 'PhabricatorCountdownController',
|
||||||
|
'PhabricatorCountdownMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||||
'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
'PhabricatorCountdownQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||||
'PhabricatorCountdownRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
'PhabricatorCountdownRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||||
'PhabricatorCountdownReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
'PhabricatorCountdownReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||||
|
|
|
@ -172,6 +172,13 @@ final class PhabricatorCountdownEditor
|
||||||
array $xactions) {
|
array $xactions) {
|
||||||
|
|
||||||
$body = parent::buildMailBody($object, $xactions);
|
$body = parent::buildMailBody($object, $xactions);
|
||||||
|
$description = $object->getDescription();
|
||||||
|
|
||||||
|
if (strlen($description)) {
|
||||||
|
$body->addTextSection(
|
||||||
|
pht('COUNTDOWN DESCRIPTION'),
|
||||||
|
$object->getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
$body->addLinkSection(
|
$body->addLinkSection(
|
||||||
pht('COUNTDOWN DETAIL'),
|
pht('COUNTDOWN DETAIL'),
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
|
||||||
protected $description;
|
protected $description;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
|
protected $mailKey;
|
||||||
protected $spacePHID;
|
protected $spacePHID;
|
||||||
|
|
||||||
public static function initializeNewCountdown(PhabricatorUser $actor) {
|
public static function initializeNewCountdown(PhabricatorUser $actor) {
|
||||||
|
@ -41,6 +41,7 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'title' => 'text255',
|
'title' => 'text255',
|
||||||
'description' => 'text',
|
'description' => 'text',
|
||||||
|
'mailKey' => 'bytes20',
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,13 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
|
||||||
return 'C'.$this->getID();
|
return 'C'.$this->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function save() {
|
||||||
|
if (!$this->getMailKey()) {
|
||||||
|
$this->setMailKey(Filesystem::readRandomCharacters(20));
|
||||||
|
}
|
||||||
|
return parent::save();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
/* -( PhabricatorSubscribableInterface )----------------------------------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue