mirror of
https://github.com/friendica/friendica
synced 2024-12-23 04:40:15 +00:00
Don't perform a delivery to failing servers
This commit is contained in:
parent
86a486f62b
commit
feb74b4d9a
2 changed files with 15 additions and 5 deletions
|
@ -177,9 +177,13 @@ class GServer
|
||||||
public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false): bool
|
public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false): bool
|
||||||
{
|
{
|
||||||
if ($server == '') {
|
if ($server == '') {
|
||||||
$contact = Contact::getByURL($profile, null, ['baseurl']);
|
$contact = Contact::getByURL($profile, null, ['baseurl', 'network']);
|
||||||
if (!empty($contact['baseurl'])) {
|
if (!empty($contact['baseurl'])) {
|
||||||
$server = $contact['baseurl'];
|
$server = $contact['baseurl'];
|
||||||
|
} elseif ($contact['network'] == Protocol::DIASPORA) {
|
||||||
|
$parts = parse_url($profile);
|
||||||
|
unset($parts['path']);
|
||||||
|
$server = (string)Uri::fromParts($parts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ use Friendica\DI;
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Conversation;
|
use Friendica\Model\Conversation;
|
||||||
use Friendica\Model\Group;
|
use Friendica\Model\Group;
|
||||||
|
use Friendica\Model\GServer;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\PushSubscriber;
|
use Friendica\Model\PushSubscriber;
|
||||||
|
@ -99,7 +100,7 @@ class Notifier
|
||||||
$uid = $target_id;
|
$uid = $target_id;
|
||||||
|
|
||||||
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
$condition = ['uid' => $target_id, 'self' => false, 'network' => [Protocol::DFRN, Protocol::DIASPORA]];
|
||||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'batch'], $condition);
|
$delivery_contacts_stmt = DBA::select('contact', ['id', 'url', 'addr', 'network', 'protocol', 'baseurl', 'batch'], $condition);
|
||||||
} else {
|
} else {
|
||||||
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
$post = Post::selectFirst(['id'], ['uri-id' => $post_uriid, 'uid' => $sender_uid]);
|
||||||
if (!DBA::isResult($post)) {
|
if (!DBA::isResult($post)) {
|
||||||
|
@ -425,7 +426,7 @@ class Notifier
|
||||||
if (!empty($networks)) {
|
if (!empty($networks)) {
|
||||||
$condition['network'] = $networks;
|
$condition['network'] = $networks;
|
||||||
}
|
}
|
||||||
$delivery_contacts_stmt = DBA::select('contact', ['id', 'addr', 'url', 'network', 'protocol', 'batch'], $condition);
|
$delivery_contacts_stmt = DBA::select('contact', ['id', 'addr', 'url', 'network', 'protocol', 'baseurl', 'batch'], $condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$conversants = [];
|
$conversants = [];
|
||||||
|
@ -437,7 +438,7 @@ class Notifier
|
||||||
if ($diaspora_delivery && !$unlisted) {
|
if ($diaspora_delivery && !$unlisted) {
|
||||||
$batch_delivery = true;
|
$batch_delivery = true;
|
||||||
|
|
||||||
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'id', 'url', 'name'],
|
$participants = DBA::selectToArray('contact', ['batch', 'network', 'protocol', 'baseurl', 'id', 'url', 'name'],
|
||||||
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
["`network` = ? AND `batch` != '' AND `uid` = ? AND `rel` != ? AND NOT `blocked` AND NOT `pending` AND NOT `archive`", Protocol::DIASPORA, $owner['uid'], Contact::SHARING],
|
||||||
['group_by' => ['batch', 'network', 'protocol']]);
|
['group_by' => ['batch', 'network', 'protocol']]);
|
||||||
|
|
||||||
|
@ -449,7 +450,7 @@ class Notifier
|
||||||
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
$condition = ['network' => Protocol::DFRN, 'uid' => $owner['uid'], 'blocked' => false,
|
||||||
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
|
'pending' => false, 'archive' => false, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]];
|
||||||
|
|
||||||
$contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol'], $condition);
|
$contacts = DBA::selectToArray('contact', ['id', 'url', 'addr', 'name', 'network', 'protocol', 'baseurl'], $condition);
|
||||||
|
|
||||||
$conversants = array_merge($contacts, $participants);
|
$conversants = array_merge($contacts, $participants);
|
||||||
|
|
||||||
|
@ -563,6 +564,11 @@ class Notifier
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!GServer::reachable($contact['url'], $contact['baseurl'], $contact['network'])) {
|
||||||
|
Logger::info('Server is not reachable', ['id' => $post_uriid, 'uid' => $sender_uid, 'contact' => $contact]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
Logger::info('Delivery', ['batch' => $in_batch, 'target' => $post_uriid, 'uid' => $sender_uid, 'guid' => $target_item['guid'] ?? '', 'to' => $contact]);
|
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.
|
// Ensure that posts with our own protocol arrives before Diaspora posts arrive.
|
||||||
|
|
Loading…
Reference in a new issue