aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-01-10 14:25:11 -0800
committerzotlabs <mike@macgirvin.com>2017-01-10 14:25:11 -0800
commit5092cb75f42b7f935bb1cc9957707233df8a1373 (patch)
treeeb365aa57ffef5196ca429860942a794efb02e56
parentf2f6a0534257394e52e9d8e41dce8ac55db332d1 (diff)
downloadvolse-hubzilla-5092cb75f42b7f935bb1cc9957707233df8a1373.tar.gz
volse-hubzilla-5092cb75f42b7f935bb1cc9957707233df8a1373.tar.bz2
volse-hubzilla-5092cb75f42b7f935bb1cc9957707233df8a1373.zip
normalise feed id
-rw-r--r--include/feedutils.php25
1 files changed, 16 insertions, 9 deletions
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 .= '<thr:in-reply-to ref="' . z_root() . '/display/' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n";
+ $o .= '<thr:in-reply-to ref="' . 'X-ZOT:' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($item['plink']) . '" />' . "\r\n";
}
@@ -1200,7 +1206,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$o .= '<content type="' . $type . '" >' . xmlify(prepare_text($body,$item['mimetype'])) . '</content>' . "\r\n";
}
- $o .= '<id>' . z_root() . '/display/' . xmlify($item['mid']) . '</id>' . "\r\n";
+ $o .= '<id>' . 'X-ZOT:' . xmlify($item['mid']) . '</id>' . "\r\n";
$o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n";
$o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\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'];