mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-13 02:12:41 +01:00
Link to attached objects in email when a Maniphest task has stuff attached
Summary: When files or revisions are attached to a Maniphest task, link to the new stuff in the email. See T116. Test Plan: Attached files and revisions to a task, got sensible-looking emails about it. Reviewed By: tomo Reviewers: tomo, jungejason, tuomaspelkonen, aran CC: aran, tomo Differential Revision: 286
This commit is contained in:
parent
01bb30f905
commit
20892b0bc2
2 changed files with 62 additions and 0 deletions
|
@ -70,10 +70,18 @@ class ManiphestTransactionDetailView extends AphrontView {
|
||||||
}
|
}
|
||||||
|
|
||||||
$descs = implode("\n", $descs);
|
$descs = implode("\n", $descs);
|
||||||
|
|
||||||
if ($comments) {
|
if ($comments) {
|
||||||
$descs .= "\n".$comments;
|
$descs .= "\n".$comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->transactions as $transaction) {
|
||||||
|
$supplemental = $this->renderSupplementalLinksForEmail($transaction);
|
||||||
|
if ($supplemental) {
|
||||||
|
$descs .= "\n\n".$supplemental;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->forEmail = false;
|
$this->forEmail = false;
|
||||||
return array($action, $descs);
|
return array($action, $descs);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +157,59 @@ class ManiphestTransactionDetailView extends AphrontView {
|
||||||
'</div>');
|
'</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function renderSupplementalLinksForEmail($transaction) {
|
||||||
|
$handles = $this->handles;
|
||||||
|
|
||||||
|
$type = $transaction->getTransactionType();
|
||||||
|
$new = $transaction->getNewValue();
|
||||||
|
$old = $transaction->getOldValue();
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case ManiphestTransactionType::TYPE_ATTACH:
|
||||||
|
$old_raw = nonempty($old, array());
|
||||||
|
$new_raw = nonempty($new, array());
|
||||||
|
|
||||||
|
$attach_types = array(
|
||||||
|
PhabricatorPHIDConstants::PHID_TYPE_DREV,
|
||||||
|
PhabricatorPHIDConstants::PHID_TYPE_FILE,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($attach_types as $type) {
|
||||||
|
$old = array_keys(idx($old_raw, $type, array()));
|
||||||
|
$new = array_keys(idx($new_raw, $type, array()));
|
||||||
|
if ($old != $new) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$added = array_diff($new, $old);
|
||||||
|
if (!$added) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$links = array();
|
||||||
|
foreach (array_select_keys($handles, $added) as $handle) {
|
||||||
|
$links[] = ' '.PhabricatorEnv::getProductionURI($handle->getURI());
|
||||||
|
}
|
||||||
|
$links = implode("\n", $links);
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case PhabricatorPHIDConstants::PHID_TYPE_DREV:
|
||||||
|
$title = 'ATTACHED REVISIONS';
|
||||||
|
break;
|
||||||
|
case PhabricatorPHIDConstants::PHID_TYPE_FILE:
|
||||||
|
$title = 'ATTACHED FILES';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $title."\n".$links;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private function describeAction($transaction) {
|
private function describeAction($transaction) {
|
||||||
$verb = null;
|
$verb = null;
|
||||||
$desc = null;
|
$desc = null;
|
||||||
|
|
|
@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/maniphest/constants/status');
|
||||||
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
phutil_require_module('phabricator', 'applications/maniphest/constants/transactiontype');
|
||||||
phutil_require_module('phabricator', 'applications/phid/constants');
|
phutil_require_module('phabricator', 'applications/phid/constants');
|
||||||
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
phutil_require_module('phabricator', 'infrastructure/celerity/api');
|
||||||
|
phutil_require_module('phabricator', 'infrastructure/env');
|
||||||
phutil_require_module('phabricator', 'view/base');
|
phutil_require_module('phabricator', 'view/base');
|
||||||
phutil_require_module('phabricator', 'view/utils');
|
phutil_require_module('phabricator', 'view/utils');
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue