Prefix all namespaces with "pterotype"

This commit is contained in:
Jeremy Dormitzer 2018-10-20 22:34:20 -04:00
parent fc01e6beb2
commit a85bbc7333
29 changed files with 208 additions and 208 deletions

View File

@ -1,5 +1,5 @@
<?php
namespace posts;
namespace pterotype\posts;
require_once plugin_dir_path( __FILE__ ) . '../server/activities/create.php';
@ -12,16 +12,16 @@ function handle_post_status_change( $new_status, $old_status, $post ) {
$activity = null;
if ( $new_status == 'publish' && $old_status != 'publish' ) {
// Create
$activity = \activities\create\make_create( $actor_slug, $post_object );
$activity = \pterotype\activities\create\make_create( $actor_slug, $post_object );
} else if ( $new_status == 'publish' && $old_status == 'publish' ) {
// Update
$activity = \activities\update\make_update( $actor_slug, $post_object );
$activity = \pterotype\activities\update\make_update( $actor_slug, $post_object );
} else if ( $new_status != 'publish' && $old_status == 'publish' ) {
// Delete
$activity = \activities\delete\make_delete( $actor_slug, $post_object );
$activity = \pterotype\activities\delete\make_delete( $actor_slug, $post_object );
}
if ( $activity && ! is_wp_error( $activity ) ) {
$followers = \followers\get_followers_collection( $actor_slug );
$followers = \pterotype\followers\get_followers_collection( $actor_slug );
$activity['to'] = array(
'https://www.w3.org/ns/activitystreams#Public',
$followers['id']

View File

@ -1,5 +1,5 @@
<?php
namespace init;
namespace pterotype\init;
require_once plugin_dir_path( __FILE__ ) . 'util.php';
require_once plugin_dir_path( __FILE__ ) . 'server/api.php';
@ -10,30 +10,30 @@ require_once plugin_dir_path( __FILE__ ) . 'client/posts.php';
require_once plugin_dir_path( __FILE__ ) . 'server/async.php';
add_action( 'rest_api_init', function() {
\api\register_routes();
\pterotype\api\register_routes();
} );
add_action( 'user_register', function( $user_id ) {
$slug = get_the_author_meta( 'user_nicename', $user_id );
\actors\create_actor_user( $slug, 'user' );
\pterotype\actors\create_actor_user( $slug, 'user' );
} );
add_action( 'pterotype_init', function() {
\schema\run_migrations();
\actors\initialize_actors();
\pterotype\schema\run_migrations();
\pterotype\actors\pterotype\initialize_actors();
if ( ! empty( ob_get_contents() ) ) {
\util\log( 'init.log', ob_get_contents(), false );
\pterotype\util\log( 'init.log', ob_get_contents(), false );
}
} );
add_action( 'pterotype_load', function() {
\schema\run_migrations();
\async\init_tasks();
\pterotype\schema\run_migrations();
\pterotype\async\pterotype\init_tasks();
} );
add_action( 'generate_rewrite_rules', '\webfinger\generate_rewrite_rules', 111 );
add_action( 'parse_request', '\webfinger\parse_request', 111 );
add_filter( 'query_vars', '\webfinger\query_vars' );
add_action( 'well_known_webfinger', '\webfinger\handle' );
add_action( 'transition_post_status', '\posts\handle_post_status_change', 10, 3 );
add_action( 'generate_rewrite_rules', '\pterotype\webfinger\generate_rewrite_rules', 111 );
add_action( 'parse_request', '\pterotype\webfinger\parse_request', 111 );
add_filter( 'query_vars', '\pterotype\webfinger\query_vars' );
add_action( 'well_known_webfinger', '\pterotype\webfinger\handle' );
add_action( 'transition_post_status', '\pterotype\posts\handle_post_status_change', 10, 3 );
?>

View File

@ -1,5 +1,5 @@
<?php
namespace pgp;
namespace pterotype\pgp;
function gen_key( $actor_slug ) {
$rsa = new \phpseclib\Crypt\RSA();

View File

@ -1,5 +1,5 @@
<?php
namespace schema;
namespace pterotype\schema;
function get_previous_version() {
$previous_version = get_option( 'pterotype_previously_migrated_version' );

View File

@ -1,5 +1,5 @@
<?php
namespace activities\accept;
namespace pterotype\activities\accept;
require_once plugin_dir_path( __FILE__ ) . '../following.php';
require_once plugin_dir_path( __FILE__ ) . '../followers.php';
@ -15,23 +15,23 @@ function handle_inbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
$object = \util\dereference_object( $activity['object'] );
$object = \pterotype\util\dereference_object( $activity['object'] );
if ( array_key_exists( 'type', $object ) ) {
switch ( $object['type'] ) {
case 'Follow':
if ( !array_key_exists( 'object', $object ) ) {
break;
}
$follow_object = \util\dereference_object( $object['object'] );
$follow_object = \pterotype\util\dereference_object( $object['object'] );
if ( !array_key_exists( 'id', $follow_object ) ) {
break;
}
$object_id = \objects\get_object_by_activitypub_id( $follow_object['id'] );
$object_id = \pterotype\objects\get_object_by_activitypub_id( $follow_object['id'] );
if ( is_wp_error( $object_id ) ) {
break;
}
$actor_id = \actors\get_actor_id( $actor_slug );
\following\accept_follow( $actor_id, $object_id );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
\pterotype\following\accept_follow( $actor_id, $object_id );
break;
default:
break;
@ -48,15 +48,15 @@ function handle_outbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
$object = \util\dereference_object( $activity['object'] );
$object = \pterotype\util\dereference_object( $activity['object'] );
if ( array_key_exists( 'type', $object ) ) {
switch ( $object['type'] ) {
case 'Follow':
if ( !array_key_exists( 'actor', $object ) ) {
break;
}
$follower = \util\dereference_object( $object['actor'] );
\followers\add_follower( $actor_slug, $follower );
$follower = \pterotype\util\dereference_object( $object['actor'] );
\pterotype\followers\add_follower( $actor_slug, $follower );
break;
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace activities\announce;
namespace pterotype\activities\announce;
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
require_once plugin_dir_path( __FILE__ ) . '../shares.php';
@ -20,10 +20,10 @@ function handle_inbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
if ( !\objects\is_local_object( $object ) ) {
if ( !\pterotype\objects\is_local_object( $object ) ) {
return $activity;
}
$object_id = \objects\get_object_id( $object['id'] );
$object_id = \pterotype\objects\get_object_id( $object['id'] );
if ( !$object_id ) {
return new \WP_Error(
'not_found',
@ -39,7 +39,7 @@ function handle_inbox( $actor_slug, $activity ) {
array( 'status' => 404 )
);
}
\shares\add_share( $object_id, $activity_id );
\pterotype\shares\add_share( $object_id, $activity_id );
return $activity;
}
?>

View File

@ -1,5 +1,5 @@
<?php
namespace activities\block;
namespace pterotype\activities\block;
require_once plugin_dir_path( __FILE__ ) . '../blocks.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -12,8 +12,8 @@ function handle_outbox( $actor, $activity ) {
array( 'status' => 400 )
);
}
$actor_id = \actors\get_actor_id( $actor );
$res = \blocks\create_block( $actor_id, $activity['object'] );
$actor_id = \pterotype\actors\get_actor_id( $actor );
$res = \pterotype\blocks\create_block( $actor_id, $activity['object'] );
if ( is_wp_error( $res ) ) {
return $res;
}

View File

@ -1,5 +1,5 @@
<?php
namespace activities\create;
namespace pterotype\activities\create;
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -33,7 +33,7 @@ function handle_outbox( $actor_slug, $activity ) {
$object['attributedTo'] = $attributed_actor;
reconcile_receivers( $object, $activity );
$object = scrub_object( $object );
$object = \objects\create_local_object( $object );
$object = \pterotype\objects\create_local_object( $object );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -50,7 +50,7 @@ function handle_inbox( $actor_slug, $activity ) {
);
}
$object = $activity['object'];
$object_row = \objects\upsert_object( $object );
$object_row = \pterotype\objects\upsert_object( $object );
if ( is_wp_error( $object_row ) ) {
return $object_row;
}
@ -91,7 +91,7 @@ function scrub_object( $object ) {
}
function make_create( $actor_slug, $object ) {
$actor = \actors\get_actor_by_slug( $actor_slug );
$actor = \pterotype\actors\get_actor_by_slug( $actor_slug );
if ( is_wp_error( $actor ) ) {
return $actor;
}

View File

@ -1,5 +1,5 @@
<?php
namespace activities\delete;
namespace pterotype\activities\delete;
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -13,7 +13,7 @@ function handle_outbox( $actor, $activity ) {
);
}
$object = $activity['object'];
$tombstone = \objects\delete_object( $object );
$tombstone = \pterotype\objects\delete_object( $object );
if ( is_wp_error( $tombstone ) ) {
return $tombstone;
}
@ -48,7 +48,7 @@ function handle_inbox( $actor_slug, $activity ) {
if ( is_wp_error( $authorized ) ) {
return $authorized;
}
$res = \objects\delete_object( $object );
$res = \pterotype\objects\delete_object( $object );
if ( is_wp_error( $res ) ) {
return $res;
}
@ -70,7 +70,7 @@ function check_authorization( $activity ) {
}
function make_delete( $actor_slug, $object ) {
$actor = \actors\get_actor_by_slug( $actor_slug );
$actor = \pterotype\actors\get_actor_by_slug( $actor_slug );
if ( is_wp_error( $actor ) ) {
return $actor;
}

View File

@ -1,5 +1,5 @@
<?php
namespace activities\follow;
namespace pterotype\activities\follow;
require_once plugin_dir_path( __FILE__ ) . '../following.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -16,9 +16,9 @@ function handle_outbox( $actor_slug, $activity ) {
);
}
$object = $activity['object'];
$object_row = \objects\upsert_object( $object );
$actor_id = \actors\get_actor_id( $actor_slug );
$res = \following\request_follow( $actor_id, $object_row->id );
$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 );
if ( is_wp_error( $res ) ) {
return $res;
}
@ -37,8 +37,8 @@ function handle_inbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
$follower = \util\dereference_object( $activity['actor'] );
\objects\upsert_object( $follower );
$follower = \pterotype\util\dereference_object( $activity['actor'] );
\pterotype\objects\upsert_object( $follower );
$accept = make_accept( $actor_slug, $activity );
if ( is_wp_error( $accept ) ) {
return $accept;
@ -55,11 +55,11 @@ function actor_is_object( $actor_slug, $activity ) {
if ( !array_key_exists( 'object', $activity ) ) {
return false;
}
$actor = \actors\get_actor_by_slug( $actor_slug );
$actor = \pterotype\actors\get_actor_by_slug( $actor_slug );
if ( is_wp_error( $actor ) ) {
return false;
}
$object = \util\dereference_object( $activity['object'] );
$object = \pterotype\util\dereference_object( $activity['object'] );
if ( !array_key_exists( 'type', $object ) ) {
return false;
}
@ -82,7 +82,7 @@ function make_accept( $actor_slug, $follow ) {
$accept = array(
'@context' => array( 'https://www.w3.org/ns/activitystreams' ),
'type' => 'Accept',
'actor' => \actors\get_actor_by_slug( $actor_slug ),
'actor' => \pterotype\actors\get_actor_by_slug( $actor_slug ),
'object' => $follow,
'to' => $follow['actor'],
);

View File

@ -1,5 +1,5 @@
<?php
namespace activities\like;
namespace pterotype\activities\like;
require_once plugin_dir_path( __FILE__ ) . '../likes.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -21,14 +21,14 @@ function handle_outbox( $actor, $activity ) {
array( 'status' => 400 )
);
}
$object_row = \objects\upsert_object( $object );
$actor_id = \actors\get_actor_id( $actor );
$res = \likes\create_local_actor_like( $actor_id, $object_row->id );
$object_row = \pterotype\objects\upsert_object( $object );
$actor_id = \pterotype\actors\get_actor_id( $actor );
$res = \pterotype\likes\create_local_actor_like( $actor_id, $object_row->id );
if ( is_wp_error( $res ) ) {
return $res;
}
if ( \objects\is_local_object( $object ) ) {
$activity_id = \objects\get_object_id( $activity['id'] );
if ( \pterotype\objects\is_local_object( $object ) ) {
$activity_id = \pterotype\objects\get_object_id( $activity['id'] );
if ( !$activity_id ) {
return new \WP_Error(
'not_found',
@ -37,7 +37,7 @@ function handle_outbox( $actor, $activity ) {
);
}
$object_id = $object_row->id;
\likes\record_like( $object_id, $activity_id );
\pterotype\likes\record_like( $object_id, $activity_id );
}
return $activity;
}
@ -65,8 +65,8 @@ function handle_inbox( $actor, $activity ) {
array( 'status' => 400 )
);
}
if ( \objects\is_local_object( $object ) ) {
$activity_id = \objects\get_object_id( $activity['id'] );
if ( \pterotype\objects\is_local_object( $object ) ) {
$activity_id = \pterotype\objects\get_object_id( $activity['id'] );
if ( !$activity_id ) {
return new \WP_Error(
'not_found',
@ -74,7 +74,7 @@ function handle_inbox( $actor, $activity ) {
array( 'status' => 404 )
);
}
$object_id = \objects\get_object_id( $object['id'] );
$object_id = \pterotype\objects\get_object_id( $object['id'] );
if ( !$object_id ) {
return new \WP_Error(
'not_found',
@ -82,7 +82,7 @@ function handle_inbox( $actor, $activity ) {
array( 'status' => 404 )
);
}
\likes\record_like( $object_id, $activity_id );
\pterotype\likes\record_like( $object_id, $activity_id );
}
return $activity;
}

View File

@ -1,5 +1,5 @@
<?php
namespace activities\reject;
namespace pterotype\activities\reject;
require_once plugin_dir_path( __FILE__ ) . '../following.php';
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
@ -24,12 +24,12 @@ function handle_inbox( $actor_slug, $activity ) {
if ( !array_key_exists( 'id', $follow_object ) ) {
break;
}
$object_id = \objects\get_object_by_activitypub_id( $follow_object['id'] );
$object_id = \pterotype\objects\get_object_by_activitypub_id( $follow_object['id'] );
if ( is_wp_error( $object_id ) ) {
break;
}
$actor_id = \actors\get_actor_id( $actor_slug );
\following\reject_follow( $actor_id, $object_id );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
\pterotype\following\reject_follow( $actor_id, $object_id );
break;
default:
break;

View File

@ -1,5 +1,5 @@
<?php
namespace activities\undo;
namespace pterotype\activities\undo;
require_once plugin_dir_path( __FILE__ ) . '../../util.php';
require_once plugin_dir_path( __FILE__ ) . '../actors.php';
@ -13,7 +13,7 @@ function handle_outbox( $actor_slug, $activity ) {
if ( is_wp_error( $object ) ) {
return $object;
}
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -30,30 +30,30 @@ function handle_outbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
$liked_object_url = \util\get_id( $object['object'] );
$liked_object_url = \pterotype\util\get_id( $object['object'] );
if ( !$liked_object_url ) {
break;
}
$liked_object_id = \objects\get_object_id( $liked_object_url );
$liked_object_id = \pterotype\objects\get_object_id( $liked_object_url );
if ( !$liked_object_id ) {
break;
}
\likes\delete_local_actor_like( $actor_id, $liked_object_id );
$like_id = \objects\get_object_id( $object['id'] );
\pterotype\likes\delete_local_actor_like( $actor_id, $liked_object_id );
$like_id = \pterotype\objects\get_object_id( $object['id'] );
if ( !$like_id ) {
break;
}
\likes\delete_object_like( $liked_object_id, $like_id );
\pterotype\likes\delete_object_like( $liked_object_id, $like_id );
break;
case 'Block':
if ( !array_key_exists( 'object', $object ) ) {
break;
}
$blocked_object_url = \util\get_id( $object['object'] );
$blocked_object_url = \pterotype\util\get_id( $object['object'] );
if ( !$blocked_object_url ) {
break;
}
$res = \blocks\delete_block( $actor_id, $blocked_object_url );
$res = \pterotype\blocks\delete_block( $actor_id, $blocked_object_url );
if ( is_wp_error( $res ) ) {
return $res;
}
@ -62,15 +62,15 @@ function handle_outbox( $actor_slug, $activity ) {
if ( !array_key_exists( 'object', $object ) ) {
break;
}
$follow_object_url = \util\get_id( $object['object'] );
$follow_object_url = \pterotype\util\get_id( $object['object'] );
if ( !$follow_object_url ) {
break;
}
$follow_object_id = \objects\get_object_id( $follow_object_url );
$follow_object_id = \pterotype\objects\get_object_id( $follow_object_url );
if ( !$follow_object_id ) {
break;
}
\following\reject_follow( $actor_id, $follow_object_id );
\pterotype\following\reject_follow( $actor_id, $follow_object_id );
break;
// TODO I should support Undoing these as well
case 'Add':
@ -88,7 +88,7 @@ function handle_inbox( $actor_slug, $activity ) {
if ( is_wp_error( $object ) ) {
return $object;
}
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -101,17 +101,17 @@ function handle_inbox( $actor_slug, $activity ) {
if ( !array_key_exists( 'object', $object ) ) {
break;
}
if ( \objects\is_local_object( $object['object'] ) ) {
$object_url = \objects\get_object_id( $object['object'] );
if ( \pterotype\objects\is_local_object( $object['object'] ) ) {
$object_url = \pterotype\objects\get_object_id( $object['object'] );
if ( !$object_url ) {
break;
}
$object_id = \objects\get_object_id( $object_url );
$like_id = \objects\get_object_id( $object['id'] );
$object_id = \pterotype\objects\get_object_id( $object_url );
$like_id = \pterotype\objects\get_object_id( $object['id'] );
if ( !$like_id ) {
break;
}
\likes\delete_object_like( $object_id, $like_id );
\pterotype\likes\delete_object_like( $object_id, $like_id );
}
break;
case 'Follow':
@ -119,13 +119,13 @@ function handle_inbox( $actor_slug, $activity ) {
break;
}
$follower = $object['actor'];
\followers\remove_follower( $actor_slug, $follower );
\pterotype\followers\remove_follower( $actor_slug, $follower );
break;
case 'Accept':
if ( !array_key_exists( 'object', $object ) ) {
break;
}
$accept_object = \util\dereference_object( $object['object'] );
$accept_object = \pterotype\util\dereference_object( $object['object'] );
if ( is_wp_error( $object ) ) {
break;
}
@ -133,13 +133,13 @@ function handle_inbox( $actor_slug, $activity ) {
if ( !array_key_exists( 'object', $accept_object ) ) {
break;
}
$followed_object_url = \util\get_id( $accept_object['object'] );
$followed_object_id = \objects\get_object_id( $followed_object_url );
$followed_object_url = \pterotype\util\get_id( $accept_object['object'] );
$followed_object_id = \pterotype\objects\get_object_id( $followed_object_url );
if ( !$followed_object_id ) {
break;
}
// Put the follow request back into the PENDING state
\following\request_follow( $actor_id, $followed_object_id );
\pterotype\following\request_follow( $actor_id, $followed_object_id );
}
break;
default:
@ -163,7 +163,7 @@ function validate_undo( $activity ) {
array( 'status' => 400 )
);
}
$object = \util\dereference_object( $activity['object'] );
$object = \pterotype\util\dereference_object( $activity['object'] );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -181,7 +181,7 @@ function validate_undo( $activity ) {
array( 'status' => 400 )
);
}
if ( !\util\is_same_object( $activity['actor'], $object['actor'] ) ) {
if ( !\pterotype\util\is_same_object( $activity['actor'], $object['actor'] ) ) {
return new \WP_Error(
'unauthorized',
__( 'Unauthorzed Undo activity', 'pterotype' ),

View File

@ -1,5 +1,5 @@
<?php
namespace activities\update;
namespace pterotype\activities\update;
require_once plugin_dir_path( __FILE__ ) . '../objects.php';
@ -26,12 +26,12 @@ function handle_outbox( $actor_slug, $activity ) {
array( 'status' => 400 )
);
}
$existing_object = \objects\get_object_by_activitypub_id( $update_object['id'] );
$existing_object = \pterotype\objects\get_object_by_activitypub_id( $update_object['id'] );
if ( is_wp_error( $existing_object ) ) {
return $existing_object;
}
$updated_object = array_merge( $existing_object, $update_object );
$updated_object = \objects\update_object( $updated_object );
$updated_object = \pterotype\objects\update_object( $updated_object );
if ( is_wp_error( $updated_object ) ) {
return $updated_object;
}
@ -72,7 +72,7 @@ function handle_inbox( $actor_slug, $activity ) {
if ( is_wp_error( $authorized ) ) {
return $authorized;
}
$object_row = \objects\upsert_object( $object );
$object_row = \pterotype\objects\upsert_object( $object );
if ( is_wp_error( $object_row ) ) {
return $object_row;
}
@ -94,7 +94,7 @@ function check_authorization( $activity ) {
}
function make_update( $actor_slug, $object ) {
$actor = \actors\get_actor_by_slug( $actor_slug );
$actor = \pterotype\actors\get_actor_by_slug( $actor_slug );
if ( is_wp_error( $actor ) ) {
return $actor;
}

View File

@ -1,5 +1,5 @@
<?php
namespace actors;
namespace pterotype\actors;
require_once plugin_dir_path( __FILE__ ) . '../pgp.php';
@ -83,7 +83,7 @@ function get_blog_actor() {
'owner' => get_rest_url(
null, sprintf( '/pterotype/v1/actor/%s', PTEROTYPE_BLOG_ACTOR_SLUG )
),
'publicKeyPem' => \pgp\get_public_key( $actor_id ),
'publicKeyPem' => \pterotype\pgp\get_public_key( $actor_id ),
),
);
if ( has_custom_logo() ) {
@ -124,7 +124,7 @@ function get_user_actor( $user ) {
'owner' => get_rest_url(
null, sprintf( '/pterotype/v1/actor/%s', $handle )
),
'publicKeyPem' => \pgp\get_public_key( $actor_id ),
'publicKeyPem' => \pterotype\pgp\get_public_key( $actor_id ),
),
);
return $actor;
@ -138,18 +138,18 @@ function initialize_actors() {
foreach ( $user_slugs as $user_slug ) {
create_actor( $user_slug, 'user' );
$actor_id = get_actor_id( $user_slug );
$keys_created = \pgp\get_public_key( $actor_id );
$keys_created = \pterotype\pgp\get_public_key( $actor_id );
if ( ! $keys_created ) {
$keys = \pgp\gen_key( $user_slug );
\pgp\persist_key( $actor_id, $keys['publickey'], $keys['privatekey'] );
$keys = \pterotype\pgp\gen_key( $user_slug );
\pterotype\pgp\persist_key( $actor_id, $keys['publickey'], $keys['privatekey'] );
}
}
create_actor( PTEROTYPE_BLOG_ACTOR_SLUG, 'blog' );
$blog_actor_id = get_actor_id( PTEROTYPE_BLOG_ACTOR_SLUG );
$keys_created = \pgp\get_public_key( $blog_actor_id );
$keys_created = \pterotype\pgp\get_public_key( $blog_actor_id );
if ( ! $keys_created ) {
$keys = \pgp\gen_key( PTEROTYPE_BLOG_ACTOR_SLUG );
\pgp\persist_key( $blog_actor_id, $keys['publickey'], $keys['privatekey'] );
$keys = \pterotype\pgp\gen_key( PTEROTYPE_BLOG_ACTOR_SLUG );
\pterotype\pgp\persist_key( $blog_actor_id, $keys['publickey'], $keys['privatekey'] );
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace api;
namespace pterotype\api;
require_once plugin_dir_path( __FILE__ ) . 'actors.php';
require_once plugin_dir_path( __FILE__ ) . 'outbox.php';
@ -11,54 +11,54 @@ require_once plugin_dir_path( __FILE__ ) . 'shares.php';
function get_actor( $request ) {
$actor = $request->get_url_params()['actor'];
return \actors\get_actor_by_slug( $actor );
return \pterotype\actors\get_actor_by_slug( $actor );
}
function post_to_outbox( $request ) {
$actor_slug = $request->get_url_params()['actor'];
$activity = json_decode( $request->get_body(), true );
return \outbox\handle_activity( $actor_slug, $activity );
return \pterotype\outbox\handle_activity( $actor_slug, $activity );
}
function get_outbox( $request ) {
$actor_slug = $request->get_url_params()['actor'];
return \outbox\get_outbox( $actor_slug );
return \pterotype\outbox\get_outbox( $actor_slug );
}
function post_to_inbox( $request ) {
$actor_slug = $request->get_url_params()['actor'];
$activity = json_decode( $request->get_body(), true );
return \inbox\handle_activity( $actor_slug, $activity );
return \pterotype\inbox\handle_activity( $actor_slug, $activity );
}
function get_inbox( $request ) {
$actor_slug = $request->get_url_params()['actor'];
return \inbox\get_inbox( $actor_slug );
return \pterotype\inbox\get_inbox( $actor_slug );
}
function get_object( $request ) {
$id = $request->get_url_params()['id'];
return \objects\get_object( $id );
return \pterotype\objects\get_object( $id );
}
function get_following( $request ) {
$actor_slug = $request->get_url_params()['actor'];
return \following\get_following_collection( $actor_slug );
return \pterotype\following\get_following_collection( $actor_slug );
}
function get_followers( $request ) {
$actor_slug = $request->get_url_params()['actor'];
return \followers\get_followers_collection( $actor_slug );
return \pterotype\followers\get_followers_collection( $actor_slug );
}
function get_likes( $request ) {
$object_id = $request->get_url_params()['object'];
return \likes\get_likes_collection( $object_id );
return \pterotype\likes\get_likes_collection( $object_id );
}
function get_shares( $request ) {
$object_id = $request->get_url_params()['object'];
return \shares\get_shares_collection( $object_id );
return \pterotype\shares\get_shares_collection( $object_id );
}
function user_can_post_to_outbox() {

View File

@ -1,5 +1,5 @@
<?php
namespace async;
namespace pterotype\async;
require_once plugin_dir_path( __FILE__ ) . 'outbox.php';
@ -17,7 +17,7 @@ class Send_Accept_Task extends \WP_Async_Task {
$accept = $_POST['accept'];
if ( $actor_slug && $accept ) {
sleep( 5 );
\outbox\handle_activity( $actor_slug, $accept );
\pterotype\outbox\handle_activity( $actor_slug, $accept );
}
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace blocks;
namespace pterotype\blocks;
/*
If an actor is in another actor's block list, any activities

View File

@ -1,5 +1,5 @@
<?php
namespace collections;
namespace pterotype\collections;
function make_ordered_collection( $objects ) {
$ordered_collection = array(

View File

@ -1,5 +1,5 @@
<?php
namespace deliver;
namespace pterotype\deliver;
require_once plugin_dir_path( __FILE__ ) . 'actors.php';
require_once plugin_dir_path( __FILE__ ) . '../pgp.php';
@ -10,8 +10,8 @@ require_once plugin_dir_path( __FILE__ ) . '../util.php';
// objects up to some limit
function deliver_activity( $actor_slug, $activity ) {
$actor_id = \actors\get_actor_id( $actor_slug );
$activity = \util\dereference_object( $activity );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
$activity = \pterotype\util\dereference_object( $activity );
$recipients = array();
foreach ( array( 'to', 'bto', 'cc', 'bcc', 'audience' ) as $field ) {
$recipients = array_merge(
@ -20,10 +20,10 @@ function deliver_activity( $actor_slug, $activity ) {
}
$recipients = array_unique( $recipients );
if ( array_key_exists( 'actor', $activity ) ) {
$actor = \util\dereference_object( $activity['actor'] );
$actor = \pterotype\util\dereference_object( $activity['actor'] );
$recipients = remove_actor_inbox_from_recipients( $actor, $recipients );
}
$activity = \objects\strip_private_fields( $activity );
$activity = \pterotype\objects\strip_private_fields( $activity );
post_activity_to_inboxes( $actor_id, $activity, $recipients );
}
@ -78,7 +78,7 @@ function get_recipient_urls( $object, $depth, $acc ) {
return $recipients;
case 'Link':
if ( array_key_exists( 'href', $object ) ) {
$response = \util\get_object_from_url( $object['href'] );
$response = \pterotype\util\get_object_from_url( $object['href'] );
if ( is_wp_error( $response ) ) {
return array();
}
@ -107,7 +107,7 @@ function get_recipient_urls( $object, $depth, $acc ) {
return $recipients;
} else {
if ( filter_var( $object, FILTER_VALIDATE_URL ) ) {
$response = \util\get_object_from_url( $object );
$response = \pterotype\util\get_object_from_url( $object );
if ( is_wp_error( $response ) ) {
return array();
}
@ -125,7 +125,7 @@ function post_activity_to_inboxes( $actor_id, $activity, $recipients ) {
continue;
}
$date_str = get_now_date();
if ( \util\is_local_url( $inbox ) ) {
if ( \pterotype\util\is_local_url( $inbox ) ) {
$request = \WP_REST_Request::from_url( $inbox );
$request->set_method('POST');
$request->set_body( $activity );
@ -144,12 +144,12 @@ function post_activity_to_inboxes( $actor_id, $activity, $recipients ) {
),
'data_format' => 'body',
);
\util\log( 'debug.html', 'Request:' );
\util\log( 'debug.html', "POST $inbox" );
\util\log_var( 'debug.html', $args );
\pterotype\util\log( 'debug.html', 'Request:' );
\pterotype\util\log( 'debug.html', "POST $inbox" );
\pterotype\util\log_var( 'debug.html', $args );
$response = wp_remote_post( $inbox, $args );
\util\log( 'debug.html', 'Response:' );
\util\log_var( 'debug.html', $response );
\pterotype\util\log( 'debug.html', 'Response:' );
\pterotype\util\log_var( 'debug.html', $response );
}
}
}
@ -169,11 +169,11 @@ function get_signing_string( $inbox_url, $date_str ) {
}
function signature_header( $inbox_url, $actor_id, $date_str ) {
$actor = \actors\get_actor( $actor_id );
$actor = \pterotype\actors\get_actor( $actor_id );
$key_id = $actor['publicKey']['id'];
$signing_string = get_signing_string( $inbox_url, $date_str );
\util\log_var( 'debug.html', $signing_string, false );
$signature = \pgp\sign_data( $signing_string, $actor_id );
\pterotype\util\log_var( 'debug.html', $signing_string, false );
$signature = \pterotype\pgp\sign_data( $signing_string, $actor_id );
$headers = '(request-target) host date';
return "keyId=\"$key_id\",headers=\"$headers\",signature=\"$signature\"";
}

View File

@ -1,5 +1,5 @@
<?php
namespace followers;
namespace pterotype\followers;
require_once plugin_dir_path( __FILE__ ) . 'actors.php';
require_once plugin_dir_path( __FILE__ ) . 'objects.php';
@ -7,7 +7,7 @@ require_once plugin_dir_path( __FILE__ ) . '../util.php';
function add_follower( $actor_slug, $follower ) {
global $wpdb;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -15,7 +15,7 @@ function add_follower( $actor_slug, $follower ) {
array( 'status' => 404 )
);
}
$follower = \util\dereference_object( $follower );
$follower = \pterotype\util\dereference_object( $follower );
if ( !array_key_exists( 'id', $follower ) ) {
return new \WP_Error(
'invalid_object',
@ -23,9 +23,9 @@ function add_follower( $actor_slug, $follower ) {
array( 'status' => 400 )
);
}
$object_id = \objects\get_object_id( $follower['id'] );
$object_id = \pterotype\objects\get_object_id( $follower['id'] );
if ( !$object_id ) {
$row = \objects\upsert_object( $follower );
$row = \pterotype\objects\upsert_object( $follower );
$object_id = $row->id;
}
return $wpdb->query( $wpdb->prepare(
@ -36,7 +36,7 @@ function add_follower( $actor_slug, $follower ) {
function remove_follower( $actor_slug, $follower ) {
global $wpdb;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -44,7 +44,7 @@ function remove_follower( $actor_slug, $follower ) {
array( 'status' => 404 )
);
}
$follower = \util\dereference_object( $follower );
$follower = \pterotype\util\dereference_object( $follower );
if ( !array_key_exists( 'id', $follower ) ) {
return new \WP_Error(
'invalid_object',
@ -52,7 +52,7 @@ function remove_follower( $actor_slug, $follower ) {
array( 'status' => 400 )
);
}
$object_id = \objects\get_object_id( $follower['id'] );
$object_id = \pterotype\objects\get_object_id( $follower['id'] );
if ( !$object_id ) {
return new \WP_Error(
'not_found',
@ -71,7 +71,7 @@ function remove_follower( $actor_slug, $follower ) {
function get_followers_collection( $actor_slug ) {
global $wpdb;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -94,7 +94,7 @@ function get_followers_collection( $actor_slug ) {
if ( !$followers ) {
$followers = array();
}
$collection = \collections\make_ordered_collection( array_map(
$collection = \pterotype\collections\make_ordered_collection( array_map(
function ( $result ) {
return json_decode( $result['object'], true );
},

View File

@ -1,5 +1,5 @@
<?php
namespace following;
namespace pterotype\following;
require_once plugin_dir_path( __FILE__ ) . 'collections.php';
@ -40,7 +40,7 @@ function reject_follow( $actor_id, $object_id ) {
function get_following_collection( $actor_slug ) {
global $wpdb;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found', __( 'Actor not found', 'pterotype' ), array( 'status' => 404 )
@ -62,7 +62,7 @@ function get_following_collection( $actor_slug ) {
if ( !$objects ) {
$objects = array();
}
$collection = \collections\make_ordered_collection( array_map(
$collection = \pterotype\collections\make_ordered_collection( array_map(
function( $result ) {
return json_decode( $result['object'], true );
},

View File

@ -7,7 +7,7 @@ When an Activity is received (i.e. POSTed) to an Actor's inbox, the server must:
2. Perform the side effects of receiving the Activity
3. Persist the activity in the actor's inbox (and the attached object, if necessary)
*/
namespace inbox;
namespace pterotype\inbox;
require_once plugin_dir_path( __FILE__ ) . 'objects.php';
require_once plugin_dir_path( __FILE__ ) . 'deliver.php';
@ -28,7 +28,7 @@ function handle_activity( $actor_slug, $activity ) {
// 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 );
$activity = \pterotype\util\dereference_object( $activity );
if ( !array_key_exists( 'type', $activity ) ) {
return new \WP_Error(
'invalid_activity',
@ -43,28 +43,28 @@ function handle_activity( $actor_slug, $activity ) {
}
switch ( $activity['type'] ) {
case 'Create':
$activity = \activities\create\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\create\handle_inbox( $actor_slug, $activity );
break;
case 'Update':
$activity = \activities\update\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\update\handle_inbox( $actor_slug, $activity );
break;
case 'Delete':
$activity = \activities\delete\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\delete\handle_inbox( $actor_slug, $activity );
break;
case 'Follow':
$activity = \activities\follow\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\follow\handle_inbox( $actor_slug, $activity );
break;
case 'Accept':
$activity = \activities\accept\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\accept\handle_inbox( $actor_slug, $activity );
break;
case 'Reject':
$activity = \activities\reject\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\reject\handle_inbox( $actor_slug, $activity );
break;
case 'Announce':
$activity = \activities\announce\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\announce\handle_inbox( $actor_slug, $activity );
break;
case 'Undo':
$activity = \activities\undo\handle_inbox( $actor_slug, $activity );
$activity = \pterotype\activities\undo\handle_inbox( $actor_slug, $activity );
break;
}
if ( is_wp_error( $activity ) ) {
@ -78,7 +78,7 @@ function forward_activity( $actor_slug, $activity ) {
if ( !array_key_exists( 'id', $activity ) ) {
return;
}
$seen_before = \objects\get_object_id( $activity['id'] );
$seen_before = \pterotype\objects\get_object_id( $activity['id'] );
if ( $seen_before ) {
return;
}
@ -92,14 +92,14 @@ function forward_activity( $actor_slug, $activity ) {
if ( count( $collections ) === 0 ) {
return;
}
\deliver\deliver_activity( $actor_slug, $activity );
\pterotype\deliver\pterotype\deliver_activity( $actor_slug, $activity );
}
function references_local_object( $object, $depth ) {
if ( $depth === 12 ) {
return false;
}
if ( \objects\is_local_object( $object ) ) {
if ( \pterotype\objects\is_local_object( $object ) ) {
return true;
}
$fields = array_intersect_key(
@ -114,11 +114,11 @@ function references_local_object( $object, $depth ) {
if ( $result ) {
return $result;
}
$dereferenced = \util\dereference_object( $field_value );
$dereferenced = \pterotype\util\dereference_object( $field_value );
if ( is_wp_error( $dereferenced ) ) {
return false;
} else {
return \objects\is_local_object( $dereferenced );
return \pterotype\objects\is_local_object( $dereferenced );
}
}
return false;
@ -126,19 +126,19 @@ function references_local_object( $object, $depth ) {
function persist_activity( $actor_slug, $activity ) {
global $wpdb;
$row = \objects\upsert_object( $activity );
$row = \pterotype\objects\upsert_object( $activity );
if ( is_wp_error( $row ) ) {
return $row;
}
$activity = $row->object;
$activity_id = \objects\get_object_id( $activity['id'] );
$activity_id = \pterotype\objects\get_object_id( $activity['id'] );
if ( !$activity_id ) {
return new \WP_Error(
'db_error',
__( 'Error retrieving activity id', 'pterotype' )
);
}
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
$seen_before = $wpdb->get_row( $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}pterotype_inbox
WHERE actor_id = %d AND object_id = %d",
@ -167,7 +167,7 @@ function persist_activity( $actor_slug, $activity ) {
function get_inbox( $actor_slug ) {
global $wpdb;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -187,7 +187,7 @@ function get_inbox( $actor_slug ) {
",
$actor_id
), ARRAY_A );
return \collections\make_ordered_collection( array_map(
return \pterotype\collections\make_ordered_collection( array_map(
function ( $result ) {
return json_decode( $result['object'], true );
},

View File

@ -1,5 +1,5 @@
<?php
namespace likes;
namespace pterotype\likes;
require_once plugin_dir_path( __FILE__ ) . 'collections.php';
@ -62,7 +62,7 @@ function get_likes_collection( $object_id ) {
if ( !$likes ) {
$likes = array();
}
$collection = \collections\make_ordered_collection( $likes );
$collection = \pterotype\collections\make_ordered_collection( $likes );
$collection['id'] = get_rest_url( null, sprintf(
'/pterotype/v1/object/%d/likes', $object_id
) );

View File

@ -1,5 +1,5 @@
<?php
namespace objects;
namespace pterotype\objects;
require_once plugin_dir_path( __FILE__ ) . '../util.php';
@ -8,7 +8,7 @@ require_once plugin_dir_path( __FILE__ ) . '../util.php';
function create_local_object( $object ) {
global $wpdb;
$object = \util\dereference_object( $object );
$object = \pterotype\util\dereference_object( $object );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -58,7 +58,7 @@ function create_local_object( $object ) {
function upsert_object( $object ) {
global $wpdb;
$object = \util\dereference_object( $object );
$object = \pterotype\util\dereference_object( $object );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -120,7 +120,7 @@ function upsert_object( $object ) {
function update_object( $object ) {
global $wpdb;
$object = \util\dereference_object( $object );
$object = \pterotype\util\dereference_object( $object );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -207,7 +207,7 @@ function get_object_id( $activitypub_id ) {
function delete_object( $object ) {
global $wpdb;
$object = \util\dereference_object( $object );
$object = \pterotype\util\dereference_object( $object );
if ( is_wp_error( $object ) ) {
return $object;
}
@ -256,11 +256,11 @@ function make_tombstone( $object ) {
}
function is_local_object( $object ) {
$url = \util\get_id( $object );
$url = \pterotype\util\get_id( $object );
if ( !$url ) {
return false;
}
return \util\is_local_url( $url );
return \pterotype\util\is_local_url( $url );
}
function strip_private_fields( $object ) {

View File

@ -10,7 +10,7 @@ When an Activity is received (i.e. POSTed) to an Actor's outbox, the server must
target inbox.
3. Perform side effects as necessary
*/
namespace outbox;
namespace pterotype\outbox;
require_once plugin_dir_path( __FILE__ ) . 'actors.php';
require_once plugin_dir_path( __FILE__ ) . 'deliver.php';
@ -24,11 +24,11 @@ require_once plugin_dir_path( __FILE__ ) . 'activities/undo.php';
require_once plugin_dir_path( __FILE__ ) . '../util.php';
function handle_activity( $actor_slug, $activity ) {
\util\log( 'outbox.html', 'Got outbox request', false );
\util\log_var( 'outbox.html', $actor_slug );
\util\log_var( 'outbox.html', $activity );
\pterotype\util\log( 'outbox.html', 'Got outbox request', false );
\pterotype\util\log_var( 'outbox.html', $actor_slug );
\pterotype\util\log_var( 'outbox.html', $activity );
// TODO handle authentication/authorization
$activity = \util\dereference_object( $activity );
$activity = \pterotype\util\dereference_object( $activity );
if ( is_wp_error( $activity ) ) {
return $activity;
}
@ -45,16 +45,16 @@ function handle_activity( $actor_slug, $activity ) {
}
switch ( $activity['type'] ) {
case 'Create':
$activity = \activities\create\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\create\handle_outbox( $actor_slug, $activity );
break;
case 'Update':
$activity = \activities\update\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\update\handle_outbox( $actor_slug, $activity );
break;
case 'Delete':
$activity = \activities\delete\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\delete\handle_outbox( $actor_slug, $activity );
break;
case 'Follow':
$activity = \activities\follow\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\follow\handle_outbox( $actor_slug, $activity );
break;
case 'Add':
return new \WP_Error(
@ -71,16 +71,16 @@ function handle_activity( $actor_slug, $activity ) {
);
break;
case 'Like':
$activity = \activities\like\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\like\handle_outbox( $actor_slug, $activity );
break;
case 'Block':
$activity = \activities\block\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\block\handle_outbox( $actor_slug, $activity );
break;
case 'Undo':
$activity = \activities\undo\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\undo\handle_outbox( $actor_slug, $activity );
break;
case 'Accept':
$activity = \activities\accept\handle_outbox( $actor_slug, $activity );
$activity = \pterotype\activities\accept\handle_outbox( $actor_slug, $activity );
break;
// For the other activities, just persist and deliver
case 'Reject':
@ -108,14 +108,14 @@ function handle_activity( $actor_slug, $activity ) {
if ( is_wp_error( $create_activity ) ) {
return $create_activity;
}
$activity = \activities\create\handle_outbox( $actor_slug, $create_activity );
$activity = \pterotype\activities\create\handle_outbox( $actor_slug, $create_activity );
break;
}
if ( is_wp_error( $activity ) ) {
return $activity;
}
// the activity may have changed while processing side effects, so persist the new version
$row = \objects\upsert_object( $activity );
$row = \pterotype\objects\upsert_object( $activity );
if ( is_wp_error( $row) ) {
return $row;
}
@ -131,7 +131,7 @@ function handle_activity( $actor_slug, $activity ) {
function get_outbox( $actor_slug ) {
global $wpdb;
// TODO what sort of joins should these be?
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
if ( !$actor_id ) {
return new \WP_Error(
'not_found',
@ -152,7 +152,7 @@ function get_outbox( $actor_slug ) {
$actor_id
), ARRAY_A );
// TODO return PagedCollection if $activites is too big
return \collections\make_ordered_collection( array_map(
return \pterotype\collections\make_ordered_collection( array_map(
function ( $result) {
return json_decode( $result['object'], true);
},
@ -161,17 +161,17 @@ function get_outbox( $actor_slug ) {
}
function deliver_activity( $actor_slug, $activity ) {
\deliver\deliver_activity( $actor_slug, $activity );
$activity = \objects\strip_private_fields( $activity );
\pterotype\deliver\pterotype\deliver_activity( $actor_slug, $activity );
$activity = \pterotype\objects\strip_private_fields( $activity );
return $activity;
}
function persist_activity( $actor_slug, $activity ) {
global $wpdb;
$activity = \objects\strip_private_fields( $activity );
$activity = \objects\create_local_object( $activity );
$activity = \pterotype\objects\strip_private_fields( $activity );
$activity = \pterotype\objects\create_local_object( $activity );
$activity_id = $wpdb->insert_id;
$actor_id = \actors\get_actor_id( $actor_slug );
$actor_id = \pterotype\actors\get_actor_id( $actor_slug );
$res = $wpdb->insert( $wpdb->prefix . 'pterotype_outbox', array(
'actor_id' => $actor_id,
'object_id' => $activity_id,
@ -186,6 +186,6 @@ function persist_activity( $actor_slug, $activity ) {
}
function wrap_object_in_create( $actor_slug, $object ) {
return \activities\create\make_create( $actor_slug, $object );
return \pterotype\activities\create\make_create( $actor_slug, $object );
}
?>

View File

@ -1,5 +1,5 @@
<?php
namespace shares;
namespace pterotype\shares;
require_once plugin_dir_path( __FILE__ ) . 'collections.php';
@ -32,7 +32,7 @@ function get_shares_collection( $object_id ) {
if ( !$shares ) {
$shares = array();
}
$collection = \collections\make_ordered_collection( $shares );
$collection = \pterotype\collections\make_ordered_collection( $shares );
$collection['id'] = get_rest_url( null, sprintf(
'/pterotype/v1/object/%d/shares', $object_id
) );

View File

@ -1,5 +1,5 @@
<?php
namespace webfinger;
namespace pterotype\webfinger;
require_once plugin_dir_path( __FILE__ ) . 'actors.php';
@ -54,7 +54,7 @@ function handle( $query ) {
}
function get_webfinger_json( $resource, $actor_slug ) {
$actor = \actors\get_actor_by_slug( $actor_slug );
$actor = \pterotype\actors\get_actor_by_slug( $actor_slug );
if ( is_wp_error( $actor ) ) {
header( 'HTTP/1.1 404 Not Found', true, 404 );
echo __( 'Resource not found', 'pterotype' );

View File

@ -1,5 +1,5 @@
<?php
namespace util;
namespace pterotype\util;
function dereference_object( $object ) {
return dereference_object_helper( $object, 0 );