mirror of
https://github.com/friendica/friendica
synced 2025-05-21 20:24:12 +02:00
Store the protocol of the received message
This commit is contained in:
parent
dd4a656dec
commit
7ab63d2106
9 changed files with 38 additions and 37 deletions
|
@ -2199,13 +2199,13 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo Add type-hints
|
||||
*/
|
||||
private static function processEntry($header, $xpath, $entry, $importer, $xml)
|
||||
private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol)
|
||||
{
|
||||
Logger::log("Processing entries");
|
||||
|
||||
$item = $header;
|
||||
|
||||
$item["protocol"] = Conversation::PARCEL_DFRN;
|
||||
$item["protocol"] = $protocol;
|
||||
|
||||
$item["source"] = $xml;
|
||||
|
||||
|
@ -2601,7 +2601,7 @@ class DFRN
|
|||
* @throws \ImagickException
|
||||
* @todo set proper type-hints
|
||||
*/
|
||||
public static function import($xml, $importer, $sort_by_date = false)
|
||||
public static function import($xml, $importer, $sort_by_date = false, $protocol = Conversation::PARCEL_DFRN)
|
||||
{
|
||||
if ($xml == "") {
|
||||
return 400;
|
||||
|
@ -2712,7 +2712,7 @@ class DFRN
|
|||
if (!$sort_by_date) {
|
||||
$entries = $xpath->query("/atom:feed/atom:entry");
|
||||
foreach ($entries as $entry) {
|
||||
self::processEntry($header, $xpath, $entry, $importer, $xml);
|
||||
self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
|
||||
}
|
||||
} else {
|
||||
$newentries = [];
|
||||
|
@ -2726,7 +2726,7 @@ class DFRN
|
|||
ksort($newentries);
|
||||
|
||||
foreach ($newentries as $entry) {
|
||||
self::processEntry($header, $xpath, $entry, $importer, $xml);
|
||||
self::processEntry($header, $xpath, $entry, $importer, $xml, $protocol);
|
||||
}
|
||||
}
|
||||
Logger::log("Import done for user " . $importer["importer_uid"] . " from contact " . $importer["id"], Logger::DEBUG);
|
||||
|
|
|
@ -32,6 +32,7 @@ use Friendica\Core\Protocol;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Conversation;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -100,7 +101,7 @@ class Feed
|
|||
$dfrn_importer = DFRN::getImporter($contact['id'], $importer['uid']);
|
||||
if (!empty($dfrn_importer)) {
|
||||
Logger::info('Now import the DFRN feed');
|
||||
DFRN::import($xml, $dfrn_importer, true);
|
||||
DFRN::import($xml, $dfrn_importer, true, Conversation::PARCEL_LEGACY_DFRN);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -875,7 +875,9 @@ class OStatus
|
|||
*/
|
||||
private static function fetchSelf($self, array &$item)
|
||||
{
|
||||
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $self, Conversation::PARCEL_DFRN, Conversation::PARCEL_SALMON];
|
||||
$condition = ['item-uri' => $self, 'protocol' => [Conversation::PARCEL_DFRN,
|
||||
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LEGACY_DFRN,
|
||||
Conversation::PARCEL_LOCAL_DFRN, Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
|
||||
if (DBA::exists('conversation', $condition)) {
|
||||
Logger::log('Conversation '.$item['uri'].' is already stored.', Logger::DEBUG);
|
||||
return;
|
||||
|
@ -912,8 +914,11 @@ class OStatus
|
|||
*/
|
||||
private static function fetchRelated($related, $related_uri, $importer)
|
||||
{
|
||||
$condition = ['`item-uri` = ? AND `protocol` IN (?, ?)', $related_uri, Conversation::PARCEL_DFRN, Conversation::PARCEL_SALMON];
|
||||
$conversation = DBA::selectFirst('conversation', ['source', 'protocol'], $condition);
|
||||
$condition = ['item-uri' => $related_uri, 'protocol' => [Conversation::PARCEL_DFRN,
|
||||
Conversation::PARCEL_DIASPORA_DFRN, Conversation::PARCEL_LEGACY_DFRN,
|
||||
Conversation::PARCEL_LOCAL_DFRN, Conversation::PARCEL_DIRECT, Conversation::PARCEL_SALMON]];
|
||||
if (DBA::exists('conversation', $condition)) {
|
||||
$conversation = DBA::selectFirst('conversation', ['source', 'protocol'], $condition);
|
||||
if (DBA::isResult($conversation)) {
|
||||
$stored = true;
|
||||
$xml = $conversation['source'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue