400 ) ); } switch ( $activity["type"] ) { case "Create": $activity = \activites\create\handle( $actor, $activity ); break; case "Update": break; case "Delete": break; case "Follow": break; case "Add": break; case "Remove": break; case "Like": break; case "Block": break; case "Undo": break; default: // handle wrapping object in Create activity break; } if ( is_wp_error( $activity ) ) { return $activity; } else { deliver_activity( $activity ); return persist_activity( $actor, $activity ); } } function deliver_activity( $activity ) { // TODO } function persist_activity( $actor, $activity ) { global $wpdb; $activity_json = wp_json_encode( $activity ); $wpdb->insert( 'activitypub_outbox', array( "actor" => $actor, "activity" => $activity_json, ) ); // TODO hydrate $activity["id"] with URL to activity using $wpdb->insert_id $response = new WP_REST_Response( $activity ); $response->set_status( 201 ); // TODO set location header of response to created activity URL return $response; } function create_outbox_table() { global $wpdb; $wpdb->query( " CREATE TABLE IF NOT EXISTS activitypub_outbox ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, actor VARCHAR(128) NOT NULL, activity TEXT NOT NULL ); " ); } ?>