public function store()
{
// Make sure paste exists.
$pasteid = $this->getPaste()->getId();
if (!$this->getPaste()->exists()) {
throw new Exception('Invalid data.', 67);
}
// Make sure the discussion is opened in this paste and in configuration.
if (!$this->getPaste()->isOpendiscussion() || !$this->_conf->getKey('discussion')) {
throw new Exception('Invalid data.', 68);
}
// Check for improbable collision.
if ($this->exists()) {
throw new Exception('You are unlucky. Try again.', 69);
}
$this->_data->meta->postdate = time();
// store comment
if ($this->_store->createComment($pasteid, $this->getParentId(), $this->getId(), json_decode(json_encode($this->_data), true)) === false) {
throw new Exception('Error saving comment. Sorry.', 70);
}
}