/** * Add a comment. * * @param array $args * @param \Vinelab\Minion\Dictionary $data * * @return array */ public function add($args, Dictionary $data) { if (TokenAuth::loginWithToken($data->access_token)) { $content = Content::make($data); $comment = $this->comments->add($data->comment, $content, TokenAuth::user()); $response = (array) Api::content(['CommentMapper', 'mapNewInstance'], $comment); $this->publish($this->getContentActionKey($content->id(), 'add'), [], $response['data']); $this->publishToModeration('add', $response['data']); return $response; } throw new UnAuthorizedException(); }
/** * Get the cache key for the given content. * * @param \Fahita\RealTime\Content $content * * @return string */ public function getContentKey(Content $content) { return 'content:' . $content->id(); }
/** * Get the cache key based on the given content instance. * * @param \Fahita\RealTime\Content $content * * @return string */ protected function getCacheKeyForContent(Content $content) { return ':' . $this->cache_prefix . ':' . $content->type() . ':' . $content->id(); }
/** * Make the comment of the given id as safe (not spam). * * @param int $comment * * @return bool */ public function unspam(Comment $comment) { // marking as spam is about moving the comment from the 'comments:{content}' set // to the `comments:{content}:spam` set. $content = Content::makeFromContent($comment->content); return $this->sorted->move($this->getSpamKeyForContent($content), $content, $comment->getKey()); }