Differential D14073 Diff 34742 src/applications/differential/mail/DifferentialCreateMailReceiver.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/mail/DifferentialCreateMailReceiver.php
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | $subject_prefix = | ||||
| PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix'); | PhabricatorEnv::getEnvConfig('metamta.differential.subject-prefix'); | ||||
| if (count($diffs)) { | if (count($diffs)) { | ||||
| $subject = pht( | $subject = pht( | ||||
| 'You successfully created %d diff(s).', | 'You successfully created %d diff(s).', | ||||
| count($diffs)); | count($diffs)); | ||||
| } else { | } else { | ||||
| $subject = pht( | $subject = pht( | ||||
| 'Diff creation failed; see body for %s error(s).', | 'Diff creation failed; see body for %s error(s).', | ||||
| new PhutilNumber(count($errors))); | phutil_count($errors)); | ||||
| } | } | ||||
| $body = new PhabricatorMetaMTAMailBody(); | $body = new PhabricatorMetaMTAMailBody(); | ||||
| $body->addRawSection($subject); | $body->addRawSection($subject); | ||||
| if (count($diffs)) { | if (count($diffs)) { | ||||
| $text_body = ''; | $text_body = ''; | ||||
| $html_body = array(); | $html_body = array(); | ||||
| $body_label = pht('%s DIFF LINK(S)', new PhutilNumber(count($diffs))); | $body_label = pht('%s DIFF LINK(S)', phutil_count($diffs)); | ||||
| foreach ($diffs as $filename => $diff_uri) { | foreach ($diffs as $filename => $diff_uri) { | ||||
| $text_body .= $filename.': '.$diff_uri."\n"; | $text_body .= $filename.': '.$diff_uri."\n"; | ||||
| $html_body[] = phutil_tag( | $html_body[] = phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $diff_uri, | 'href' => $diff_uri, | ||||
| ), | ), | ||||
| $filename); | $filename); | ||||
| $html_body[] = phutil_tag('br'); | $html_body[] = phutil_tag('br'); | ||||
| } | } | ||||
| $body->addTextSection($body_label, $text_body); | $body->addTextSection($body_label, $text_body); | ||||
| $body->addHTMLSection($body_label, $html_body); | $body->addHTMLSection($body_label, $html_body); | ||||
| } | } | ||||
| if (count($errors)) { | if (count($errors)) { | ||||
| $body_section = new PhabricatorMetaMTAMailSection(); | $body_section = new PhabricatorMetaMTAMailSection(); | ||||
| $body_label = pht('%s ERROR(S)', new PhutilNumber(count($errors))); | $body_label = pht('%s ERROR(S)', phutil_count($errors)); | ||||
| foreach ($errors as $error) { | foreach ($errors as $error) { | ||||
| $body_section->addFragment($error); | $body_section->addFragment($error); | ||||
| } | } | ||||
| $body->addTextSection($body_label, $body_section); | $body->addTextSection($body_label, $body_section); | ||||
| } | } | ||||
| id(new PhabricatorMetaMTAMail()) | id(new PhabricatorMetaMTAMail()) | ||||
| ->addTos(array($sender->getPHID())) | ->addTos(array($sender->getPHID())) | ||||
| ->setSubject($subject) | ->setSubject($subject) | ||||
| ->setSubjectPrefix($subject_prefix) | ->setSubjectPrefix($subject_prefix) | ||||
| ->setFrom($sender->getPHID()) | ->setFrom($sender->getPHID()) | ||||
| ->setBody($body->render()) | ->setBody($body->render()) | ||||
| ->saveAndSend(); | ->saveAndSend(); | ||||
| } | } | ||||
| } | } | ||||