示例#1
0
文件: Service.php 项目: cargomedia/cm
 /**
  * @param CM_Model_Stream_Subscribe $streamSubscribe
  * @return bool
  * @throws CM_Exception_Invalid
  */
 protected function _isSubscribeAllowed(CM_Model_Stream_Subscribe $streamSubscribe)
 {
     /** @var CM_Model_StreamChannel_Media|CM_StreamChannel_DisallowInterface $streamChannel */
     $streamChannel = $streamSubscribe->getStreamChannel();
     if (!$streamChannel instanceof CM_StreamChannel_DisallowInterface) {
         throw new CM_Exception_Invalid('Streamchannel does not disallow client-connections', ['streamChannel' => $streamChannel]);
     }
     if ($streamSubscribe->getAllowedUntil() < time()) {
         $canSubscribeUntil = $streamChannel->canSubscribe($streamSubscribe->getUser(), $streamSubscribe->getAllowedUntil());
         $streamSubscribe->setAllowedUntil($canSubscribeUntil);
         if ($streamSubscribe->getAllowedUntil() < time()) {
             return false;
         }
     }
     return true;
 }