From 3d1f15f652af02d58d767fbe402baf72f5b7d4ce Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Thu, 16 Jan 2025 13:29:59 +0100 Subject: [PATCH] Ingest Pixelfed's Image attachments (#430) --- feed-parsers/class-feed-parser-activitypub.php | 2 +- includes/class-feed.php | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/feed-parsers/class-feed-parser-activitypub.php b/feed-parsers/class-feed-parser-activitypub.php index aba3908c..5ad3a570 100644 --- a/feed-parsers/class-feed-parser-activitypub.php +++ b/feed-parsers/class-feed-parser-activitypub.php @@ -1023,7 +1023,7 @@ private function handle_incoming_create( $activity ) { if ( ! isset( $attachment['type'] ) || ! isset( $attachment['mediaType'] ) ) { continue; } - if ( 'Document' !== $attachment['type'] ) { + if ( ! in_array( $attachment['type'], array( 'Document', 'Image' ), true ) ) { continue; } diff --git a/includes/class-feed.php b/includes/class-feed.php index 02f201e6..549a2f6b 100644 --- a/includes/class-feed.php +++ b/includes/class-feed.php @@ -631,6 +631,11 @@ public function process_incoming_feed_items( array $items, User_Feed $user_feed if ( empty( $old_post->$field ) || empty( $post_data[ $field ] ) ) { continue; } + if ( 'post_content' === $field && $old_post->$field !== $post_data[ $field ] ) { + $modified_post_data[ $field ] = $post_data[ $field ]; + break; + } + if ( wp_strip_all_tags( $old_post->$field ) !== wp_strip_all_tags( $post_data[ $field ] ) ) { $modified_post_data[ $field ] = $post_data[ $field ]; break; @@ -654,6 +659,7 @@ public function process_incoming_feed_items( array $items, User_Feed $user_feed if ( intval( $old_post->comment_count ) !== intval( $item->comment_count ) ) { $modified_post_data['comment_count'] = $item->comment_count; } + wp_update_post( $modified_post_data ); $modified_posts[] = $post_id; }