replace ap_comment_id to reuse replytocom var

This commit is contained in:
Django Doucet 2022-11-15 08:27:51 -07:00
parent de74f1d70b
commit f87dbd87be
6 changed files with 12 additions and 12 deletions

View file

@ -97,12 +97,12 @@ class Activitypub {
*/ */
public static function add_query_vars( $vars ) { public static function add_query_vars( $vars ) {
$vars[] = 'activitypub'; $vars[] = 'activitypub';
$vars[] = 'ap_comment_id';//comment_id doesn't work, 'c' is probably too short and prone to collisions $vars[] = 'replytocom';
//Collections review //Collections review
$vars[] = 'replies'; $vars[] = 'replies';
$vars[] = 'collection_page'; $vars[] = 'collection_page';
$vars[] = 'only_other_accounts'; //$vars[] = 'only_other_accounts';
return $vars; return $vars;
} }

View file

@ -374,9 +374,9 @@ function url_to_commentid( $in_replyto_url ) {
if ( site_url() === $url_maybe_id['scheme'] . '://' . $url_maybe_id['host'] && ! empty( $url_maybe_id['query'] ) ) { if ( site_url() === $url_maybe_id['scheme'] . '://' . $url_maybe_id['host'] && ! empty( $url_maybe_id['query'] ) ) {
//is local post or comment //is local post or comment
\parse_str( $url_maybe_id['query'], $reply_query ); \parse_str( $url_maybe_id['query'], $reply_query );
if ( isset( $reply_query['ap_comment_id'] ) ) { if ( isset( $reply_query['replytocom'] ) ) {
//is local comment //is local comment
return $reply_query['ap_comment_id']; return $reply_query['replytocom'];
} }
} else { } else {
//is remote url //is remote url
@ -409,7 +409,7 @@ function url_to_commentid( $in_replyto_url ) {
* @return int comment_id * @return int comment_id
*/ */
function is_ap_comment() { function is_ap_comment() {
$comment_id = get_query_var( 'ap_comment_id', null ); $comment_id = get_query_var( 'replytocom', null );
if ( ! is_null( $comment_id ) ) { if ( ! is_null( $comment_id ) ) {
$comment = \get_comment( $comment_id ); $comment = \get_comment( $comment_id );
// Only return local origin comments // Only return local origin comments
@ -561,7 +561,7 @@ function set_ap_comment_id( $comment ) {
$ap_comment_id = \add_query_arg( $ap_comment_id = \add_query_arg(
array( array(
'p' => $comment->comment_post_ID, 'p' => $comment->comment_post_ID,
'ap_comment_id' => $comment->comment_ID, 'replytocom' => $comment->comment_ID,
), ),
\trailingslashit( site_url() ) \trailingslashit( site_url() )
); );

View file

@ -110,14 +110,14 @@ class Comment {
$in_reply_to = add_query_arg( $in_reply_to = add_query_arg(
array( array(
'p' => $comment->comment_post_ID, 'p' => $comment->comment_post_ID,
'ap_comment_id' => $comment->comment_parent, 'replytocom' => $comment->comment_parent,
), ),
trailingslashit( site_url() ) trailingslashit( site_url() )
); );
} }
} else { //parent is_post } else { //parent is_post
// Backwards compatibility // Backwards compatibility
$pretty_permalink = \get_post_meta( $comment->comment_post_ID, '_activitypub_permalink_compat', true ); // TODO finalize meta $pretty_permalink = \get_post_meta( $comment->comment_post_ID, '_activitypub_permalink_compat', true );
if ( $pretty_permalink ) { if ( $pretty_permalink ) {
$in_reply_to = $pretty_permalink; $in_reply_to = $pretty_permalink;
} else { } else {
@ -259,7 +259,7 @@ class Comment {
$comment_url = \add_query_arg( // $comment_url = \add_query_arg( //
array( array(
'p' => $comment->comment_post_ID, 'p' => $comment->comment_post_ID,
'ap_comment_id' => $comment->comment_ID, 'replytocom' => $comment->comment_ID,
), ),
trailingslashit( site_url() ) trailingslashit( site_url() )
); );

View file

@ -199,7 +199,7 @@ class Post {
$comment_url = \add_query_arg( // $comment_url = \add_query_arg( //
array( array(
'p' => $this->post->ID, 'p' => $this->post->ID,
'ap_comment_id' => $comment->comment_ID, 'replytocom' => $comment->comment_ID,
), ),
trailingslashit( site_url() ) trailingslashit( site_url() )
); );

View file

@ -1,5 +1,5 @@
<?php <?php
$comment = \get_comment( \get_query_var( 'ap_comment_id' ) ); $comment = \get_comment( \get_query_var( 'replytocom' ) );
$activitypub_comment = new \Activitypub\Model\Comment( $comment ); $activitypub_comment = new \Activitypub\Model\Comment( $comment );
$json = \array_merge( array( '@context' => \Activitypub\get_context() ), $activitypub_comment->to_array() ); $json = \array_merge( array( '@context' => \Activitypub\get_context() ), $activitypub_comment->to_array() );

View file

@ -14,7 +14,7 @@ $args = array(
$comments = get_comments( $args ); $comments = get_comments( $args );
$replies_request = \add_query_arg( $_SERVER['QUERY_STRING'], '', $post->guid ); $replies_request = \add_query_arg( $_SERVER['QUERY_STRING'], '', $post->guid );
$collection_id = \remove_query_arg(['page', 'ap_comment_id'], $replies_request ); $collection_id = \remove_query_arg(['page', 'replytocom'], $replies_request );
$json = new \stdClass(); $json = new \stdClass();
$json->{'@context'} = 'https://www.w3.org/ns/activitystreams'; $json->{'@context'} = 'https://www.w3.org/ns/activitystreams';