/**
* {@inheritdoc}
*/
protected function getDefaultAttributes($post)
{
$attributes = parent::getDefaultAttributes($post);
unset($attributes['content']);
$gate = $this->gate->forUser($this->actor);
$canEdit = $gate->allows('edit', $post);
if ($post instanceof CommentPost) {
$attributes['contentHtml'] = $post->content_html;
if ($canEdit) {
$attributes['content'] = $post->content;
}
if ($gate->allows('viewIps', $post)) {
$attributes['ipAddress'] = $post->ip_address;
}
} else {
$attributes['content'] = $post->content;
}
if ($post->edit_time) {
$attributes['editTime'] = $this->formatDate($post->edit_time);
}
if ($post->hide_time) {
$attributes['isHidden'] = true;
$attributes['hideTime'] = $this->formatDate($post->hide_time);
}
$attributes += ['canEdit' => $canEdit, 'canDelete' => $gate->allows('delete', $post)];
return $attributes;
}