From f63da85ec08abae00f980547ddf93e7ad73bd92f Mon Sep 17 00:00:00 2001 From: Alex Kirk Date: Sat, 21 Dec 2024 06:15:09 +0100 Subject: [PATCH] Log the newly supported ActivityPub events to the Friends Log --- .../class-feed-parser-activitypub.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/feed-parsers/class-feed-parser-activitypub.php b/feed-parsers/class-feed-parser-activitypub.php index aba3908c..6381284e 100644 --- a/feed-parsers/class-feed-parser-activitypub.php +++ b/feed-parsers/class-feed-parser-activitypub.php @@ -1065,13 +1065,32 @@ private function handle_incoming_update_person( $activity, User_Feed $user_feed $friend_user = $user_feed->get_friend_user(); $this->log( 'Received person update for ' . $friend_user->user_login, compact( 'activity' ) ); + $message = sprintf( + // translators: %s is the user login. + __( 'Received person update for %s', 'friends' ), + '' . esc_html( $friend_user->display_name ) . '' + ); + + $details = array(); + if ( ! empty( $activity['summary'] ) ) { + $details['old-summary'] = $friend_user->description; + $details['new-summary'] = $activity['summary']; + $friend_user->description = $activity['summary']; + $message .= __( 'Updated description.', 'friends' ); } if ( ! empty( $activity['icon']['url'] ) ) { + $details['old-summary'] = ''; + $details['new-summary'] = ''; $friend_user->update_user_icon_url( $activity['icon']['url'] ); } $friend_user->save(); + + $details['object'] = $activity; + + Logging::log( 'user-update', $message, $details, self::SLUG, 0, $friend_user->ID ); + return null; // No feed item to submit. } /** @@ -1261,6 +1280,7 @@ public function handle_incoming_move( $activity, User_Feed $user_feed ) { 'post-format' => $user_feed->get_post_format(), 'active' => $user_feed->is_active(), ); + $this->log( 'Received Move from ' . $old_url . ' to ' . $feed['url'] ); // Similar as in process_admin_edit_friend_feeds. if ( $user_feed->get_url() !== $feed['url'] ) { @@ -1296,7 +1316,19 @@ public function handle_incoming_move( $activity, User_Feed $user_feed ) { $user_feed->get_url() ) ); + + $message = sprintf( + // translators: %s is the new URL. + __( '%1$s moved to a new URL: %2$s', 'friends' ), + '' . esc_html( $feed['title'] ) . '', + '' . esc_html( $new_feed->get_title() ) . '' + ); + + Logging::log( 'feed-move', $message, $activity, self::SLUG, 0, $friend->ID ); + return $new_feed; + } else { + $this->log( 'Move URL didn\'t change, old: ' . $old_url . ', new: ' . $feed['url'] ); } return true;