From 5092cb75f42b7f935bb1cc9957707233df8a1373 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 10 Jan 2017 14:25:11 -0800 Subject: normalise feed id --- include/feedutils.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'include/feedutils.php') diff --git a/include/feedutils.php b/include/feedutils.php index 68ac20782..b122a8e4b 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -635,6 +635,7 @@ function get_atom_elements($feed, $item, &$author) { $res['target'] = $obj; } + $arr = array('feed' => $feed, 'item' => $item, 'author' => $author, 'result' => $res); call_hooks('parse_atom', $arr); @@ -731,7 +732,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { foreach($del_entries as $dentry) { $deleted = false; if(isset($dentry['attribs']['']['ref'])) { - $mid = $dentry['attribs']['']['ref']; + $mid = normalise_id($dentry['attribs']['']['ref']); $deleted = true; if(isset($dentry['attribs']['']['when'])) { $when = $dentry['attribs']['']['when']; @@ -771,14 +772,14 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { foreach($items as $item) { $is_reply = false; - $item_id = $item->get_id(); + $item_id = normalise_id($item->get_id()); logger('consume_feed: processing ' . $raw_item_id, LOGGER_DEBUG); $rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to'); if(isset($rawthread[0]['attribs']['']['ref'])) { $is_reply = true; - $parent_mid = $rawthread[0]['attribs']['']['ref']; + $parent_mid = normalise_id($rawthread[0]['attribs']['']['ref']); } if($is_reply) { @@ -788,7 +789,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Have we seen it? If not, import it. - $item_id = $item->get_id(); + $item_id = normalise_id($item->get_id()); $author = array(); $datarray = get_atom_elements($feed,$item,$author); @@ -860,7 +861,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Head post of a conversation. Have we seen it? If not, import it. - $item_id = $item->get_id(); + $item_id = normalise_id($item->get_id()); $author = array(); $datarray = get_atom_elements($feed,$item,$author); @@ -965,6 +966,11 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { } +function normalise_id($id) { + return str_replace('X-ZOT:','',$id); +} + + /** * @brief Process atom feed and return the first post and structure * @@ -1005,14 +1011,14 @@ function process_salmon_feed($xml, $importer) { foreach($items as $item) { - $item_id = $item->get_id(); + $item_id = normalise_id($item->get_id()); logger('processing ' . $item_id, LOGGER_DEBUG); $rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to'); if(isset($rawthread[0]['attribs']['']['ref'])) { $is_reply = true; - $parent_mid = $rawthread[0]['attribs']['']['ref']; + $parent_mid = normalise_id($rawthread[0]['attribs']['']['ref']); } if($is_reply) @@ -1181,7 +1187,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { if(($item['parent'] != $item['id']) || ($item['parent_mid'] !== $item['mid']) || (($item['thr_parent'] !== '') && ($item['thr_parent'] !== $item['mid']))) { $parent_item = (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']); - $o .= '' . "\r\n"; + $o .= '' . "\r\n"; } @@ -1200,7 +1206,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o .= '' . xmlify(prepare_text($body,$item['mimetype'])) . '' . "\r\n"; } - $o .= '' . z_root() . '/display/' . xmlify($item['mid']) . '' . "\r\n"; + $o .= '' . 'X-ZOT:' . xmlify($item['mid']) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; @@ -1287,6 +1293,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { 'entry' => $o ]; + call_hooks('atom_entry', $x); return $x['entry']; -- cgit v1.2.3