]> git.mxchange.org Git - friendica.git/commitdiff
Preparations to work with BCC
authorMichael <heluecht@pirati.ca>
Wed, 24 Oct 2018 19:19:51 +0000 (19:19 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 24 Oct 2018 19:19:51 +0000 (19:19 +0000)
src/Protocol/ActivityPub.php
src/Protocol/ActivityPub/Receiver.php
src/Protocol/ActivityPub/Transmitter.php
src/Util/HTTPSignature.php

index 23eb861721279a4a66a454306696d7b0c0342ddc..e6701074c65e2a8f4ed94ba20a9b93a83a344ae2 100644 (file)
@@ -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
 {
index 4341c14a3f42b544e927229f6090fd83945d72b1..472341d06f745a40c67623293f3b4c72cf7d6134 100644 (file)
@@ -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'];
 
        /**
index b0e6cd362955f5a3e7f029577c4604e6f07f070c..2b6f87e665dc85681b84ac191a30632eb5425354 100644 (file)
@@ -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;
        }
index 1d2e7d9f76b6a692e15c7453397c914e012c6593..34fe7a9870f890e7c19bf72f2137bb29b699f4d9 100644 (file)
@@ -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']) {