1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-10-31 14:10:08 +00:00

Fix cronjob

This commit is contained in:
Tim Düsterhus 2013-05-03 20:02:18 +02:00
parent ee1114935a
commit deea3dcc19
3 changed files with 18 additions and 31 deletions

View File

@ -210,6 +210,20 @@ public function leave() {
\wcf\system\nodePush\NodePushHandler::getInstance()->sendMessage('be.bastelstu.chat.join');
}
/**
* Forces dead users to leave the chat.
*/
public function removeDeadUsers() {
$deadUsers = Room::getDeadUsers();
foreach ($deadUsers as $deadUser) {
$roomAction = new self(array(), 'leave', array(
'user' => $deadUser
));
$roomAction->executeAction();
}
}
/**
* Validates permissions.
*/

View File

@ -65,14 +65,9 @@ public function readData() {
$this->readMessages();
$this->users = $this->room->getUsers();
$deadUsers = data\room\Room::getDeadUsers();
foreach ($deadUsers as $deadUser) {
$roomAction = new data\room\RoomAction(array(), 'leave', array(
'user' => $deadUser
));
$roomAction = new data\room\RoomAction(array(), 'removeDeadUsers');
$roomAction->executeAction();
}
}
/**
* Fetches the new messages

View File

@ -24,29 +24,7 @@ public function execute(\wcf\data\cronjob\Cronjob $cronjob) {
$suspensionAction->executeAction();
// kill dead users
$deadUsers = \chat\util\ChatUtil::getDiedUsers();
foreach ($deadUsers as $deadUser) {
if (!$deadUser) continue;
$user = new \wcf\data\user\User($deadUser['userID']);
if (CHAT_DISPLAY_JOIN_LEAVE) {
$userData['color'] = \chat\util\ChatUtil::readUserData('color', $user);
$messageAction = new data\message\MessageAction(array(), 'create', array(
'data' => array(
'roomID' => $deadUser['roomID'],
'sender' => $user->userID,
'username' => $user->username,
'time' => TIME_NOW,
'type' => data\message\Message::TYPE_LEAVE,
'message' => '',
'color1' => $userData['color'][1],
'color2' => $userData['color'][2]
)
));
$messageAction->executeAction();
}
\chat\util\ChatUtil::writeUserData(array('roomID' => null), $user);
}
$roomAction = new data\room\RoomAction(array(), 'removeDeadUsers');
$roomAction->executeAction();
}
}