Skip to content

Commit

Permalink
Fix in reply to with ActivityPub 1.0 (#257)
Browse files Browse the repository at this point in the history
* Fix inReplyTo

* Support old version

* typo
  • Loading branch information
akirk authored Oct 12, 2023
1 parent c0bef62 commit 6e0951f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion feed-parsers/class-feed-parser-activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ public function __construct( Feed $friends_feed ) {
\add_filter( 'the_content', array( $this, 'the_content' ), 99, 2 );
\add_filter( 'activitypub_extract_mentions', array( $this, 'activitypub_extract_mentions' ), 10, 2 );
\add_filter( 'mastodon_api_external_mentions_user', array( $this, 'get_external_mentions_user' ) );
add_filter( 'activitypub_post', array( $this, 'activitypub_post_in_reply_to' ), 10, 2 );
\add_filter( 'activitypub_post', array( $this, 'activitypub_post_in_reply_to' ), 10, 2 );
\add_filter( 'activitypub_activity_object_array', array( $this, 'activitypub_activity_object_array_in_reply_to' ), 10, 3 );

\add_action( 'friends_user_post_reaction', array( $this, 'post_reaction' ) );
\add_action( 'friends_user_post_undo_reaction', array( $this, 'undo_post_reaction' ) );
Expand Down Expand Up @@ -505,7 +506,14 @@ public function activitypub_post_in_reply_to( $ret, $post ) {
$ret['inReplyTo'] = get_post_meta( $post->ID, 'activitypub_in_reply_to', true );
$ret['object']['inReplyTo'] = $ret['inReplyTo'];
}
return $ret;
}

public function activity_object_array_in_reply_to( $ret, $c, $url ) {
$post_id = url_to_postid( $url );
if ( get_post_meta( $post_id, 'activitypub_in_reply_to', true ) ) {
$ret['inReplyTo'] = get_post_meta( $post_id, 'activitypub_in_reply_to', true );
}
return $ret;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public function ajax_frontend_publish_post() {
$result = 'empty';

if ( ! empty( $_POST['in_reply_to'] ) ) {
$p['post_meta_input'] = array(
$p['meta_input'] = array(
'activitypub_in_reply_to' => $_POST['in_reply_to'],
);
}
Expand Down

0 comments on commit 6e0951f

Please sign in to comment.