Don't try legacy if the server supports more
This commit is contained in:
parent
bf563a1a39
commit
050f31eeb3
|
@ -1744,7 +1744,7 @@ class GServer
|
||||||
* @return void
|
* @return void
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
static function setProtocol(int $gsid, int $protocol)
|
public static function setProtocol(int $gsid, int $protocol)
|
||||||
{
|
{
|
||||||
if (empty($gsid)) {
|
if (empty($gsid)) {
|
||||||
return;
|
return;
|
||||||
|
@ -1796,4 +1796,25 @@ 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']]);
|
||||||
DBA::update('gserver', ['protocol' => $protocol], ['id' => $gsid]);
|
DBA::update('gserver', ['protocol' => $protocol], ['id' => $gsid]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the protocol of the given server
|
||||||
|
*
|
||||||
|
* @param int $gsid Server id
|
||||||
|
* @return int
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static function getProtocol(int $gsid)
|
||||||
|
{
|
||||||
|
if (empty($gsid)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$gserver = DBA::selectFirst('gserver', ['protocol'], ['id' => $gsid]);
|
||||||
|
if (DBA::isResult($gserver)) {
|
||||||
|
return $gserver['protocol'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,6 +202,8 @@ class Delivery
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$protocol = Model\GServer::getProtocol($contact['gsid']);
|
||||||
|
|
||||||
// Transmit via Diaspora if the thread had started as Diaspora post.
|
// Transmit via Diaspora if the thread had started as Diaspora post.
|
||||||
// Also transmit via Diaspora if this is a direct answer to a Diaspora comment.
|
// Also transmit via Diaspora if this is a direct answer to a Diaspora comment.
|
||||||
// This is done since the uri wouldn't match (Diaspora doesn't transmit it)
|
// This is done since the uri wouldn't match (Diaspora doesn't transmit it)
|
||||||
|
@ -219,7 +221,7 @@ class Delivery
|
||||||
|
|
||||||
switch ($contact['network']) {
|
switch ($contact['network']) {
|
||||||
case Protocol::DFRN:
|
case Protocol::DFRN:
|
||||||
self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
self::deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup, $protocol);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Protocol::DIASPORA:
|
case Protocol::DIASPORA:
|
||||||
|
@ -255,18 +257,19 @@ class Delivery
|
||||||
/**
|
/**
|
||||||
* Deliver content via DFRN
|
* Deliver content via DFRN
|
||||||
*
|
*
|
||||||
* @param string $cmd Command
|
* @param string $cmd Command
|
||||||
* @param array $contact Contact record of the receiver
|
* @param array $contact Contact record of the receiver
|
||||||
* @param array $owner Owner record of the sender
|
* @param array $owner Owner record of the sender
|
||||||
* @param array $items Item record of the content and the parent
|
* @param array $items Item record of the content and the parent
|
||||||
* @param array $target_item Item record of the content
|
* @param array $target_item Item record of the content
|
||||||
* @param boolean $public_message Is the content public?
|
* @param boolean $public_message Is the content public?
|
||||||
* @param boolean $top_level Is it a thread starter?
|
* @param boolean $top_level Is it a thread starter?
|
||||||
* @param boolean $followup Is it an answer to a remote post?
|
* @param boolean $followup Is it an answer to a remote post?
|
||||||
|
* @param int $server_protocol The protocol of the server
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @throws \ImagickException
|
* @throws \ImagickException
|
||||||
*/
|
*/
|
||||||
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
|
private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup, $server_protocol)
|
||||||
{
|
{
|
||||||
// Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora
|
// Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora
|
||||||
if (Diaspora::isReshare($target_item['body']) && !empty(FContact::getByURL($contact['addr'], false))) {
|
if (Diaspora::isReshare($target_item['body']) && !empty(FContact::getByURL($contact['addr'], false))) {
|
||||||
|
@ -369,7 +372,7 @@ class Delivery
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($deliver_status < 200) || ($deliver_status > 299)) {
|
if ((($deliver_status < 200) || ($deliver_status > 299)) && (empty($server_protocol) || ($server_protocol == Model\Post\DeliveryData::LEGACY_DFRN))) {
|
||||||
// Transmit via Diaspora if not possible via Friendica
|
// Transmit via Diaspora if not possible via Friendica
|
||||||
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
self::deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup);
|
||||||
return;
|
return;
|
||||||
|
@ -377,7 +380,7 @@ class Delivery
|
||||||
} elseif ($cmd != self::RELOCATION) {
|
} elseif ($cmd != self::RELOCATION) {
|
||||||
// DFRN payload over Diaspora transport layer
|
// DFRN payload over Diaspora transport layer
|
||||||
$deliver_status = DFRN::transmit($owner, $contact, $atom);
|
$deliver_status = DFRN::transmit($owner, $contact, $atom);
|
||||||
if ($deliver_status < 200) {
|
if (($deliver_status < 200) && (empty($server_protocol) || ($server_protocol == Model\Post\DeliveryData::LEGACY_DFRN))) {
|
||||||
// Legacy DFRN
|
// Legacy DFRN
|
||||||
$deliver_status = DFRN::deliver($owner, $contact, $atom);
|
$deliver_status = DFRN::deliver($owner, $contact, $atom);
|
||||||
$protocol = Model\Post\DeliveryData::LEGACY_DFRN;
|
$protocol = Model\Post\DeliveryData::LEGACY_DFRN;
|
||||||
|
|
Loading…
Reference in a new issue