diff options
author | Friendika <info@friendika.com> | 2011-02-28 18:24:32 -0800 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-02-28 18:24:32 -0800 |
commit | f089b1610e148db0f3952d9fce44974dbecfbc5c (patch) | |
tree | 00ac17a78c7bf10903022cb65f59d62c986c48da /include/items.php | |
parent | 3308a693201f13903ae3a229d48c920793815650 (diff) | |
download | volse-hubzilla-f089b1610e148db0f3952d9fce44974dbecfbc5c.tar.gz volse-hubzilla-f089b1610e148db0f3952d9fce44974dbecfbc5c.tar.bz2 volse-hubzilla-f089b1610e148db0f3952d9fce44974dbecfbc5c.zip |
feeds: update content when updated/edited changes
Diffstat (limited to 'include/items.php')
-rw-r--r-- | include/items.php | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/include/items.php b/include/items.php index 0951adbae..f38c0938f 100644 --- a/include/items.php +++ b/include/items.php @@ -1132,15 +1132,28 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { // Have we seen it? If not, import it. - $item_id = $item->get_id(); + $item_id = $item->get_id(); + $datarray = get_atom_elements($feed,$item); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); - // FIXME update content if 'updated' changes + // Update content if 'updated' changes + if(count($r)) { + if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($datarray['body']), + dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc($item_id), + intval($importer['uid']) + ); + } + + // update last-child if it changes + $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow'); if(($allow) && ($allow[0]['data'] != $r[0]['last-child'])) { $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", @@ -1158,7 +1171,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { continue; } - $datarray = get_atom_elements($feed,$item); $force_parent = false; if($contact['network'] === 'stat') { $force_parent = true; @@ -1189,14 +1201,31 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { } else { + // Head post of a conversation. Have we seen it? If not, import it. - $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $item_id = $item->get_id(); + $datarray = get_atom_elements($feed,$item); + + $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); + + // Update content if 'updated' changes + if(count($r)) { + if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { + $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($datarray['body']), + dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), + dbesc($item_id), + intval($importer['uid']) + ); + } + + // update last-child if it changes + $allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { $r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -1208,7 +1237,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { } continue; } - $datarray = get_atom_elements($feed,$item); if(activity_match($datarray['verb'],ACTIVITY_FOLLOW)) { logger('consume-feed: New follower'); |