From: Michael Date: Wed, 24 Oct 2018 19:19:51 +0000 (+0000) Subject: Preparations to work with BCC X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=58f82e084db4c79f22629b6f82fcb858a6fe4b73;p=friendica.git Preparations to work with BCC --- diff --git a/src/Protocol/ActivityPub.php b/src/Protocol/ActivityPub.php index 23eb861721..e6701074c6 100644 --- a/src/Protocol/ActivityPub.php +++ b/src/Protocol/ActivityPub.php @@ -29,6 +29,11 @@ use Friendica\Model\APContact; * * To-do: * - Polling the outboxes for missing content? + * + * Missing parts from DFRN: + * - Public Forum + * - Private Forum + * - Relocation */ class ActivityPub { diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 4341c14a3f..472341d06f 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -37,7 +37,7 @@ class Receiver { const PUBLIC_COLLECTION = 'as:Public'; const ACCOUNT_TYPES = ['as:Person', 'as:Organization', 'as:Service', 'as:Group', 'as:Application']; - const CONTENT_TYPES = ['as:Note', 'as:Article', 'as:Video', 'as:Image']; + const CONTENT_TYPES = ['as:Note', 'as:Article', 'as:Video', 'as:Image', 'as:Event']; const ACTIVITY_TYPES = ['as:Like', 'as:Dislike', 'as:Accept', 'as:Reject', 'as:TentativeAccept']; /** diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index b0e6cd3629..2b6f87e665 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -300,10 +300,11 @@ class Transmitter * Creates an array of permissions from an item thread * * @param array $item + * @param boolean $blindcopy * * @return array with permission data */ - private static function createPermissionBlockForItem($item) + private static function createPermissionBlockForItem($item, $blindcopy) { // Will be activated in a later step // $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]; @@ -398,6 +399,9 @@ class Transmitter } } + if (!$blindcopy) { + } + return ['to' => array_values($data['to']), 'cc' => array_values($data['cc'])]; } @@ -453,7 +457,7 @@ class Transmitter */ public static function fetchTargetInboxes($item, $uid, $personal = false) { - $permissions = self::createPermissionBlockForItem($item); + $permissions = self::createPermissionBlockForItem($item, true); if (empty($permissions)) { return []; } @@ -471,13 +475,15 @@ class Transmitter continue; } + $blindcopy = in_array($element, ['bto', 'bcc']); + foreach ($permissions[$element] as $receiver) { if ($receiver == $item_profile['followers']) { $inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal)); } else { $profile = APContact::getByURL($receiver, false); if (!empty($profile)) { - if (empty($profile['sharedinbox']) || $personal) { + if (empty($profile['sharedinbox']) || $personal || $blindcopy) { $target = $profile['inbox']; } else { $target = $profile['sharedinbox']; @@ -593,7 +599,7 @@ class Transmitter $data['instrument'] = ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()]; - $data = array_merge($data, self::createPermissionBlockForItem($item)); + $data = array_merge($data, self::createPermissionBlockForItem($item, false)); if (in_array($data['type'], ['Create', 'Update', 'Delete'])) { $data['object'] = self::createNote($item); @@ -905,7 +911,7 @@ class Transmitter $data['generator'] = ['type' => 'Application', 'name' => $item['app']]; } - $data = array_merge($data, self::createPermissionBlockForItem($item)); + $data = array_merge($data, self::createPermissionBlockForItem($item, false)); return $data; } diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index 1d2e7d9f76..34fe7a9870 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -406,6 +406,8 @@ class HTTPSignature } } + /// @todo Check if the signed date field is in an acceptable range + // Check the content-length when it is part of the signed data if (in_array('content-length', $sig_block['headers'])) { if (strlen($content) != $headers['content-length']) {