From 95bc5557f8e6ad7439177b26af7e0f77c5c783a2 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Sun, 9 Sep 2018 18:48:14 -0600 Subject: [PATCH] [WIP] Begin to implement delivery --- inc/deliver.php | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ inc/outbox.php | 4 ++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 inc/deliver.php diff --git a/inc/deliver.php b/inc/deliver.php new file mode 100644 index 0000000..523f6f5 --- /dev/null +++ b/inc/deliver.php @@ -0,0 +1,82 @@ + 0 ) { + // recursive case: call retrieve_recipients on each $item + // merge the results and return them + foreach ( $items as $item ) { + // TODO what will $item look like? Could be an actor JSON, or just a URL? + $recipients[] = retrieve_recipients( $item ); + } + } + return $recipients; + default: // an actor + if ( array_key_exists( 'inbox', $response_body ) ) { + return array( $response_body['inbox'] ); + } + return array(); + } +} + +function post_activity_to_inboxes( $activity, $recipients ) { + foreach ( $inbox as $recipients ) { + // TODO + wp_remote_post(); + } +} +?> diff --git a/inc/outbox.php b/inc/outbox.php index 39f895d..af0719d 100644 --- a/inc/outbox.php +++ b/inc/outbox.php @@ -13,6 +13,7 @@ When an Activity is received (i.e. POSTed) to an Actor's outbox, the server must namespace outbox; require_once plugin_dir_path( __FILE__ ) . '/activities.php'; +require_once plugin_dir_path( __FILE__ ) . '/deliver.php'; require_once plugin_dir_path( __FILE__ ) . '/activities/create.php'; require_once plugin_dir_path( __FILE__ ) . '/activities/update.php'; require_once plugin_dir_path( __FILE__ ) . '/activities/delete.php'; @@ -86,7 +87,8 @@ function handle_activity( $actor, $activity ) { } function deliver_activity( $activity ) { - // TODO + // TODO deliver activity, then strip bto and bcc + \deliver\deliver_activity( $activity ); } function persist_activity( $actor, $activity ) {