public static function notifyOnPendingDuals(User $user) { if (!empty(PendingDuals::get()->getUsersByDual($user))) { $response = (new MessageResponse())->setMsg(MsgToken::create('DualIsWanted', $user->getProperties()->getTim()->getShortName()))->setTime(null)->setChannelId($user->getChannelId()); (new UserCollection())->attach($user)->setResponse($response)->notify(false); } }
/** * @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); } }
private function unbanResponse(User $user, UserDAO $unBanUserDAO) { $response = (new MessageResponse())->setMsg(MsgToken::create('UserIsUnbanned', $unBanUserDAO->getPropeties()->getName()))->setTime(null)->setChannelId($user->getChannelId())->setGuests(DI::get()->getUsers()->getUsersByChatId($user->getChannelId())); (new UserCollection())->attach($user)->setResponse($response)->notify(false); if ($unBanUser = DI::get()->getUsers()->getClientById($unBanUserDAO->getId())) { $response = (new MessageResponse())->setMsg(MsgToken::create('UserUnbannedYou', $user->getProperties()->getName()))->setChannelId($unBanUser->getChannelId())->setTime(null); (new UserCollection())->attach($unBanUser)->setResponse($response)->notify(false); } }
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 static function informOnPendingExit(User $user) { $response = (new MessageResponse())->setChannelId($user->getChannelId())->setTime(null)->setDualChat('exit')->setMsg(MsgToken::create('ExitDualQueue')); (new UserCollection())->attach($user)->setResponse($response)->notify(false); }
private function forbiddenChangeInDualization(User $user) { $response = (new UserPropetiesResponse())->setUserProps($user)->setMsg(MsgToken::create('ProfileChangeForbiddenInDualization'))->setChannelId($user->getChannelId()); (new UserCollection())->attach($user)->setResponse($response)->notify(); }
private static function getTimeoutCallableResponse() { return function (User $userInviter, User $desiredUser) { $response = (new MessageResponse())->setMsg(MsgToken::create('UserInviteTimeout', $userInviter->getProperties()->getName()))->setChannelId($desiredUser->getChannelId())->setTime(null); (new UserCollection())->setResponse($response)->attach($desiredUser)->notify(false); $response = (new MessageResponse())->setMsg(MsgToken::create('SelfInviteTimeout', $desiredUser->getProperties()->getName()))->setChannelId($userInviter->getChannelId())->setTime(null); (new UserCollection())->setResponse($response)->attach($userInviter)->notify(false); }; }
private static function sendRenewPositions(array $userIds) { if (empty($userIds)) { return; } $notification = new UserCollection(); $users = DI::get()->getUsers(); foreach ($userIds as $userId) { $user = $users->getClientById($userId); $response = (new MessageResponse())->setMsg(MsgToken::create('DualQueueShifted', count($userIds)))->setDualChat('init')->setTime(null)->setChannelId($user->getChannelId()); $notification->attach($user)->setResponse($response); } $notification->notify(false); }
private static function informYouselfOnExit(User $user) { $response = (new MessageResponse())->setChannelId($user->getChannelId())->setTime(null)->setDualChat('exit')->setMsg(MsgToken::create('ReturnedToMainChat')); (new UserCollection())->attach($user)->setResponse($response)->notify(false); }
private function checkReferral(User $user) { $ref = ReferralDAO::create()->getFirstRefByUserId($user->getId()); if (!$ref) { return; } $users = DI::get()->getUsers(); if ($refUserOnline = $users->getClientById($ref->getRefUserId())) { $refUser = $refUserOnline->getUserDAO(); } else { $refUser = UserDAO::create()->getById($ref->getRefUserId()); } if (!$refUser->getId()) { return; } $mark = UserKarmaDAO::create()->setUserId($refUser->getId())->setEvaluator($user)->setMark(5)->setDateRegister(DbQueryHelper::timestamp2date()); $mark->save(); $props = $refUser->getPropeties(); $props->setKarma($props->getKarma() + 5); if ($refUserOnline) { $refUserOnline->save(); $response = (new MessageResponse())->setGuests($users->getUsersByChatId($refUserOnline->getChannelId()))->setChannelId($refUserOnline->getChannelId())->setTime(null); $users->setResponse($response)->notify(); $response = (new MessageResponse())->setMsg(MsgToken::create('profile.referralKarma'))->setChannelId($refUserOnline->getChannelId())->setTime(null); (new UserCollection())->attach($refUserOnline)->setResponse($response)->notify(false); } else { $props->save(false); } DI::get()->getLogger()->info('Added karma to referral userId ' . $props->getUserId()); }