Derefence all the objects
This commit is contained in:
parent
2d5f488e3d
commit
5713d23a9f
@ -3,6 +3,7 @@ namespace pterotype\activities\announce;
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../shares.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
|
||||
function handle_inbox( $actor_slug, $activity ) {
|
||||
if ( !array_key_exists( 'object', $activity ) ) {
|
||||
@ -12,7 +13,7 @@ function handle_inbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_activity',
|
||||
|
@ -3,6 +3,7 @@ namespace pterotype\activities\block;
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . '../blocks.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
|
||||
function handle_outbox( $actor, $activity ) {
|
||||
if ( !array_key_exists( 'object', $activity ) ) {
|
||||
@ -13,7 +14,8 @@ function handle_outbox( $actor, $activity ) {
|
||||
);
|
||||
}
|
||||
$actor_id = \pterotype\actors\get_actor_id( $actor );
|
||||
$res = \pterotype\blocks\create_block( $actor_id, $activity['object'] );
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$res = \pterotype\blocks\create_block( $actor_id, $object );
|
||||
if ( is_wp_error( $res ) ) {
|
||||
return $res;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ function handle_outbox( $actor_slug, $activity ) {
|
||||
'invalid_actor', __( 'Expecting a valid actor', 'pterotype' )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$attributed_actor = $activity['actor'];
|
||||
$object['attributedTo'] = $attributed_actor;
|
||||
reconcile_receivers( $object, $activity );
|
||||
@ -52,7 +52,7 @@ function handle_inbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$object_row = \pterotype\objects\upsert_object( $object );
|
||||
if ( is_wp_error( $object_row ) ) {
|
||||
return $object_row;
|
||||
@ -125,7 +125,7 @@ function link_comment( $object ) {
|
||||
}
|
||||
|
||||
function sync_comments( $activity ) {
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$object_id = \pterotype\objects\get_object_id( $object['id'] );
|
||||
$comment_exists = \pterotype\commentlinks\get_comment_id( $object_id );
|
||||
if ( $comment_exists ) {
|
||||
@ -157,7 +157,7 @@ function sync_comments( $activity ) {
|
||||
link_new_comment( $comment_id, $object_id );
|
||||
return;
|
||||
} else {
|
||||
$parent = $parent_row->object;
|
||||
$parent = \pterotype\util\dereference_object( $parent_row->object );
|
||||
if ( ! array_key_exists( 'url', $parent ) ) {
|
||||
return;
|
||||
}
|
||||
@ -189,6 +189,7 @@ function get_comment_id_from_url( $url ) {
|
||||
}
|
||||
|
||||
function make_comment_from_object( $object, $post_id, $parent_comment_id = null ) {
|
||||
$object = \pterotype\util\dereference_object( $object );
|
||||
$actor = null;
|
||||
if ( array_key_exists( 'attributedTo', $object ) ) {
|
||||
$actor = \pterotype\util\dereference_object( $object['attributedTo'] );
|
||||
|
@ -4,6 +4,7 @@ namespace pterotype\activities\delete;
|
||||
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../commentlinks.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
|
||||
function handle_outbox( $actor, $activity ) {
|
||||
if ( !array_key_exists( 'object', $activity ) ) {
|
||||
@ -13,7 +14,7 @@ function handle_outbox( $actor, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$tombstone = \pterotype\objects\delete_object( $object );
|
||||
if ( is_wp_error( $tombstone ) ) {
|
||||
return $tombstone;
|
||||
@ -37,7 +38,7 @@ function handle_inbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_activity',
|
||||
|
@ -15,7 +15,7 @@ function handle_outbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$object_row = \pterotype\objects\upsert_object( $object );
|
||||
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
|
||||
$res = \pterotype\following\request_follow( $actor_id, $object_row->id );
|
||||
|
@ -4,6 +4,7 @@ namespace pterotype\activities\like;
|
||||
require_once plugin_dir_path( __FILE__ ) . '../likes.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
|
||||
function handle_outbox( $actor, $activity ) {
|
||||
if ( !array_key_exists( 'object', $activity ) ) {
|
||||
@ -13,7 +14,7 @@ function handle_outbox( $actor, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_object',
|
||||
@ -57,7 +58,7 @@ function handle_inbox( $actor, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_object',
|
||||
|
@ -4,6 +4,7 @@ namespace pterotype\activities\reject;
|
||||
require_once plugin_dir_path( __FILE__ ) . '../following.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
|
||||
function handle_inbox( $actor_slug, $activity ) {
|
||||
if ( !array_key_exists( 'object', $activity ) ) {
|
||||
@ -13,7 +14,7 @@ function handle_inbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( array_key_exists( 'type', $object ) ) {
|
||||
switch ( $object['type'] ) {
|
||||
case 'Follow':
|
||||
|
@ -3,6 +3,7 @@ namespace pterotype\activities\update;
|
||||
|
||||
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../commentlinks.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
|
||||
require_once plugin_dir_path( __FILE__ ) . 'create.php';
|
||||
|
||||
function handle_outbox( $actor_slug, $activity ) {
|
||||
@ -20,7 +21,7 @@ function handle_outbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$update_object = $activity['object'];
|
||||
$update_object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $update_object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_object',
|
||||
@ -62,7 +63,7 @@ function handle_inbox( $actor_slug, $activity ) {
|
||||
array( 'status' => 400 )
|
||||
);
|
||||
}
|
||||
$object = $activity['object'];
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
if ( !array_key_exists( 'id', $object ) ) {
|
||||
return new \WP_Error(
|
||||
'invalid_activity',
|
||||
|
@ -21,8 +21,13 @@ function deliver_activity( $actor_slug, $activity ) {
|
||||
$recipients = array_values( array_unique( $recipients ) );
|
||||
if ( array_key_exists( 'actor', $activity ) ) {
|
||||
$actor = \pterotype\util\dereference_object( $activity['actor'] );
|
||||
$activity['actor'] = $actor;
|
||||
$recipients = remove_actor_inbox_from_recipients( $actor, $recipients );
|
||||
}
|
||||
if ( array_key_exists( 'object', $activity ) ) {
|
||||
$object = \pterotype\util\dereference_object( $activity['object'] );
|
||||
$activity['object'] = $object;
|
||||
}
|
||||
$activity = \pterotype\objects\strip_private_fields( $activity );
|
||||
post_activity_to_inboxes( $actor_id, $activity, $recipients );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user