From 3e34f4743b7bf191c59a2e1cb3a015145c48ccd4 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Thu, 13 Sep 2018 16:47:47 -0600 Subject: [PATCH] Strip bto and bcc before delivery/persisting --- inc/deliver.php | 11 +++++++++++ inc/outbox.php | 10 ++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/inc/deliver.php b/inc/deliver.php index 9959118..e1e64b5 100644 --- a/inc/deliver.php +++ b/inc/deliver.php @@ -12,6 +12,7 @@ function deliver_activity( $activity ) { if ( array_key_exists( 'actor', $activity ) ) { $recipients = remove_actor_inbox_from_recipients( $activity['actor'], $recipients ); } + $activity = strip_private_fields( $activity ); post_activity_to_inboxes( $activity, $recipients ); } @@ -83,4 +84,14 @@ function post_activity_to_inboxes( $activity, $recipients ) { wp_remote_post( $inbox, $args ); } } + +function strip_private_fields( $activity ) { + if ( array_key_exists( 'bto', $activity ) ) { + unset( $activity['bto'] ); + } + if ( array_key_exists( 'bcc', $activity ) ) { + unset( $activity['bcc'] ); + } + return $activity; +} ?> diff --git a/inc/outbox.php b/inc/outbox.php index af0719d..a9b66b2 100644 --- a/inc/outbox.php +++ b/inc/outbox.php @@ -81,14 +81,20 @@ function handle_activity( $actor, $activity ) { if ( is_wp_error( $activity ) ) { return $activity; } else { - deliver_activity( $activity ); + $activity = deliver_activity( $activity ); return persist_activity( $actor, $activity ); } } function deliver_activity( $activity ) { - // TODO deliver activity, then strip bto and bcc \deliver\deliver_activity( $activity ); + if ( array_key_exists( 'bto', $activity ) ) { + unset( $activity['bto'] ); + } + if ( array_key_exists( 'bcc', $activity ) ) { + unset( $activity['bcc'] ); + } + return $activity; } function persist_activity( $actor, $activity ) {