fix code smells
This commit is contained in:
parent
7fa58cf26c
commit
85ca37aa1d
2 changed files with 22 additions and 13 deletions
|
@ -320,7 +320,12 @@ function url_to_authorid( $url ) {
|
|||
* @return WP_Comment, or undef if no comment could be found.
|
||||
*/
|
||||
function object_id_to_comment( $id ) {
|
||||
$comment_query = new \WP_Comment_Query( array( 'meta_key' => 'source_id', 'meta_value' => $id ) );
|
||||
$comment_query = new \WP_Comment_Query(
|
||||
array(
|
||||
'meta_key' => 'source_id',
|
||||
'meta_value' => $id,
|
||||
)
|
||||
);
|
||||
if ( ! $comment_query->comments ) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ class Inbox {
|
|||
|
||||
// Objects must have IDs
|
||||
if ( ! isset( $object['object']['id'] ) ) {
|
||||
\error_log( "Comment provided without ID" );
|
||||
\error_log( 'Comment provided without ID' );
|
||||
return;
|
||||
}
|
||||
$id = $object['object']['id'];
|
||||
|
@ -465,9 +465,13 @@ class Inbox {
|
|||
$parent_comment = \Activitypub\object_id_to_comment( $in_reply_to );
|
||||
|
||||
// save only replies and reactions
|
||||
$comment_post_id = \Activitypub\object_to_post_id_by_field_name( $object, 'context' ) ??
|
||||
\Activitypub\object_to_post_id_by_field_name( $object, 'inReplyTo' ) ??
|
||||
( $parent_comment ? $parent_comment->comment_post_ID : 0 );
|
||||
$comment_post_id = \Activitypub\object_to_post_id_by_field_name( $object, 'context' );
|
||||
if ( ! $comment_post_id ) {
|
||||
$comment_post_id = \Activitypub\object_to_post_id_by_field_name( $object, 'inReplyTo' );
|
||||
}
|
||||
if ( ! $comment_post_id ) {
|
||||
$comment_post_id = $parent_comment->comment_post_ID;
|
||||
}
|
||||
if ( ! $comment_post_id ) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue