/** * @param User $user * @param UserCollection $users */ private static function moveUsersToPublic(User $user, UserCollection $users) { $partners = $users->getUsersByChatId($user->getChannelId()); $response = (new MessageResponse())->setTime(null)->setMsg(MsgToken::create('UserLeftPrivate', $user->getProperties()->getName()))->setDualChat('exit')->setChannelId($user->getChannelId()); $users->setResponse($response)->notify(); foreach ($partners as $pUser) { $pUser->setChannelId(1); $pUser->save(); } }
private function notifyOnClose(User $user, UserCollection $clients) { $response = new MessageResponse(); if ($user->isAsyncDetach()) { $response->setMsg(MsgToken::create('LeavesUs', $user->getProperties()->getName())); } $response->setTime(null)->setGuests($clients->getUsersByChatId($user->getChannelId()))->setChannelId($user->getChannelId()); $clients->setResponse($response)->notify(); ChannelNotifier::updateChannelInfo($clients, ChannelsCollection::get()); }
private function sendPublic(UserCollection $clients, User $user, $msg, $isSelf) { $props = $user->getProperties(); $filteredMsg = RudeFilter::parse($msg); if (mb_strlen($filteredMsg) != mb_strlen($msg)) { $props->setRudeCount($props->getRudeCount() + 1); } $props->setWordsCount($props->getWordsCount() + mb_substr_count($msg, ' ') + 1); $response = (new MessageResponse())->setMsg(Msg::create($msg))->setFilteredMsg(Msg::create($filteredMsg))->setTime(null)->setChannelId($user->getChannelId()); if (!$isSelf) { $response->setFrom($user); } $clients->setResponse($response)->notify(); }
public static function updateGuestsList(UserCollection $userCollection, $channelId) { $userCollection->setResponse((new MessageResponse())->setGuests($userCollection->getUsersByChatId($channelId))->setChannelId($channelId))->notify(false); }
private static function sendMatchResponse(array $users, MsgContainer $msg) { $notification = new UserCollection(); foreach ($users as $user) { $notification->attach($user); } $user = $users[0]; /* @var $user User */ $response = (new MessageResponse())->setDualChat('match')->setMsg($msg)->setChannelId($user->getChannelId())->setGuests($users); $notification->setResponse($response)->notify(); }