get_json_params(); if ( empty( $activity['type'] ) ) { return false; } if ( 'Create' !== $activity['type'] ) { return $valid; } if ( ! isset( $activity['object'] ) || ! \is_array( $activity['object'] ) ) { return false; } if ( ! isset( $activity['object']['id'] ) ) { return false; } if ( ! isset( $activity['object']['content'] ) ) { /* * Image-only replies and quotes have something to show only when comment images are enabled; * other posts still need text. This runs before the signature check, so it leaves the host * checks to Interactions::add_comment(). */ if ( ( ! is_activity_reply( $activity ) && ! is_quote_activity( $activity ) ) || ! Interactions::get_image_attachments( $activity['object'], false ) ) { return false; } } return $valid; } /** * Remove a URL from the tombstone registry when a Create or Update activity is sent. * * This handles the case where a post was soft-deleted (visibility changed to local/private) * and then later changed back to public. The Create/Update activity indicates the post is being * re-federated, so we remove it from the tombstone registry. * * @param int $outbox_id The ID of the outbox activity. * @param \Activitypub\Activity\Activity $activity The Activity object. * * @return void */ public static function maybe_unbury( $outbox_id, $activity ) { if ( ! \in_array( $activity->get_type(), array( 'Create', 'Update' ), true ) ) { return; } $object = $activity->get_object(); if ( $object ) { Tombstone::remove( $object->get_id(), $object->get_url() ); } } }