protected function executeChecks()
 {
     try {
         PhabricatorNotificationClient::tryAnyConnection();
     } catch (Exception $ex) {
         $message = pht("Phabricator is configured to use a notification server, but is " . "unable to connect to it. You should resolve this issue or disable " . "the notification server. It may be helpful to double check your " . "configuration or restart the server using the command below.\n\n%s", phutil_tag('pre', array(), array(get_class($ex), "\n", $ex->getMessage())));
         $this->newIssue('aphlict.connect')->setShortName(pht('Notification Server Down'))->setName(pht('Unable to Connect to Notification Server'))->setMessage($message)->addRelatedPhabricatorConfig('notification.servers')->addCommand(pht("(To start the server, run this command.)\n%s", 'phabricator/ $ ./bin/aphlict start'));
         return;
     }
 }
 public function processRequest()
 {
     try {
         $status = PhabricatorNotificationClient::getServerStatus();
         $status = $this->renderServerStatus($status);
     } catch (Exception $ex) {
         $status = new AphrontErrorView();
         $status->setTitle('Notification Server Issue');
         $status->appendChild(hsprintf('Unable to determine server status. This probably means the server ' . 'is not in great shape. The specific issue encountered was:' . '<br />' . '<br />' . '<strong>%s</strong> %s', get_class($ex), phutil_escape_html_newlines($ex->getMessage())));
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Status'));
     return $this->buildApplicationPage(array($crumbs, $status), array('title' => pht('Notification Server Status'), 'device' => false));
 }
 protected function executeChecks()
 {
     $enabled = PhabricatorEnv::getEnvConfig('notification.enabled');
     if (!$enabled) {
         // Notifications aren't set up, so just ignore all of these checks.
         return;
     }
     try {
         $status = PhabricatorNotificationClient::getServerStatus();
     } catch (Exception $ex) {
         $message = pht("Phabricator is configured to use a notification server, but is " . "unable to connect to it. You should resolve this issue or disable " . "the notification server. It may be helpful to double check your " . "configuration or restart the server using the command below.\n\n%s", phutil_tag('pre', array(), array(get_class($ex), "\n", $ex->getMessage())));
         $this->newIssue('aphlict.connect')->setShortName(pht('Notification Server Down'))->setName(pht('Unable to Connect to Notification Server'))->setMessage($message)->addRelatedPhabricatorConfig('notification.enabled')->addRelatedPhabricatorConfig('notification.server-uri')->addCommand(pht("(To start the server, run this command.)\n%s", 'phabricator/ $ ./bin/aphlict start'));
         return;
     }
     $expect_version = PhabricatorNotificationClient::EXPECT_VERSION;
     $have_version = idx($status, 'version', 1);
     if ($have_version != $expect_version) {
         $message = pht('The notification server is out of date. You are running server ' . 'version %d, but Phabricator expects version %d. Restart the server ' . 'to update it, using the command below:', $have_version, $expect_version);
         $this->newIssue('aphlict.version')->setShortName(pht('Notification Server Version'))->setName(pht('Notification Server Out of Date'))->setMessage($message)->addCommand('phabricator/ $ ./bin/aphlict restart');
     }
 }
Ejemplo n.º 4
0
 protected function applyFinalEffects(PhabricatorLiskDAO $object, array $xactions)
 {
     $message_count = 0;
     foreach ($xactions as $xaction) {
         switch ($xaction->getTransactionType()) {
             case PhabricatorTransactions::TYPE_COMMENT:
                 $message_count++;
                 break;
         }
     }
     // update everyone's participation status on the last xaction -only-
     $xaction = end($xactions);
     $xaction_phid = $xaction->getPHID();
     $behind = ConpherenceParticipationStatus::BEHIND;
     $up_to_date = ConpherenceParticipationStatus::UP_TO_DATE;
     $participants = $object->getParticipants();
     $user = $this->getActor();
     $time = time();
     foreach ($participants as $phid => $participant) {
         if ($phid != $user->getPHID()) {
             if ($participant->getParticipationStatus() != $behind) {
                 $participant->setBehindTransactionPHID($xaction_phid);
                 $participant->setSeenMessageCount($object->getMessageCount() - $message_count);
             }
             $participant->setParticipationStatus($behind);
             $participant->setDateTouched($time);
         } else {
             $participant->setSeenMessageCount($object->getMessageCount());
             $participant->setBehindTransactionPHID($xaction_phid);
             $participant->setParticipationStatus($up_to_date);
             $participant->setDateTouched($time);
         }
         $participant->save();
     }
     if ($xactions) {
         $data = array('type' => 'message', 'threadPHID' => $object->getPHID(), 'messageID' => last($xactions)->getID(), 'subscribers' => array($object->getPHID()));
         PhabricatorNotificationClient::tryToPostMessage($data);
     }
     return $xactions;
 }
 private function sendNotification($chrono_key, array $subscribed_phids)
 {
     $data = array('key' => (string) $chrono_key, 'type' => 'notification', 'subscribers' => $subscribed_phids);
     PhabricatorNotificationClient::tryToPostMessage($data);
 }