@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.

Use the customizable "Welcome Mail" message in welcome mail

Summary:
Depends on D19994. See PHI1027. If an install has customized the "Welcome Mail" message, include it in welcome mail. A special custom message from the profile screen overrides it, if provided.

(I fiddled with putting the custom message as "placeholder" text in the remarkup area as a hint, but newlines in "placeholder" text appear to have issues in Safari and Firefox. I think this is probably reasonably clear as-is.)

Make both render remarkup-into-text so things like links work properly, as it's reasonably likely that installs will want to link to things.

Test Plan:
- With custom "Welcome Mail" text, sent mail with no custom override (got custom text) and a custom override (got overridden text).
- Linked to some stuff, got sensible links in the mail (`bin/mail show-outbound`).

Reviewers: amckinley

Reviewed By: amckinley

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

+65 -20
+9 -3
src/applications/auth/storage/PhabricatorAuthMessage.php
··· 61 61 return $this->getMessageType()->getDisplayName(); 62 62 } 63 63 64 - public static function loadMessageText( 64 + public static function loadMessage( 65 65 PhabricatorUser $viewer, 66 66 $message_key) { 67 - 68 - $message = id(new PhabricatorAuthMessageQuery()) 67 + return id(new PhabricatorAuthMessageQuery()) 69 68 ->setViewer($viewer) 70 69 ->withMessageKeys(array($message_key)) 71 70 ->executeOne(); 71 + } 72 + 73 + public static function loadMessageText( 74 + PhabricatorUser $viewer, 75 + $message_key) { 76 + 77 + $message = self::loadMessage($viewer, $message_key); 72 78 73 79 if (!$message) { 74 80 return null;
+19 -7
src/applications/people/controller/PhabricatorPeopleWelcomeController.php
··· 48 48 return id(new AphrontRedirectResponse())->setURI($profile_uri); 49 49 } 50 50 51 + $default_message = PhabricatorAuthMessage::loadMessage( 52 + $admin, 53 + PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY); 54 + if (strlen($default_message->getMessageText())) { 55 + $message_instructions = pht( 56 + 'The email will identify you as the sender. You may optionally '. 57 + 'replace the [[ %s | default custom mail body ]] with different text '. 58 + 'by providing a message below.', 59 + $default_message->getURI()); 60 + } else { 61 + $message_instructions = pht( 62 + 'The email will identify you as the sender. You may optionally '. 63 + 'include additional text in the mail body by specifying it below.'); 64 + } 65 + 51 66 $form = id(new AphrontFormView()) 52 67 ->setViewer($admin) 53 - ->appendInstructions( 68 + ->appendRemarkupInstructions( 54 69 pht( 55 70 'This workflow will send this user ("%s") a copy of the "Welcome to '. 56 71 'Phabricator" email that users normally receive when their '. 57 72 'accounts are created by an administrator.', 58 73 $user->getUsername())) 59 - ->appendInstructions( 74 + ->appendRemarkupInstructions( 60 75 pht( 61 76 'The email will contain a link that the user may use to log in '. 62 77 'to their account. This link bypasses authentication requirements '. 63 78 'and allows them to log in without credentials. Sending a copy of '. 64 79 'this email can be useful if the original was lost or never sent.')) 65 - ->appendInstructions( 66 - pht( 67 - 'The email will identify you as the sender. You may optionally '. 68 - 'include additional text in the mail body by specifying it below.')) 80 + ->appendRemarkupInstructions($message_instructions) 69 81 ->appendControl( 70 - id(new AphrontFormTextAreaControl()) 82 + id(new PhabricatorRemarkupControl()) 71 83 ->setName('message') 72 84 ->setLabel(pht('Custom Message')) 73 85 ->setValue($v_message));
+11
src/applications/people/mail/PhabricatorPeopleMailEngine.php
··· 58 58 throw new PhabricatorPeopleMailEngineException($title, $body); 59 59 } 60 60 61 + final protected function newRemarkupText($text) { 62 + $recipient = $this->getRecipient(); 63 + 64 + $engine = PhabricatorMarkupEngine::newMarkupEngine(array()) 65 + ->setConfig('viewer', $recipient) 66 + ->setConfig('uri.base', PhabricatorEnv::getProductionURI('/')) 67 + ->setMode(PhutilRemarkupEngine::MODE_TEXT); 68 + 69 + return $engine->markupText($text); 70 + } 71 + 61 72 }
+26 -10
src/applications/people/mail/PhabricatorPeopleWelcomeMailEngine.php
··· 49 49 $sender = $this->getSender(); 50 50 $recipient = $this->getRecipient(); 51 51 52 - $recipient_username = $recipient->getUserName(); 53 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 54 - 55 52 $base_uri = PhabricatorEnv::getProductionURI('/'); 56 53 57 54 $engine = new PhabricatorAuthSessionEngine(); ··· 99 96 $message[] = pht(' %s', $base_uri); 100 97 } 101 98 102 - $custom_body = $this->getWelcomeMessage(); 103 - if (strlen($custom_body)) { 104 - $message[] = $custom_body; 105 - } else { 106 - if (!$is_serious) { 107 - $message[] = pht("Love,\nPhabricator"); 108 - } 99 + $message_body = $this->newBody(); 100 + if ($message_body !== null) { 101 + $message[] = $message_body; 109 102 } 110 103 111 104 $message = implode("\n\n", $message); ··· 114 107 ->addTos(array($recipient->getPHID())) 115 108 ->setSubject(pht('[Phabricator] Welcome to Phabricator')) 116 109 ->setBody($message); 110 + } 111 + 112 + private function newBody() { 113 + $recipient = $this->getRecipient(); 114 + 115 + $custom_body = $this->getWelcomeMessage(); 116 + if (strlen($custom_body)) { 117 + return $this->newRemarkupText($custom_body); 118 + } 119 + 120 + $default_body = PhabricatorAuthMessage::loadMessageText( 121 + $recipient, 122 + PhabricatorAuthWelcomeMailMessageType::MESSAGEKEY); 123 + if (strlen($default_body)) { 124 + return $this->newRemarkupText($default_body); 125 + } 126 + 127 + $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 128 + if (!$is_serious) { 129 + return pht("Love,\nPhabricator"); 130 + } 131 + 132 + return null; 117 133 } 118 134 119 135 }