From d061f8db2ea8b3de280954597b7063d0c36b73ec Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 28 Aug 2018 18:40:19 -0400 Subject: [PATCH] Simplify persisting activities --- inc/outbox.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/inc/outbox.php b/inc/outbox.php index f1c215a..4513ed3 100644 --- a/inc/outbox.php +++ b/inc/outbox.php @@ -60,18 +60,16 @@ function deliver_activity( $activity ) { function persist_activity( $actor, $activity ) { global $wpdb; - $activity_json = wp_json_encode($activity); + $activity_json = wp_json_encode( $activity ); $wpdb->insert( 'activitypub_outbox', array( "actor" => $actor, "activity" => $activity_json, ) ); - $persisted = json_decode( $wpdb->get_var( sprintf( - "SELECT activity FROM activitypub_outbox WHERE id = %d", $wpdb->insert_id - ) ) ); - $response = new WP_REST_Response( $persisted ); + // 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 object URL + // TODO set location header of response to created activity URL return $response; }