1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Make Thread-Topic human readable

Summary:
Some e-mail clients display this header and it needs to be constant.

This is somehow involved but I doubt that there is a simpler solution.

Test Plan:
Applied SQL patch.
Commented on revision, commented on commit, changed package.
Verified that the `Thread-Topic` has constant and human readable value.

Reviewers: epriestley

Reviewed By: epriestley

CC: ola, aran, Korvin

Differential Revision: https://secure.phabricator.com/D2745
This commit is contained in:
vrana 2012-06-13 20:52:10 -07:00
parent 7463f9b3a9
commit 892a2d1b61
10 changed files with 62 additions and 10 deletions

View file

@ -0,0 +1,14 @@
ALTER TABLE {$NAMESPACE}_differential.differential_revision
ADD originalTitle varchar(255) NOT NULL AFTER title;
UPDATE {$NAMESPACE}_differential.differential_revision SET
originalTitle = title;
ALTER TABLE {$NAMESPACE}_owners.owners_package
ADD originalName varchar(255) NOT NULL AFTER name;
UPDATE {$NAMESPACE}_owners.owners_package SET
originalName = name;
ALTER TABLE {$NAMESPACE}_maniphest.maniphest_task
ADD originalTitle text NOT NULL AFTER title;
UPDATE {$NAMESPACE}_maniphest.maniphest_task SET
originalTitle = title;

View file

@ -395,7 +395,9 @@ final class PhabricatorAuditCommentEditor {
$prefix = PhabricatorEnv::getEnvConfig('metamta.diffusion.subject-prefix');
$threading = self::getMailThreading($commit->getPHID());
$repository = id(new PhabricatorRepository())
->load($commit->getRepositoryID());
$threading = self::getMailThreading($repository, $commit);
list($thread_id, $thread_topic) = $threading;
$body = $this->renderMailBody(
@ -452,10 +454,13 @@ final class PhabricatorAuditCommentEditor {
}
}
public static function getMailThreading($phid) {
public static function getMailThreading(
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
return array(
'diffusion-audit-'.$phid,
'Diffusion Audit '.$phid,
'diffusion-audit-'.$commit->getPHID(),
'Commit r'.$repository->getCallsign().$commit->getCommitIdentifier(),
);
}

View file

@ -328,8 +328,9 @@ EOTEXT;
}
protected function getThreadTopic() {
$phid = $this->getRevision()->getPHID();
return "Differential Revision {$phid}";
$id = $this->getRevision()->getID();
$title = $this->getRevision()->getOriginalTitle();
return "D{$id}: {$title}";
}
public function setComment($comment) {

View file

@ -19,6 +19,7 @@
final class DifferentialRevision extends DifferentialDAO {
protected $title;
protected $originalTitle;
protected $status;
protected $summary;
@ -60,6 +61,14 @@ final class DifferentialRevision extends DifferentialDAO {
) + parent::getConfiguration();
}
public function setTitle($title) {
$this->title = $title;
if (!$this->getID()) {
$this->originalTitle = $title;
}
return $this;
}
public function loadCommitPHIDs() {
if (!$this->getID()) {
return ($this->commits = array());

View file

@ -278,7 +278,7 @@ final class ManiphestTransactionEditor {
->setVarySubjectPrefix("[{$action}]")
->setFrom($transaction->getAuthorPHID())
->setParentMessageID($this->parentMessageID)
->addHeader('Thread-Topic', 'Maniphest Task '.$task->getPHID())
->addHeader('Thread-Topic', "T{$task_id}: ".$task->getOriginalTitle())
->setThreadID($thread_id, $is_create)
->setRelatedPHID($task->getPHID())
->setIsBulk(true)

View file

@ -31,6 +31,7 @@ final class ManiphestTask extends ManiphestDAO {
protected $subpriority;
protected $title;
protected $originalTitle;
protected $description;
protected $originalEmailSource;
protected $mailKey;
@ -107,6 +108,14 @@ final class ManiphestTask extends ManiphestDAO {
return $this;
}
public function setTitle($title) {
$this->title = $title;
if (!$this->getID()) {
$this->originalTitle = $title;
}
return $this;
}
public function attachAuxiliaryAttributes(array $attrs) {
if ($this->auxiliaryDirty) {
throw new Exception(

View file

@ -24,7 +24,7 @@ abstract class PackageMail {
protected $paths;
protected $mailTo;
public function __construct($package) {
public function __construct(PhabricatorOwnersPackage $package) {
$this->package = $package;
}
@ -206,7 +206,7 @@ abstract class PackageMail {
private function getMailThreading() {
return array(
'package-'.$this->getPackage()->getPHID(),
'package '.$this->getPackage()->getPHID(),
'Package '.$this->getPackage()->getOriginalName(),
);
}

View file

@ -20,6 +20,7 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
protected $phid;
protected $name;
protected $originalName;
protected $auditingEnabled;
protected $description;
protected $primaryOwnerPHID;
@ -79,6 +80,14 @@ final class PhabricatorOwnersPackage extends PhabricatorOwnersDAO {
return $this->oldAuditingEnabled;
}
public function setName($name) {
$this->name = $name;
if (!$this->getID()) {
$this->originalName = $name;
}
return $this;
}
public function loadOwners() {
if (!$this->getID()) {
return array();

View file

@ -153,7 +153,8 @@ EOBODY;
$prefix = PhabricatorEnv::getEnvConfig('metamta.diffusion.subject-prefix');
$threading = PhabricatorAuditCommentEditor::getMailThreading(
$commit->getPHID());
$repository,
$commit);
list($thread_id, $thread_topic) = $threading;
$template = new PhabricatorMetaMTAMail();

View file

@ -887,6 +887,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql',
'name' => $this->getPatchPath('ldapinfo.sql'),
),
'threadtopic.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('threadtopic.sql'),
),
);
}