/** * @param User $user * @param UserCollection $userCollection */ public function notifyChat(User $user, UserCollection $userCollection) { $channelId = $user->getChannelId(); DI::get()->getLogger()->info("Total user count {$userCollection->getTotalCount()}", [__CLASS__]); if ($user->isInPrivateChat()) { $dualUsers = new UserCollection(); $dualUsers->attach($user); $response = (new MessageResponse())->setTime(null)->setGuests($userCollection->getUsersByChatId($channelId))->setChannelId($channelId); if ($userCollection->getClientsCount($channelId) > 1) { $dualUsers = $userCollection; $response->setMsg(MsgToken::create('PartnerIsOnline'))->setDualChat('match'); } elseif ($num = PendingDuals::get()->getUserPosition($user)) { $response->setMsg(MsgToken::create('StillInDualSearch', $num))->setDualChat('init'); } else { $response->setMsg(MsgToken::create('YouAreAlone'))->setDualChat('match'); } if ($user->getLastMsgId()) { $response->setMsg(Msg::create(null)); } $dualUsers->setResponse($response)->notify(false); } else { ChannelNotifier::welcome($user, $userCollection); ChannelNotifier::indentifyChat($user, $userCollection, true); } }
public static function run(User $user, UserCollection $users, ChannelsCollection $chats) { if (!$user->isInPrivateChat()) { return; } self::moveUsersToPublic($user, $users); self::informYouselfOnExit($user); ChannelNotifier::uploadHistory($user, true); ChannelNotifier::indentifyChat($user, $users); $chats->clean($user); }
public function matchDual(User $user) { if ($user->isInPrivateChat() || !$this->isCorrectUser($user)) { return false; } $tim = $user->getProperties()->getTim(); if (!$this->dualExists($user)) { $this->register($user); return false; } $queue = $this->getDualQueue($user)[$this->getDualTim($tim)]; $queue = array_flip($queue); $userId = $queue[1]; $this->deleteByUser(DI::get()->getUsers()->getClientById($userId)); return $userId; }