From e3a91902b79e452901b36ae1340e82c7ffe1ce64 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 9 Feb 2011 09:58:48 -0800 Subject: [PATCH] This might make emails work better. Summary: Test Plan: Reviewers: CC: --- .../comment/DifferentialCommentEditor.php | 7 +++- .../revision/DifferentialRevisionEditor.php | 10 ++++- .../differential/editor/revision/__init__.php | 1 + .../mail/base/DifferentialMail.php | 39 +++++++++---------- .../mail/comment/DifferentialCommentMail.php | 4 +- .../DifferentialReviewRequestMail.php | 4 +- 6 files changed, 38 insertions(+), 27 deletions(-) diff --git a/src/applications/differential/editor/comment/DifferentialCommentEditor.php b/src/applications/differential/editor/comment/DifferentialCommentEditor.php index fd2f42eb04..38826563f3 100755 --- a/src/applications/differential/editor/comment/DifferentialCommentEditor.php +++ b/src/applications/differential/editor/comment/DifferentialCommentEditor.php @@ -280,9 +280,14 @@ class DifferentialCommentEditor { } } + $phids = array($this->actorPHID); + $handles = id(new PhabricatorObjectHandleData($phids)) + ->loadHandles(); + $actor_handle = $handles[$this->actorPHID]; + id(new DifferentialCommentMail( $revision, - $this->actorPHID, + $actor_handle, $comment, /* $changesets TODO */ array(), /* $inline_comments TODO */ array())) diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index 1c00cef228..5dff5ccade 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -418,10 +418,16 @@ class DifferentialRevisionEditor { $revision->loadRelationships(); + $phids = array($this->getActorPHID()); + + $handles = id(new PhabricatorObjectHandleData($phids)) + ->loadHandles(); + $actor_handle = $handles[$this->getActorPHID()]; + if ($add['rev']) { $message = id(new DifferentialNewDiffMail( $revision, - $this->getActorPHID(), + $actor_handle, $changesets)) ->setIsFirstMailAboutRevision($is_new) ->setIsFirstMailToRecipients(true) @@ -449,7 +455,7 @@ class DifferentialRevisionEditor { if (!$is_new && $add['ccs']) { $mail[] = id(new DifferentialCCWelcomeMail( $revision, - $this->getActorPHID(), + $actor_handle, $changesets)) ->setIsFirstMailToRecipients(true) ->setToPHIDs(array_keys($add['ccs'])); diff --git a/src/applications/differential/editor/revision/__init__.php b/src/applications/differential/editor/revision/__init__.php index 0961c81a68..bc0bf4fae8 100644 --- a/src/applications/differential/editor/revision/__init__.php +++ b/src/applications/differential/editor/revision/__init__.php @@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/differential/mail/ccwelcome') phutil_require_module('phabricator', 'applications/differential/mail/newdiff'); phutil_require_module('phabricator', 'applications/differential/storage/comment'); phutil_require_module('phabricator', 'applications/differential/storage/revision'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'storage/qsprintf'); phutil_require_module('phabricator', 'storage/queryfx'); diff --git a/src/applications/differential/mail/base/DifferentialMail.php b/src/applications/differential/mail/base/DifferentialMail.php index e80ae7aebe..e05a492d14 100755 --- a/src/applications/differential/mail/base/DifferentialMail.php +++ b/src/applications/differential/mail/base/DifferentialMail.php @@ -23,8 +23,7 @@ abstract class DifferentialMail { protected $to = array(); protected $cc = array(); - protected $actorName; - protected $actorID; + protected $actorHandle; protected $revision; protected $comment; @@ -35,17 +34,25 @@ abstract class DifferentialMail { protected $heraldTranscriptURI; protected $heraldRulesHeader; - public function getActorName() { - return $this->actorName; - } + abstract protected function renderSubject(); + abstract protected function renderBody(); - public function setActorName($actor_name) { - $this->actorName = $actor_name; + public function setActorHandle($actor_handle) { + $this->actorHandle = $actor_handle; return $this; } - abstract protected function renderSubject(); - abstract protected function renderBody(); + public function getActorHandle() { + return $this->actorHandle; + } + + protected function getActorName() { + $handle = $this->getActorHandle(); + if ($handle) { + return $handle->getName(); + } + return '???'; + } public function setXHeraldRulesHeader($header) { $this->heraldRulesHeader = $header; @@ -65,8 +72,9 @@ abstract class DifferentialMail { $body = $this->buildBody(); $mail = new PhabricatorMetaMTAMail(); - if ($this->getActorID()) { - $mail->setFrom($this->getActorID()); + $handle = $this->getActorHandle(); + if ($handle) { + $mail->setFrom($handle->getPHID()); $mail->setReplyTo($this->getReplyHandlerEmailAddress()); } else { $mail->setFrom($this->getReplyHandlerEmailAddress()); @@ -190,15 +198,6 @@ EOTEXT; return $this->cc; } - public function setActorID($actor_id) { - $this->actorID = $actor_id; - return $this; - } - - public function getActorID() { - return $this->actorID; - } - public function setRevision($revision) { $this->revision = $revision; return $this; diff --git a/src/applications/differential/mail/comment/DifferentialCommentMail.php b/src/applications/differential/mail/comment/DifferentialCommentMail.php index 11ae980ab2..3973cc5119 100755 --- a/src/applications/differential/mail/comment/DifferentialCommentMail.php +++ b/src/applications/differential/mail/comment/DifferentialCommentMail.php @@ -31,13 +31,13 @@ class DifferentialCommentMail extends DifferentialMail { public function __construct( DifferentialRevision $revision, - $actor_id, + PhabricatorObjectHandle $actor, DifferentialComment $comment, array $changesets, array $inline_comments) { $this->setRevision($revision); - $this->setActorID($actor_id); + $this->setActorHandle($actor); $this->setComment($comment); $this->setChangesets($changesets); $this->setInlineComments($inline_comments); diff --git a/src/applications/differential/mail/reviewrequest/DifferentialReviewRequestMail.php b/src/applications/differential/mail/reviewrequest/DifferentialReviewRequestMail.php index 5589a9b4a9..0fc013363c 100755 --- a/src/applications/differential/mail/reviewrequest/DifferentialReviewRequestMail.php +++ b/src/applications/differential/mail/reviewrequest/DifferentialReviewRequestMail.php @@ -31,11 +31,11 @@ abstract class DifferentialReviewRequestMail extends DifferentialMail { public function __construct( DifferentialRevision $revision, - $actor_id, + PhabricatorObjectHandle $actor, array $changesets) { $this->setRevision($revision); - $this->setActorID($actor_id); + $this->setActorHandle($actor); $this->setChangesets($changesets); }