private function buildPropertyList(PhabricatorRepositoryPushEvent $event) { $viewer = $this->getRequest()->getUser(); $this->loadHandles(array($event->getPusherPHID())); $view = new PHUIPropertyListView(); $view->addProperty(pht('Pushed At'), phabricator_datetime($event->getEpoch(), $viewer)); $view->addProperty(pht('Pushed By'), $this->getHandle($event->getPusherPHID())->renderLink()); $view->addProperty(pht('Pushed Via'), $event->getRemoteProtocol()); return $view; }
private function sendMail(PhabricatorMailTarget $target, PhabricatorRepository $repository, PhabricatorRepositoryPushEvent $event) { $task_data = $this->getTaskData(); $viewer = $target->getViewer(); $locale = PhabricatorEnv::beginScopedLocale($viewer->getTranslation()); $logs = $event->getLogs(); list($ref_lines, $ref_list) = $this->renderRefs($logs); list($commit_lines, $subject_line) = $this->renderCommits($repository, $logs, idx($task_data, 'info', array())); $ref_count = count($ref_lines); $commit_count = count($commit_lines); $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($event->getPusherPHID()))->execute(); $pusher_name = $handles[$event->getPusherPHID()]->getName(); $repo_name = $repository->getMonogram(); if ($commit_count) { $overview = pht('%s pushed %d commit(s) to %s.', $pusher_name, $commit_count, $repo_name); } else { $overview = pht('%s pushed to %s.', $pusher_name, $repo_name); } $details_uri = PhabricatorEnv::getProductionURI('/diffusion/pushlog/view/' . $event->getID() . '/'); $body = new PhabricatorMetaMTAMailBody(); $body->addRawSection($overview); $body->addLinkSection(pht('DETAILS'), $details_uri); if ($commit_lines) { $body->addTextSection(pht('COMMITS'), implode("\n", $commit_lines)); } if ($ref_lines) { $body->addTextSection(pht('REFERENCES'), implode("\n", $ref_lines)); } $prefix = PhabricatorEnv::getEnvConfig('metamta.diffusion.subject-prefix'); $parts = array(); if ($commit_count) { $parts[] = pht('%s commit(s)', $commit_count); } if ($ref_count) { $parts[] = implode(', ', $ref_list); } $parts = implode(', ', $parts); if ($subject_line) { $subject = pht('(%s) %s', $parts, $subject_line); } else { $subject = pht('(%s)', $parts); } $mail = id(new PhabricatorMetaMTAMail())->setRelatedPHID($event->getPHID())->setSubjectPrefix($prefix)->setVarySubjectPrefix(pht('[Push]'))->setSubject($subject)->setFrom($event->getPusherPHID())->setBody($body->render())->setThreadID($event->getPHID(), $is_new = true)->addHeader('Thread-Topic', $subject)->setIsBulk(true); $target->sendMail($mail); }