Preparations to work with BCC

This commit is contained in:
Michael 2018-10-24 19:19:51 +00:00
parent c25d60e107
commit 58f82e084d
4 changed files with 19 additions and 6 deletions

View File

@ -29,6 +29,11 @@ use Friendica\Model\APContact;
* *
* To-do: * To-do:
* - Polling the outboxes for missing content? * - Polling the outboxes for missing content?
*
* Missing parts from DFRN:
* - Public Forum
* - Private Forum
* - Relocation
*/ */
class ActivityPub class ActivityPub
{ {

View File

@ -37,7 +37,7 @@ class Receiver
{ {
const PUBLIC_COLLECTION = 'as:Public'; const PUBLIC_COLLECTION = 'as:Public';
const ACCOUNT_TYPES = ['as:Person', 'as:Organization', 'as:Service', 'as:Group', 'as:Application']; 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']; const ACTIVITY_TYPES = ['as:Like', 'as:Dislike', 'as:Accept', 'as:Reject', 'as:TentativeAccept'];
/** /**

View File

@ -300,10 +300,11 @@ class Transmitter
* Creates an array of permissions from an item thread * Creates an array of permissions from an item thread
* *
* @param array $item * @param array $item
* @param boolean $blindcopy
* *
* @return array with permission data * @return array with permission data
*/ */
private static function createPermissionBlockForItem($item) private static function createPermissionBlockForItem($item, $blindcopy)
{ {
// Will be activated in a later step // Will be activated in a later step
// $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]; // $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'])]; 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) public static function fetchTargetInboxes($item, $uid, $personal = false)
{ {
$permissions = self::createPermissionBlockForItem($item); $permissions = self::createPermissionBlockForItem($item, true);
if (empty($permissions)) { if (empty($permissions)) {
return []; return [];
} }
@ -471,13 +475,15 @@ class Transmitter
continue; continue;
} }
$blindcopy = in_array($element, ['bto', 'bcc']);
foreach ($permissions[$element] as $receiver) { foreach ($permissions[$element] as $receiver) {
if ($receiver == $item_profile['followers']) { if ($receiver == $item_profile['followers']) {
$inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal)); $inboxes = array_merge($inboxes, self::fetchTargetInboxesforUser($uid, $personal));
} else { } else {
$profile = APContact::getByURL($receiver, false); $profile = APContact::getByURL($receiver, false);
if (!empty($profile)) { if (!empty($profile)) {
if (empty($profile['sharedinbox']) || $personal) { if (empty($profile['sharedinbox']) || $personal || $blindcopy) {
$target = $profile['inbox']; $target = $profile['inbox'];
} else { } else {
$target = $profile['sharedinbox']; $target = $profile['sharedinbox'];
@ -593,7 +599,7 @@ class Transmitter
$data['instrument'] = ['type' => 'Service', 'name' => BaseObject::getApp()->getUserAgent()]; $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'])) { if (in_array($data['type'], ['Create', 'Update', 'Delete'])) {
$data['object'] = self::createNote($item); $data['object'] = self::createNote($item);
@ -905,7 +911,7 @@ class Transmitter
$data['generator'] = ['type' => 'Application', 'name' => $item['app']]; $data['generator'] = ['type' => 'Application', 'name' => $item['app']];
} }
$data = array_merge($data, self::createPermissionBlockForItem($item)); $data = array_merge($data, self::createPermissionBlockForItem($item, false));
return $data; return $data;
} }

View 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 // Check the content-length when it is part of the signed data
if (in_array('content-length', $sig_block['headers'])) { if (in_array('content-length', $sig_block['headers'])) {
if (strlen($content) != $headers['content-length']) { if (strlen($content) != $headers['content-length']) {