Deprecate consume_feed() in favor of Protocol\Feed::consume
This commit is contained in:
parent
e3d20b4366
commit
eba964ec12
|
@ -225,61 +225,10 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false)
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* consume_feed - process atom feed and update anything/everything we might need to update
|
||||
*
|
||||
* $xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
|
||||
*
|
||||
* $importer = the contact_record (joined to user_record) of the local user who owns this relationship.
|
||||
* It is this person's stuff that is going to be updated.
|
||||
* $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity
|
||||
* from an external network and MAY create an appropriate contact record. Otherwise, we MUST
|
||||
* have a contact record.
|
||||
* $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or
|
||||
* might not) try and subscribe to it.
|
||||
* $datedir sorts in reverse order
|
||||
* $pass - by default ($pass = 0) we cannot guarantee that a parent item has been
|
||||
* imported prior to its children being seen in the stream unless we are certain
|
||||
* of how the feed is arranged/ordered.
|
||||
* With $pass = 1, we only pull parent items out of the stream.
|
||||
* With $pass = 2, we only pull children (comments/likes).
|
||||
*
|
||||
* So running this twice, first with pass 1 and then with pass 2 will do the right
|
||||
* thing regardless of feed ordering. This won't be adequate in a fully-threaded
|
||||
* model where comments can have sub-threads. That would require some massive sorting
|
||||
* to get all the feed items into a mostly linear ordering, and might still require
|
||||
* recursion.
|
||||
*
|
||||
* @param $xml
|
||||
* @param array $importer
|
||||
* @param array $contact
|
||||
* @param $hub
|
||||
* @throws ImagickException
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
* @deprecated since 2020.06
|
||||
* @see \Friendica\Protocol\Feed::consume
|
||||
*/
|
||||
function consume_feed($xml, array $importer, array $contact, &$hub)
|
||||
{
|
||||
if ($contact['network'] === Protocol::OSTATUS) {
|
||||
Logger::log("Consume OStatus messages ", Logger::DEBUG);
|
||||
OStatus::import($xml, $importer, $contact, $hub);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($contact['network'] === Protocol::FEED) {
|
||||
Logger::log("Consume feeds", Logger::DEBUG);
|
||||
Feed::import($xml, $importer, $contact);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($contact['network'] === Protocol::DFRN) {
|
||||
Logger::log("Consume DFRN messages", Logger::DEBUG);
|
||||
$dfrn_importer = DFRN::getImporter($contact["id"], $importer["uid"]);
|
||||
if (!empty($dfrn_importer)) {
|
||||
Logger::log("Now import the DFRN feed");
|
||||
DFRN::import($xml, $dfrn_importer, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
\Friendica\Protocol\Feed::consume($xml, $importer, $contact, $hub);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,67 @@ use Friendica\Util\XML;
|
|||
/**
|
||||
* This class contain functions to import feeds (RSS/RDF/Atom)
|
||||
*/
|
||||
class Feed {
|
||||
class Feed
|
||||
{
|
||||
/**
|
||||
* consume - process atom feed and update anything/everything we might need to update
|
||||
*
|
||||
* $xml = the (atom) feed to consume - RSS isn't as fully supported but may work for simple feeds.
|
||||
*
|
||||
* $importer = the contact_record (joined to user_record) of the local user who owns this relationship.
|
||||
* It is this person's stuff that is going to be updated.
|
||||
* $contact = the person who is sending us stuff. If not set, we MAY be processing a "follow" activity
|
||||
* from an external network and MAY create an appropriate contact record. Otherwise, we MUST
|
||||
* have a contact record.
|
||||
* $hub = should we find a hub declation in the feed, pass it back to our calling process, who might (or
|
||||
* might not) try and subscribe to it.
|
||||
* $datedir sorts in reverse order
|
||||
* $pass - by default ($pass = 0) we cannot guarantee that a parent item has been
|
||||
* imported prior to its children being seen in the stream unless we are certain
|
||||
* of how the feed is arranged/ordered.
|
||||
* With $pass = 1, we only pull parent items out of the stream.
|
||||
* With $pass = 2, we only pull children (comments/likes).
|
||||
*
|
||||
* So running this twice, first with pass 1 and then with pass 2 will do the right
|
||||
* thing regardless of feed ordering. This won't be adequate in a fully-threaded
|
||||
* model where comments can have sub-threads. That would require some massive sorting
|
||||
* to get all the feed items into a mostly linear ordering, and might still require
|
||||
* recursion.
|
||||
*
|
||||
* @param $xml
|
||||
* @param array $importer
|
||||
* @param array $contact
|
||||
* @param $hub
|
||||
* @throws ImagickException
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function consume($xml, array $importer, array $contact, &$hub)
|
||||
{
|
||||
if ($contact['network'] === Protocol::OSTATUS) {
|
||||
Logger::log('Consume OStatus messages ', Logger::DEBUG);
|
||||
OStatus::import($xml, $importer, $contact, $hub);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($contact['network'] === Protocol::FEED) {
|
||||
Logger::log('Consume feeds', Logger::DEBUG);
|
||||
self::import($xml, $importer, $contact);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($contact['network'] === Protocol::DFRN) {
|
||||
Logger::log('Consume DFRN messages', Logger::DEBUG);
|
||||
$dfrn_importer = DFRN::getImporter($contact['id'], $importer['uid']);
|
||||
if (!empty($dfrn_importer)) {
|
||||
Logger::log('Now import the DFRN feed');
|
||||
DFRN::import($xml, $dfrn_importer, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a RSS/RDF/Atom feed and create an item entry for it
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue