diff --git a/resources/sql/patches/ponder-mailkey-populate.php b/resources/sql/patches/ponder-mailkey-populate.php new file mode 100644 index 0000000000..549ae093ae --- /dev/null +++ b/resources/sql/patches/ponder-mailkey-populate.php @@ -0,0 +1,37 @@ +getID(); + + echo "Question {$id}: "; + if (!$question->getMailKey()) { + queryfx( + $question->establishConnection('w'), + 'UPDATE %T SET mailKey = %s WHERE id = %d', + $question->getTableName(), + Filesystem::readRandomCharacters(20), + $id); + echo "Generated Key\n"; + } else { + echo "-\n"; + } +} + +echo "Done.\n"; diff --git a/resources/sql/patches/ponder-mailkey.sql b/resources/sql/patches/ponder-mailkey.sql new file mode 100644 index 0000000000..611647d119 --- /dev/null +++ b/resources/sql/patches/ponder-mailkey.sql @@ -0,0 +1,2 @@ +ALTER TABLE `{$NAMESPACE}_ponder`.ponder_question + ADD mailKey VARCHAR(20) NOT NULL COLLATE utf8_bin; diff --git a/src/applications/ponder/mail/PonderMail.php b/src/applications/ponder/mail/PonderMail.php index 38348ddc8d..d9f10d2333 100644 --- a/src/applications/ponder/mail/PonderMail.php +++ b/src/applications/ponder/mail/PonderMail.php @@ -106,6 +106,7 @@ abstract class PonderMail { ->loadHandles(); $reply_handler = new PonderReplyHandler(); + $reply_handler->setMailReceiver($question); $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($this->renderBody()); diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index d82132b4ea..3e5878e9a3 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -34,6 +34,7 @@ final class PonderQuestion extends PonderDAO protected $voteCount; protected $answerCount; protected $heat; + protected $mailKey; private $answers; private $vote; @@ -175,4 +176,12 @@ final class PonderQuestion extends PonderDAO public function isAutomaticallySubscribed($phid) { return false; } + + public function save() { + if (!$this->getMailKey()) { + $this->setMailKey(Filesystem::readRandomCharacters(20)); + } + return parent::save(); + } + } diff --git a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php index 561023fbb1..b7406f2b11 100644 --- a/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php +++ b/src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php @@ -996,7 +996,14 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList { 'type' => 'sql', 'name' => $this->getPatchPath('phamedomain.sql'), ), - + 'ponder-mailkey.sql' => array( + 'type' => 'sql', + 'name' => $this->getPatchPath('ponder-mailkey.sql'), + ), + 'ponder-mailkey-populate.php' => array( + 'type' => 'php', + 'name' => $this->getPatchPath('ponder-mailkey-populate.php'), + ), ); }