post_type, $post_types, true ) ) { return; } $activitypub_post = new Post( $post ); if ( 'publish' === $new_status && 'publish' !== $old_status ) { \wp_schedule_single_event( \time(), 'activitypub_send_create_activity', array( $activitypub_post ) ); } elseif ( 'publish' === $new_status ) { \wp_schedule_single_event( \time(), 'activitypub_send_update_activity', array( $activitypub_post ) ); } elseif ( 'trash' === $new_status ) { \wp_schedule_single_event( \time(), 'activitypub_send_delete_activity', array( $activitypub_post ) ); } } /** * Update followers * * @return void */ public static function update_followers() { $followers = Followers::get_outdated_followers( ACTIVITYPUB_OBJECT ); foreach ( $followers as $follower ) { $meta = get_remote_metadata_by_actor( $follower->get_actor() ); if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) { $follower->set_error( $meta ); } else { $follower->from_meta( $meta ); } $follower->update(); } } /** * Cleanup followers * * @return void */ public static function cleanup_followers() { $followers = Followers::get_faulty_followers( ACTIVITYPUB_OBJECT ); foreach ( $followers as $follower ) { $meta = get_remote_metadata_by_actor( $follower->get_actor() ); if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) { if ( 5 >= $follower->count_errors() ) { $follower->delete(); } else { $follower->set_error( $meta ); $follower->update(); } } else { $follower->reset_errors(); } } } }