mirror of
https://github.com/friendica/friendica
synced 2025-04-26 11:50:11 +00:00
Always deliver via AP if the server supports it
This commit is contained in:
parent
251bd30d77
commit
f40ab2b65d
2 changed files with 167 additions and 215 deletions
|
@ -33,6 +33,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\APContact;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\GServer;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\ItemURI;
|
||||
use Friendica\Model\Profile;
|
||||
|
@ -564,8 +565,8 @@ class Transmitter
|
|||
foreach ($terms as $term) {
|
||||
$cid = Contact::getIdForURL($term['url'], $item['uid']);
|
||||
if (!empty($cid) && in_array($cid, $receiver_list)) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'network', 'protocol'], ['id' => $cid]);
|
||||
if (!DBA::isResult($contact) || (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB))) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'network', 'protocol', 'gsid'], ['id' => $cid, 'network' => Protocol::FEDERATED]);
|
||||
if (!DBA::isResult($contact) || !self::isAPContact($contact, $networks)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -576,8 +577,8 @@ class Transmitter
|
|||
}
|
||||
|
||||
foreach ($receiver_list as $receiver) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'hidden', 'network', 'protocol'], ['id' => $receiver]);
|
||||
if (!DBA::isResult($contact) || (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB))) {
|
||||
$contact = DBA::selectFirst('contact', ['url', 'hidden', 'network', 'protocol', 'gsid'], ['id' => $receiver, 'network' => Protocol::FEDERATED]);
|
||||
if (!DBA::isResult($contact) || !self::isAPContact($contact, $networks)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -689,6 +690,23 @@ class Transmitter
|
|||
return DBA::exists('inbox-status', ['url' => $url, 'archive' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given contact should be delivered via AP
|
||||
*
|
||||
* @param array $contact
|
||||
* @param array $networks
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function isAPContact(array $contact, array $networks)
|
||||
{
|
||||
if (in_array($contact['network'], $networks) || ($contact['protocol'] == Protocol::ACTIVITYPUB)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return GServer::getProtocol($contact['gsid'] ?? 0) == Post\DeliveryData::ACTIVITYPUB;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a list of inboxes of followers of a given user
|
||||
*
|
||||
|
@ -721,19 +739,19 @@ class Transmitter
|
|||
$networks = [Protocol::ACTIVITYPUB, Protocol::OSTATUS];
|
||||
}
|
||||
|
||||
$condition = ['uid' => $uid, 'archive' => false, 'pending' => false, 'blocked' => false];
|
||||
$condition = ['uid' => $uid, 'archive' => false, 'pending' => false, 'blocked' => false, 'network' => Protocol::FEDERATED];
|
||||
|
||||
if (!empty($uid)) {
|
||||
$condition['rel'] = [Contact::FOLLOWER, Contact::FRIEND];
|
||||
}
|
||||
|
||||
$contacts = DBA::select('contact', ['id', 'url', 'network', 'protocol'], $condition);
|
||||
$contacts = DBA::select('contact', ['id', 'url', 'network', 'protocol', 'gsid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if (Contact::isLocal($contact['url'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!in_array($contact['network'], $networks) && ($contact['protocol'] != Protocol::ACTIVITYPUB)) {
|
||||
if (!self::isAPContact($contact, $networks)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue