update comment model

This commit is contained in:
Django Doucet 2023-03-10 14:54:50 -07:00
parent a058ec0569
commit d07bb1f808

View file

@ -61,9 +61,9 @@ class Comment {
'attributedTo' => $this->comment_author_url, 'attributedTo' => $this->comment_author_url,
'summary' => $this->content_warning, 'summary' => $this->content_warning,
'inReplyTo' => $this->in_reply_to, 'inReplyTo' => $this->in_reply_to,
'content' => $comment->comment_content, 'content' => $this->get_content(),
'contentMap' => array( 'contentMap' => array(
\strstr( \get_locale(), '_', true ) => $comment->comment_content, \strstr( \get_locale(), '_', true ) => $this->get_content(),
), ),
'context' => $this->context, 'context' => $this->context,
// 'source' => \get_comment_link( $comment ), //non-conforming, see https://www.w3.org/TR/activitypub/#source-property // 'source' => \get_comment_link( $comment ), //non-conforming, see https://www.w3.org/TR/activitypub/#source-property
@ -99,10 +99,7 @@ class Comment {
} }
public function generate_permalink() { public function generate_permalink() {
$comment = $this->comment; return \get_comment_link( $this->comment );
$permalink = \get_comment_link( $comment );
// replace 'trashed' for delete activity
return \str_replace( '__trashed', '', $permalink );
} }
/** /**
@ -190,15 +187,23 @@ class Comment {
/** /**
* Who is being replied to * Who is being replied to
*/ */
public function generate_mention_recipients() { public function get_content() {
$recipients = array( AS_PUBLIC ); $comment = $this->comment;
$mentions = \get_comment_meta( $this->comment->comment_ID, 'mentions', true );
if ( ! empty( $mentions ) ) { if ( isset( $this->content ) ) {
foreach ( $mentions as $mention ) { return $this->content;
$recipients[] = $mention['href'];
} }
}
return $recipients; $comment_content = $comment->comment_content;
$filtered_content = \apply_filters( 'the_content', $comment_content, $comment );
$decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' );
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $decoded_content ) );
$this->content = $content;
return $content;
} }
/** /**