@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add mail keys to Ponder questions

Summary:
We need to go slightly farther to stub reply handler functionality for Ponder in at least some configurations, where we rely on the presence of a unique random key to generate per-object or per-object+user reply addresses.

This should probably be formalized in an interface since it's currently pretty ad-hoc.

Test Plan:
- Made comments in Ponder under a per-user email configuration.
- Ran migration, verified mail keys were generated.
- Ran migration again (with --apply), verified existing questions were skipped.
- Created a new question, verified mail key generation.

Reviewers: pieter

Reviewed By: pieter

CC: aran

Maniphest Tasks: T1873

Differential Revision: https://secure.phabricator.com/D3665

+57 -1
+37
resources/sql/patches/ponder-mailkey-populate.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2012 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + echo "Populating Questions with mail keys...\n"; 20 + foreach (new LiskMigrationIterator(new PonderQuestion()) as $question) { 21 + $id = $question->getID(); 22 + 23 + echo "Question {$id}: "; 24 + if (!$question->getMailKey()) { 25 + queryfx( 26 + $question->establishConnection('w'), 27 + 'UPDATE %T SET mailKey = %s WHERE id = %d', 28 + $question->getTableName(), 29 + Filesystem::readRandomCharacters(20), 30 + $id); 31 + echo "Generated Key\n"; 32 + } else { 33 + echo "-\n"; 34 + } 35 + } 36 + 37 + echo "Done.\n";
+2
resources/sql/patches/ponder-mailkey.sql
··· 1 + ALTER TABLE `{$NAMESPACE}_ponder`.ponder_question 2 + ADD mailKey VARCHAR(20) NOT NULL COLLATE utf8_bin;
+1
src/applications/ponder/mail/PonderMail.php
··· 106 106 ->loadHandles(); 107 107 108 108 $reply_handler = new PonderReplyHandler(); 109 + $reply_handler->setMailReceiver($question); 109 110 110 111 $body = new PhabricatorMetaMTAMailBody(); 111 112 $body->addRawSection($this->renderBody());
+9
src/applications/ponder/storage/PonderQuestion.php
··· 34 34 protected $voteCount; 35 35 protected $answerCount; 36 36 protected $heat; 37 + protected $mailKey; 37 38 38 39 private $answers; 39 40 private $vote; ··· 175 176 public function isAutomaticallySubscribed($phid) { 176 177 return false; 177 178 } 179 + 180 + public function save() { 181 + if (!$this->getMailKey()) { 182 + $this->setMailKey(Filesystem::readRandomCharacters(20)); 183 + } 184 + return parent::save(); 185 + } 186 + 178 187 }
+8 -1
src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
··· 996 996 'type' => 'sql', 997 997 'name' => $this->getPatchPath('phamedomain.sql'), 998 998 ), 999 - 999 + 'ponder-mailkey.sql' => array( 1000 + 'type' => 'sql', 1001 + 'name' => $this->getPatchPath('ponder-mailkey.sql'), 1002 + ), 1003 + 'ponder-mailkey-populate.php' => array( 1004 + 'type' => 'php', 1005 + 'name' => $this->getPatchPath('ponder-mailkey-populate.php'), 1006 + ), 1000 1007 ); 1001 1008 } 1002 1009