diff --git a/inc/activities.php b/inc/activities.php index c0a7748..767ee6c 100644 --- a/inc/activities.php +++ b/inc/activities.php @@ -11,7 +11,7 @@ function get_activity( $id ) { 'not_found', __( 'Activity not found', 'activitypub' ), array( 'status' => 404 ) ); } - $activity = json_decode( $activity_json ); + $activity = json_decode( $activity_json, true ); $activity['id'] = get_activity_url( $id ); return $activity; } diff --git a/inc/api.php b/inc/api.php index 4d42dec..918625c 100644 --- a/inc/api.php +++ b/inc/api.php @@ -14,7 +14,7 @@ function get_actor( $request ) { function post_to_outbox( $request ) { $actor = $request['actor']; - $activity = json_decode( $request->get_body() ); + $activity = json_decode( $request->get_body(), true ); return \outbox\handle_activity( $actor, $activity ); } diff --git a/inc/objects.php b/inc/objects.php index 40a5a1b..81ab117 100644 --- a/inc/objects.php +++ b/inc/objects.php @@ -18,7 +18,7 @@ function get_object( $id ) { 404, __( 'Object not found', 'activitypub' ), array ( 'status' => 404 ) ); } - $object = json_decode( $object_json ); + $object = json_decode( $object_json, true ); $object['id'] = get_object_url( $id ); return $object; } diff --git a/inc/outbox.php b/inc/outbox.php index 3fea279..53b94e6 100644 --- a/inc/outbox.php +++ b/inc/outbox.php @@ -25,7 +25,7 @@ function handle_activity( $actor, $activity ) { } switch ( $activity['type'] ) { case 'Create': - $activity = \activites\create\handle( $actor, $activity ); + $activity = \activities\create\handle( $actor, $activity ); break; case 'Update': break; @@ -68,7 +68,7 @@ function persist_activity( $actor, $activity ) { 'actor' => $actor, 'activity_id' => $activity_id, ) ); - $response = new WP_REST_Response(); + $response = new \WP_REST_Response(); $response->set_status( 201 ); $response->header( 'Location', $activity['id'] ); return $response; @@ -81,7 +81,9 @@ function create_outbox_table() { CREATE TABLE IF NOT EXISTS activitypub_outbox ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, actor VARCHAR(128) NOT NULL, - activity_id INT UNSIGNED FOREIGN KEY REFERENCES activitypub_activities(id) + activity_id INT UNSIGNED NOT NULL, + FOREIGN KEY activity_fk(activity_id) + REFERENCES activitypub_activities(id) ); " );