diff --git a/includes/server/followers.php b/includes/server/followers.php index dd59f5a..13ddb87 100644 --- a/includes/server/followers.php +++ b/includes/server/followers.php @@ -89,12 +89,17 @@ function get_followers_collection( $actor_slug ) { ", $actor_id ), - ARRAY_N + ARRAY_A ); if ( !$followers ) { $followers = array(); } - $collection = \collections\make_ordered_collection( $followers ); + $collection = \collections\make_ordered_collection( array_map( + function ( $result ) { + return json_decode( $result['object'], true ); + }, + $followers + ) ); $collection['id'] = get_rest_url( null, sprintf( '/pterotype/v1/actor/%s/followers', $actor_slug ) ); diff --git a/includes/server/following.php b/includes/server/following.php index b6266fb..032df4f 100644 --- a/includes/server/following.php +++ b/includes/server/following.php @@ -62,7 +62,12 @@ function get_following_collection( $actor_slug ) { if ( !$objects ) { $objects = array(); } - $collection = \collections\make_ordered_collection( $objects ); + $collection = \collections\make_ordered_collection( array_map( + function( $result ) { + return json_decode( $result['object'], true ); + }, + $objects + ) ); $collection['id'] = get_rest_url( null, sprintf( '/pterotype/v1/actor/%s/following', $actor_slug ) ); diff --git a/includes/server/inbox.php b/includes/server/inbox.php index 96c71e1..f246545 100644 --- a/includes/server/inbox.php +++ b/includes/server/inbox.php @@ -25,6 +25,8 @@ require_once plugin_dir_path( __FILE__ ) . '../util.php'; function handle_activity( $actor_slug, $activity ) { // TODO how should I handle duplicate activities getting posted here and in the outbox? // Is it okay to just drop them if I already have the activity id in the objects table? + // A good strategy would just be to make sure all activities are idempotent, e.g. + // don't create multiple Accepts of the same Follow // TODO verify the authenticity of the activity $activity = \util\dereference_object( $activity ); if ( !array_key_exists( 'type', $activity ) ) {