Exemplo n.º 1
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);
 }