public function onUnsubscribe(CM_Model_Stream_Subscribe $streamSubscribe) { $unsubscriber = $streamSubscribe->getUser(); if ($unsubscriber && !$this->isSubscriber($unsubscriber, $streamSubscribe)) { $unsubscriber->setOfflineStamp(); } }
public function onUnsubscribe(CM_Model_Stream_Subscribe $streamSubscribe) { if ($this->hasUser()) { $user = $streamSubscribe->getUser(); if ($user && !$this->isSubscriber($user, $streamSubscribe)) { $delayedJobQueue = CM_Service_Manager::getInstance()->getDelayedJobQueue(); $delayedJobQueue->addJob(new CM_User_OfflineJob(), ['user' => $user], CM_Model_User::OFFLINE_DELAY); } } }
/** * @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; }