Merge pull request #10029 from annando/set-protocol

We now set the protocol in "gserver" on receiving as well
This commit is contained in:
Hypolite Petovan 2021-03-11 06:16:13 -05:00 committed by GitHub
commit bcfe0933da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 3 deletions

View file

@ -25,11 +25,11 @@ use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Protocol\Feed;
use Friendica\Protocol\OStatus;
use Friendica\Util\Strings;
use Friendica\Util\Network;
use Friendica\Core\System;
use Friendica\Model\GServer;
use Friendica\Model\Post;
function hub_return($valid, $body)
{
@ -134,6 +134,10 @@ function pubsub_post(App $a)
}
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
}
if (!in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND]) && ($contact['network'] != Protocol::FEED)) {
Logger::log('Contact ' . $contact['id'] . ' is not expected to share with us - ignored.');
hub_post_return();

View file

@ -25,6 +25,8 @@ use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\GServer;
use Friendica\Model\Post;
use Friendica\Protocol\ActivityNamespace;
use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
@ -185,6 +187,10 @@ function salmon_post(App $a, $xml = '') {
}
}
if (!empty($r[0]['gsid'])) {
GServer::setProtocol($r[0]['gsid'], Post\DeliveryData::OSTATUS);
}
// Have we ignored the person?
// If so we can not accept this post.

View file

@ -1793,7 +1793,7 @@ class GServer
}
}
Logger::info('Protocol for server', ['protocol' => $protocol, 'old' => $old, 'id' => $gsid, 'url' => $gserver['url']]);
Logger::info('Protocol for server', ['protocol' => $protocol, 'old' => $old, 'id' => $gsid, 'url' => $gserver['url'], 'callstack' => System::callstack(20)]);
DBA::update('gserver', ['protocol' => $protocol], ['id' => $gsid]);
}

View file

@ -33,6 +33,7 @@ use Friendica\Model\APContact;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
@ -367,6 +368,19 @@ class Processor
$item = self::constructAttachList($activity, $item);
// We received the post via AP, so we set the protocol of the server to AP
$contact = Contact::getById($item['author-id'], ['gsid']);
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::ACTIVITYPUB);
}
if ($item['author-id'] != $item['owner-id']) {
$contact = Contact::getById($item['owner-id'], ['gsid']);
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::ACTIVITYPUB);
}
}
return $item;
}

View file

@ -34,6 +34,7 @@ use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\Event;
use Friendica\Model\FContact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
@ -2604,6 +2605,14 @@ class DFRN
Logger::log("Import DFRN message for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG);
if (!empty($importer['gsid'])) {
if ($protocol == Conversation::PARCEL_DIASPORA_DFRN) {
GServer::setProtocol($importer['gsid'], Post\DeliveryData::DFRN);
} elseif ($protocol == Conversation::PARCEL_LEGACY_DFRN) {
GServer::setProtocol($importer['gsid'], Post\DeliveryData::LEGACY_DFRN);
}
}
// is it a public forum? Private forums aren't exposed with this method
$forum = intval(XML::getFirstNodeValue($xpath, "/atom:feed/dfrn:community/text()"));

View file

@ -35,6 +35,7 @@ use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Conversation;
use Friendica\Model\FContact;
use Friendica\Model\GServer;
use Friendica\Model\Item;
use Friendica\Model\ItemURI;
use Friendica\Model\Mail;
@ -1498,6 +1499,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$message_id = self::messageExists($importer["uid"], $guid);
if ($message_id) {
return true;
@ -1682,6 +1687,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$conversation = DBA::selectFirst('conv', [], ['uid' => $importer["uid"], 'guid' => $guid]);
if (!DBA::isResult($conversation)) {
$r = q(
@ -1741,6 +1750,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$message_id = self::messageExists($importer["uid"], $guid);
if ($message_id) {
return true;
@ -1851,6 +1864,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$conversation = null;
$condition = ['uid' => $importer["uid"], 'guid' => $conversation_guid];
@ -1911,6 +1928,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
if (self::messageExists($importer["uid"], $guid)) {
return true;
}
@ -2407,6 +2428,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$message_id = self::messageExists($importer["uid"], $guid);
if ($message_id) {
return true;
@ -2679,6 +2704,10 @@ class Diaspora
return false;
}
if (!empty($contact['gsid'])) {
GServer::setProtocol($contact['gsid'], Post\DeliveryData::DIASPORA);
}
$message_id = self::messageExists($importer["uid"], $guid);
if ($message_id) {
return true;