Improve distribution of non public messages
This commit is contained in:
parent
104ce7c64f
commit
404e937872
|
@ -1042,10 +1042,12 @@ class Item
|
|||
|
||||
// Reshares have to keep their permissions to allow groups to work
|
||||
if (!$defined_permissions && (!$item['origin'] || ($item['verb'] != Activity::ANNOUNCE))) {
|
||||
$item['allow_cid'] = $toplevel_parent['allow_cid'];
|
||||
$item['allow_gid'] = $toplevel_parent['allow_gid'];
|
||||
$item['deny_cid'] = $toplevel_parent['deny_cid'];
|
||||
$item['deny_gid'] = $toplevel_parent['deny_gid'];
|
||||
// Don't store the permissions on pure AP posts
|
||||
$store_permissions = ($item['network'] != Protocol::ACTIVITYPUB) || $item['origin'] || !empty($item['diaspora_signed_text']);
|
||||
$item['allow_cid'] = $store_permissions ? $toplevel_parent['allow_cid'] : '';
|
||||
$item['allow_gid'] = $store_permissions ? $toplevel_parent['allow_gid'] : '';
|
||||
$item['deny_cid'] = $store_permissions ? $toplevel_parent['deny_cid'] : '';
|
||||
$item['deny_gid'] = $store_permissions ? $toplevel_parent['deny_gid'] : '';
|
||||
}
|
||||
|
||||
$parent_origin = $toplevel_parent['origin'];
|
||||
|
|
|
@ -1192,6 +1192,7 @@ class Diaspora
|
|||
{
|
||||
$fields = [
|
||||
'id', 'parent', 'body', 'wall', 'uri', 'guid', 'private', 'origin',
|
||||
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||
'author-name', 'author-link', 'author-avatar', 'gravity',
|
||||
'owner-name', 'owner-link', 'owner-avatar'
|
||||
];
|
||||
|
@ -1567,6 +1568,12 @@ class Diaspora
|
|||
$datarray['verb'] = Activity::POST;
|
||||
$datarray['gravity'] = Item::GRAVITY_COMMENT;
|
||||
|
||||
$datarray['private'] = $toplevel_parent_item['private'];
|
||||
$datarray['allow_cid'] = $toplevel_parent_item['allow_cid'];
|
||||
$datarray['allow_gid'] = $toplevel_parent_item['allow_gid'];
|
||||
$datarray['deny_cid'] = $toplevel_parent_item['deny_cid'];
|
||||
$datarray['deny_gid'] = $toplevel_parent_item['deny_gid'];
|
||||
|
||||
$datarray['thr-parent'] = $thr_parent ?: $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::COMMENT;
|
||||
|
@ -1823,6 +1830,13 @@ class Diaspora
|
|||
|
||||
$datarray['verb'] = $verb;
|
||||
$datarray['gravity'] = Item::GRAVITY_ACTIVITY;
|
||||
|
||||
$datarray['private'] = $toplevel_parent_item['private'];
|
||||
$datarray['allow_cid'] = $toplevel_parent_item['allow_cid'];
|
||||
$datarray['allow_gid'] = $toplevel_parent_item['allow_gid'];
|
||||
$datarray['deny_cid'] = $toplevel_parent_item['deny_cid'];
|
||||
$datarray['deny_gid'] = $toplevel_parent_item['deny_gid'];
|
||||
|
||||
$datarray['thr-parent'] = $toplevel_parent_item['uri'];
|
||||
|
||||
$datarray['object-type'] = Activity\ObjectType::NOTE;
|
||||
|
|
|
@ -102,7 +102,7 @@ class Notifier
|
|||
$uid = $target_id;
|
||||
|
||||
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'uri-id', 'url', 'addr', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
||||
} else {
|
||||
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||
if (!DBA::isResult($post)) {
|
||||
|
@ -191,7 +191,8 @@ class Notifier
|
|||
$apdelivery = self::activityPubDelivery($cmd, $target_item, $parent, $thr_parent, $a->getQueueValue('priority'), $a->getQueueValue('created'), $owner);
|
||||
$ap_contacts = $apdelivery['contacts'];
|
||||
$delivery_queue_count += $apdelivery['count'];
|
||||
if (($thr_parent['network'] == Protocol::ACTIVITYPUB) && ($thr_parent['private'] == Item::PRIVATE)) {
|
||||
// Restrict distribution to AP, when there are no permissions.
|
||||
if (($target_item['private'] == Item::PRIVATE) && empty($target_item['allow_cid']) && empty($target_item['allow_gid']) && empty($target_item['deny_cid']) && empty($target_item['deny_gid'])) {
|
||||
$only_ap_delivery = true;
|
||||
$public_message = false;
|
||||
$diaspora_delivery = false;
|
||||
|
@ -438,7 +439,7 @@ class Notifier
|
|||
if (!empty($networks)) {
|
||||
$condition['network'] = $networks;
|
||||
}
|
||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'uri-id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'gsid', 'batch'], $condition);
|
||||
}
|
||||
|
||||
$conversants = [];
|
||||
|
@ -462,7 +463,7 @@ class Notifier
|
|||
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
||||
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
|
||||
|
||||
$contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl', 'gsid'], $condition);
|
||||
$contacts = DBA::selectToArray('contact', ['id', 'uri-id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl', 'gsid'], $condition);
|
||||
|
||||
$conversants = array_merge($contacts, $participants);
|
||||
|
||||
|
@ -593,6 +594,11 @@ class Notifier
|
|||
continue;
|
||||
}
|
||||
|
||||
if (($contact['network'] == Protocol::ACTIVITYPUB) && !DI::dsprContact()->existsByUriId($contact['uri-id'])) {
|
||||
Logger::info('The ActivityPub contact does not support Diaspora, so skip delivery via Diaspora', ['id' => $post_uriid, 'uid' => $sender_uid, 'url' => $contact['url']]);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger::info('Delivery', ['batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
|
||||
|
||||
// Ensure that posts with our own protocol arrives before Diaspora posts arrive.
|
||||
|
|
Loading…
Reference in New Issue
Block a user