]> git.mxchange.org Git - friendica.git/commitdiff
allow RSS for feed contacts, but no comments
authorFriendika <info@friendika.com>
Tue, 25 Jan 2011 03:36:20 +0000 (19:36 -0800)
committerFriendika <info@friendika.com>
Tue, 25 Jan 2011 03:36:20 +0000 (19:36 -0800)
include/Scrape.php
include/items.php
mod/follow.php

index 8478ea40714d389365522d02d685c7befbe51307..e4f7a0878c71016332f7f28bee75b1f97bef8bf1 100644 (file)
@@ -161,6 +161,8 @@ function scrape_feed($url) {
                $x = $item->getAttribute('rel');
                if(($x === 'alternate') && ($item->getAttribute('type') === 'application/atom+xml'))
                        $ret['feed_atom'] = $item->getAttribute('href');
+               if(($x === 'alternate') && ($item->getAttribute('type') === 'application/rss+xml'))
+                       $ret['feed_rss'] = $item->getAttribute('href');
        }
 
        return $ret;
index 5f8264beb860a64708a3da8ff407fd17d06d9181..cbe0e970d1457d359217f044c10c3ff7687ed0de 100644 (file)
@@ -423,19 +423,29 @@ function get_atom_elements($feed,$item) {
        else
                $res['private'] = 0;
 
-       $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published');
-       if($rawcreated)
-               $res['created'] = unxmlify($rawcreated[0]['data']);
 
        $rawlocation = $item->get_item_tags(NAMESPACE_DFRN, 'location');
        if($rawlocation)
                $res['location'] = unxmlify($rawlocation[0]['data']);
 
 
+       $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published');
+       if($rawcreated)
+               $res['created'] = unxmlify($rawcreated[0]['data']);
+
+
        $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated');
        if($rawedited)
                $res['edited'] = unxmlify($rawcreated[0]['data']);
 
+
+       if(! $res['created'])
+               $res['created'] = $item->get_date();
+
+       if(! $res['edited'])
+               $res['edited'] = $item->get_date();
+
+
        $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner');
        if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])
                $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']);
@@ -1155,6 +1165,10 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
                                        );
                                        $datarray['last-child'] = 1;
                                }
+                               if(($contact['network'] === 'feed') || (! strlen($contact['poll']))) {
+                                       // one way feed - no remote comment ability
+                                       $datarray['last-child'] = 0;
+                               }
                                $datarray['parent-uri'] = $parent_uri;
                                $datarray['uid'] = $importer['uid'];
                                $datarray['contact-id'] = $contact['id'];
@@ -1207,6 +1221,11 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
                                        $datarray['last-child'] = 1;
                                }
 
+                               if(($contact['network'] === 'feed') || (! strlen($contact['poll']))) {
+                                       // one way feed - no remote comment ability
+                                       $datarray['last-child'] = 0;
+                               }
+
                                $datarray['parent-uri'] = $item_id;
                                $datarray['uid'] = $importer['uid'];
                                $datarray['contact-id'] = $contact['id'];
@@ -1216,7 +1235,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) {
                        }
                }
        }
-
 }
 
 function new_follower($importer,$contact,$datarray,$item) {
index e5eb7763bf620eea6a6248384de66e7e2422ebc5..bad2e74f9cef47adedbdd777c459d6087ac72c6c 100644 (file)
@@ -74,8 +74,8 @@ function follow_post(&$a) {
 
                $ret = scrape_feed($url);
 
-               if(count($ret) && $ret['feed_atom']) {
-                       $poll = $ret['feed_atom'];
+               if(count($ret) && ($ret['feed_atom'] || $ret['feed_rss'])) {
+                       $poll = ((x($ret,'feed_atom')) ? $ret['feed_atom'] : $ret['feed_rss']);
                        $vcard = array();
                        require_once('simplepie/simplepie.inc');
                    $feed = new SimplePie();
@@ -115,7 +115,6 @@ function follow_post(&$a) {
 
        logger('follow: poll=' . $poll . ' notify=' . $notify . ' profile=' . $profile . ' vcard=' . print_r($vcard,true));
 
-
        // do we have enough information?
        
        if(! ((x($vcard['fn'])) && ($poll) && ($profile))) {