mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Validate room first in MessageAction::send()
This commit is contained in:
parent
ae2d02ae64
commit
7046452b58
@ -44,6 +44,18 @@ public function prune() {
|
||||
* Validates message sending.
|
||||
*/
|
||||
public function validateSend() {
|
||||
// read user data
|
||||
$this->parameters['userData']['color'] = \chat\util\ChatUtil::readUserData('color');
|
||||
$this->parameters['userData']['roomID'] = \chat\util\ChatUtil::readUserData('roomID');
|
||||
$this->parameters['userData']['away'] = \chat\util\ChatUtil::readUserData('away');
|
||||
|
||||
// read and validate room
|
||||
$cache = room\Room::getCache();
|
||||
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
|
||||
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
|
||||
|
||||
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
|
||||
// read parameters
|
||||
$this->readString('text');
|
||||
$this->readBoolean('enableSmilies');
|
||||
@ -67,18 +79,6 @@ public function validateSend() {
|
||||
}
|
||||
}
|
||||
|
||||
// read user data
|
||||
$this->parameters['userData']['color'] = \chat\util\ChatUtil::readUserData('color');
|
||||
$this->parameters['userData']['roomID'] = \chat\util\ChatUtil::readUserData('roomID');
|
||||
$this->parameters['userData']['away'] = \chat\util\ChatUtil::readUserData('away');
|
||||
|
||||
// read and validate room
|
||||
$cache = room\Room::getCache();
|
||||
if (!isset($cache[$this->parameters['userData']['roomID']])) throw new \wcf\system\exception\IllegalLinkException();
|
||||
$this->parameters['room'] = $cache[$this->parameters['userData']['roomID']];
|
||||
|
||||
if (!$this->parameters['room']->canEnter() || !$this->parameters['room']->canWrite()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
|
||||
\chat\util\ChatUtil::writeUserData(array('away' => null));
|
||||
|
||||
// mark user as back
|
||||
|
Loading…
Reference in New Issue
Block a user