400 ) ); } forward_activity( $activity ); $res = persist_activity( $actor_slug, $activity ); if ( is_wp_error( $res ) ) { return $res; } switch ( $activity['type'] ) { case 'Create': $activity = \activities\create\handle_inbox( $actor_slug, $activity ); break; case 'Update': $activity = \activities\update\handle_inbox( $actor_slug, $activity ); break; case 'Delete': $activity = \activities\delete\handle_inbox( $actor_slug, $activity ); break; case 'Follow': $activity = \activities\follow\handle_inbox( $actor_slug, $activity ); break; case 'Accept': $activity = \activities\accept\handle_inbox( $actor_slug, $activity ); break; case 'Reject': $activity = \activities\reject\handle_inbox( $actor_slug, $activity ); break; case 'Add': return new \WP_Error( 'not_implemented', __( 'The Add activity has not been implemented', 'pterotype' ), array( 'status' => 501 ) ); break; case 'Remove': return new \WP_Error( 'not_implemented', __( 'The Remove activity has not been implemented', 'pterotype' ), array( 'status' => 501 ) ); break; case 'Announce': $activity = \activities\announce\handle_inbox( $actor_slug, $activity ); break; case 'Undo': // TODO break; } if ( is_wp_error( $activity ) ) { return $activity; } return $res; } function forward_activity( $activity ) { // TODO } function persist_activity( $actory_slug, $activity ) { global $wpdb; $activity = \activities\persist_activity( $activity ); if ( is_wp_error( $activity ) ) { return $activity; } $activity_id = $wpdb->insert_id; $actor_id = \actors\get_actor_id( $actor_slug ); $wpdb->insert( 'pterotype_inbox', array( 'actor_id' => $actor_id, 'activity_id' => $activity_id, ) ); $response = new \WP_Rest_Response(); return $response; } ?>