mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-27 07:50:57 +01:00
Allow noncritical blocks in email bodies to be disabled via config
Summary: See T931. LLVM users would also prefer simpler mail, and have similarly harsh opinions about the current state of affairs. Allow installs to disable the hint blocks if they don't want them. Test Plan: Sent myself mail with these settings on/off, got mail with/without the blocks. Reviewers: btrahan, vrana Reviewed By: vrana CC: aran Maniphest Tasks: T931 Differential Revision: https://secure.phabricator.com/D2968
This commit is contained in:
parent
378feb3ffb
commit
02f40fd7ef
5 changed files with 99 additions and 32 deletions
|
@ -466,6 +466,20 @@ return array(
|
||||||
// address will be stored in an 'From Email' field on the task.
|
// address will be stored in an 'From Email' field on the task.
|
||||||
'metamta.maniphest.default-public-author' => null,
|
'metamta.maniphest.default-public-author' => null,
|
||||||
|
|
||||||
|
// You can disable the Herald hints in email if users prefer smaller messages.
|
||||||
|
// These are the links under the headers "MANAGE HERALD RULES" and
|
||||||
|
// "WHY DID I GET THIS EMAIL?". If you set this to true, they will not appear
|
||||||
|
// in any mail. Users can still navigate to the links via the web interface.
|
||||||
|
'metamta.herald.show-hints' => true,
|
||||||
|
|
||||||
|
// You can disable the hints under "REPLY HANDLER ACTIONS" if users prefer
|
||||||
|
// smaller messages. The actions themselves will still work properly.
|
||||||
|
'metamta.reply.show-hints' => true,
|
||||||
|
|
||||||
|
// You can disable the "To:" and "Cc:" footers in mail if users prefer
|
||||||
|
// smaller messages.
|
||||||
|
'metamta.recipients.show-hints' => true,
|
||||||
|
|
||||||
// If this option is enabled, Phabricator will add a "Precedence: bulk"
|
// If this option is enabled, Phabricator will add a "Precedence: bulk"
|
||||||
// header to transactional mail (e.g., Differential, Maniphest and Herald
|
// header to transactional mail (e.g., Differential, Maniphest and Herald
|
||||||
// notifications). This may improve the behavior of some auto-responder
|
// notifications). This may improve the behavior of some auto-responder
|
||||||
|
|
|
@ -486,12 +486,9 @@ final class PhabricatorAuditCommentEditor {
|
||||||
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb(
|
$verb = PhabricatorAuditActionConstants::getActionPastTenseVerb(
|
||||||
$comment->getAction());
|
$comment->getAction());
|
||||||
|
|
||||||
$body = array();
|
$body = new PhabricatorMetaMTAMailBody();
|
||||||
$body[] = "{$name} {$verb} commit {$cname}.";
|
$body->addRawSection("{$name} {$verb} commit {$cname}.");
|
||||||
|
$body->addRawSection($comment->getContent());
|
||||||
if ($comment->getContent()) {
|
|
||||||
$body[] = $comment->getContent();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($inline_comments) {
|
if ($inline_comments) {
|
||||||
$block = array();
|
$block = array();
|
||||||
|
@ -518,18 +515,16 @@ final class PhabricatorAuditCommentEditor {
|
||||||
$content = $inline->getContent();
|
$content = $inline->getContent();
|
||||||
$block[] = "{$path}:{$range} {$content}";
|
$block[] = "{$path}:{$range} {$content}";
|
||||||
}
|
}
|
||||||
$body[] = "INLINE COMMENTS\n ".implode("\n ", $block);
|
|
||||||
|
$body->addTextSection(pht('INLINE COMMENTS'), implode("\n", $block));
|
||||||
}
|
}
|
||||||
|
|
||||||
$body[] = "COMMIT\n ".PhabricatorEnv::getProductionURI($handle->getURI());
|
$body->addTextSection(
|
||||||
|
pht('COMMIT'),
|
||||||
|
PhabricatorEnv::getProductionURI($handle->getURI()));
|
||||||
|
$body->addReplySection($reply_handler->getReplyHandlerInstructions());
|
||||||
|
|
||||||
|
return $body->render();
|
||||||
$reply_instructions = $reply_handler->getReplyHandlerInstructions();
|
|
||||||
if ($reply_instructions) {
|
|
||||||
$body[] = "REPLY HANDLER ACTIONS\n ".$reply_instructions;
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode("\n\n", $body)."\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,16 @@ abstract class PhabricatorMailReplyHandler {
|
||||||
assert_instances_of($cc_handles, 'PhabricatorObjectHandle');
|
assert_instances_of($cc_handles, 'PhabricatorObjectHandle');
|
||||||
|
|
||||||
$body = '';
|
$body = '';
|
||||||
if ($to_handles) {
|
|
||||||
$body .= "To: ".implode(', ', mpull($to_handles, 'getName'))."\n";
|
if (PhabricatorEnv::getEnvConfig('metamta.recipients.show-hints')) {
|
||||||
}
|
if ($to_handles) {
|
||||||
if ($cc_handles) {
|
$body .= "To: ".implode(', ', mpull($to_handles, 'getName'))."\n";
|
||||||
$body .= "Cc: ".implode(', ', mpull($cc_handles, 'getName'))."\n";
|
}
|
||||||
|
if ($cc_handles) {
|
||||||
|
$body .= "Cc: ".implode(', ', mpull($cc_handles, 'getName'))."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $body;
|
return $body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,12 +72,17 @@ final class PhabricatorMetaMTAMailBody {
|
||||||
* @task compose
|
* @task compose
|
||||||
*/
|
*/
|
||||||
public function addHeraldSection($rules_uri, $xscript_uri) {
|
public function addHeraldSection($rules_uri, $xscript_uri) {
|
||||||
|
if (!PhabricatorEnv::getEnvConfig('metamta.herald.show-hints')) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
$this->addTextSection(
|
$this->addTextSection(
|
||||||
pht('MANAGE HERALD RULES'),
|
pht('MANAGE HERALD RULES'),
|
||||||
PhabricatorEnv::getProductionURI($rules_uri));
|
PhabricatorEnv::getProductionURI($rules_uri));
|
||||||
$this->addTextSection(
|
$this->addTextSection(
|
||||||
pht('WHY DID I GET THIS EMAIL?'),
|
pht('WHY DID I GET THIS EMAIL?'),
|
||||||
PhabricatorEnv::getProductionURI($xscript_uri));
|
PhabricatorEnv::getProductionURI($xscript_uri));
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +95,15 @@ final class PhabricatorMetaMTAMailBody {
|
||||||
* @task compose
|
* @task compose
|
||||||
*/
|
*/
|
||||||
public function addReplySection($instructions) {
|
public function addReplySection($instructions) {
|
||||||
if (strlen($instructions)) {
|
if (!PhabricatorEnv::getEnvConfig('metamta.reply.show-hints')) {
|
||||||
$this->addTextSection(pht('REPLY HANDLER ACTIONS'), $instructions);
|
return $this;
|
||||||
}
|
}
|
||||||
|
if (!strlen($instructions)) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addTextSection(pht('REPLY HANDLER ACTIONS'), $instructions);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,17 +21,8 @@
|
||||||
*/
|
*/
|
||||||
final class PhabricatorMetaMTAMailBodyTestCase extends PhabricatorTestCase {
|
final class PhabricatorMetaMTAMailBodyTestCase extends PhabricatorTestCase {
|
||||||
|
|
||||||
|
|
||||||
public function testBodyRender() {
|
public function testBodyRender() {
|
||||||
|
|
||||||
$env = PhabricatorEnv::beginScopedEnv();
|
|
||||||
$env->overrideEnvConfig('phabricator.base-uri', 'http://test.com/');
|
|
||||||
|
|
||||||
$body = new PhabricatorMetaMTAMailBody();
|
|
||||||
$body->addRawSection("salmon");
|
|
||||||
$body->addTextSection("HEADER", "bass\ntrout\n");
|
|
||||||
$body->addHeraldSection("/rules/", "/xscript/");
|
|
||||||
$body->addReplySection("pike");
|
|
||||||
|
|
||||||
$expect = <<<EOTEXT
|
$expect = <<<EOTEXT
|
||||||
salmon
|
salmon
|
||||||
|
|
||||||
|
@ -50,6 +41,58 @@ REPLY HANDLER ACTIONS
|
||||||
|
|
||||||
EOTEXT;
|
EOTEXT;
|
||||||
|
|
||||||
|
$this->assertEmail($expect, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testBodyRenderNoHerald() {
|
||||||
|
$expect = <<<EOTEXT
|
||||||
|
salmon
|
||||||
|
|
||||||
|
HEADER
|
||||||
|
bass
|
||||||
|
trout
|
||||||
|
|
||||||
|
REPLY HANDLER ACTIONS
|
||||||
|
pike
|
||||||
|
|
||||||
|
EOTEXT;
|
||||||
|
|
||||||
|
$this->assertEmail($expect, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testBodyRenderNoReply() {
|
||||||
|
$expect = <<<EOTEXT
|
||||||
|
salmon
|
||||||
|
|
||||||
|
HEADER
|
||||||
|
bass
|
||||||
|
trout
|
||||||
|
|
||||||
|
MANAGE HERALD RULES
|
||||||
|
http://test.com/rules/
|
||||||
|
|
||||||
|
WHY DID I GET THIS EMAIL?
|
||||||
|
http://test.com/xscript/
|
||||||
|
|
||||||
|
EOTEXT;
|
||||||
|
|
||||||
|
$this->assertEmail($expect, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertEmail($expect, $herald_hints, $reply_hints) {
|
||||||
|
$env = PhabricatorEnv::beginScopedEnv();
|
||||||
|
$env->overrideEnvConfig('phabricator.base-uri', 'http://test.com/');
|
||||||
|
$env->overrideEnvConfig('metamta.herald.show-hints', $herald_hints);
|
||||||
|
$env->overrideEnvConfig('metamta.reply.show-hints', $reply_hints);
|
||||||
|
|
||||||
|
$body = new PhabricatorMetaMTAMailBody();
|
||||||
|
$body->addRawSection("salmon");
|
||||||
|
$body->addTextSection("HEADER", "bass\ntrout\n");
|
||||||
|
$body->addHeraldSection("/rules/", "/xscript/");
|
||||||
|
$body->addReplySection("pike");
|
||||||
|
|
||||||
$this->assertEqual($expect, $body->render());
|
$this->assertEqual($expect, $body->render());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue