Strip bto and bcc before delivery/persisting

This commit is contained in:
Jeremy Dormitzer 2018-09-13 16:47:47 -06:00
parent ea2ad27ba2
commit 3e34f4743b
2 changed files with 19 additions and 2 deletions

View File

@ -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;
}
?>

View File

@ -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 ) {