Skip to content

Commit c3bb2d0

Browse files
authored
Support multiple inReplyTos in post transformer (#2160)
1 parent c4562c4 commit c3bb2d0

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: changed
3+
4+
It’s now possible to reply to multiple posts using multiple reply blocks.

includes/transformer/class-post.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,16 +615,25 @@ protected function get_in_reply_to() {
615615
return null;
616616
}
617617

618-
$blocks = \parse_blocks( $this->item->post_content );
618+
$reply_urls = array();
619+
$blocks = \parse_blocks( $this->item->post_content );
619620

620621
foreach ( $blocks as $block ) {
621622
if ( 'activitypub/reply' === $block['blockName'] && isset( $block['attrs']['url'] ) ) {
622623
// We only support one reply block per post for now.
623-
return $block['attrs']['url'];
624+
$reply_urls[] = $block['attrs']['url'];
624625
}
625626
}
626627

627-
return null;
628+
if ( empty( $reply_urls ) ) {
629+
return null;
630+
}
631+
632+
if ( 1 === count( $reply_urls ) ) {
633+
return \current( $reply_urls );
634+
}
635+
636+
return \array_values( \array_unique( $reply_urls ) );
628637
}
629638

630639
/**

0 commit comments

Comments
 (0)