aboutsummaryrefslogtreecommitdiffstats
path: root/include/feedutils.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-06-14 20:20:18 -0700
committerMario Vavti <mario@mariovavti.com>2017-06-15 08:57:03 +0200
commitbb9557a9ae9bbec806ef6e91c25120df0da8a72e (patch)
treefb83ca00972ecdb670fad1695ad96c8d0d71014a /include/feedutils.php
parent0d7e7ac657ce4d1e7d2797b565882d3a57dfd8de (diff)
downloadvolse-hubzilla-bb9557a9ae9bbec806ef6e91c25120df0da8a72e.tar.gz
volse-hubzilla-bb9557a9ae9bbec806ef6e91c25120df0da8a72e.tar.bz2
volse-hubzilla-bb9557a9ae9bbec806ef6e91c25120df0da8a72e.zip
remove some duplicated code
Diffstat (limited to 'include/feedutils.php')
-rw-r--r--include/feedutils.php26
1 files changed, 13 insertions, 13 deletions
diff --git a/include/feedutils.php b/include/feedutils.php
index 2f3927748..0d7e1d6c2 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -259,7 +259,7 @@ function get_atom_elements($feed, $item, &$author) {
if(substr($author['author_link'],-1,1) == '/')
$author['author_link'] = substr($author['author_link'],0,-1);
- $res['mid'] = unxmlify($item->get_id());
+ $res['mid'] = normalise_id(unxmlify($item->get_id()));
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0));
@@ -390,7 +390,7 @@ function get_atom_elements($feed, $item, &$author) {
$rawcnv = $item->get_item_tags(NAMESPACE_OSTATUS, 'conversation');
if($rawcnv) {
- $ostatus_conversation = unxmlify($rawcnv[0]['attribs']['']['ref']);
+ $ostatus_conversation = normalise_id(unxmlify($rawcnv[0]['attribs']['']['ref']));
set_iconfig($res,'ostatus','conversation',$ostatus_conversation,true);
}
@@ -938,7 +938,6 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
foreach($items as $item) {
$is_reply = false;
- $item_id = normalise_id($item->get_id());
logger('processing ' . $item->get_id(), LOGGER_DEBUG);
@@ -955,12 +954,11 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// Have we seen it? If not, import it.
- $item_id = normalise_id($item->get_id());
$author = array();
$datarray = get_atom_elements($feed,$item,$author);
- if($datarray['mid'])
- $datarray['mid'] = normalise_id($item->get_id());
+ if(! $datarray['mid'])
+ continue;
if($contact['xchan_network'] === 'rss') {
$datarray['public_policy'] = 'specific';
@@ -987,7 +985,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$datarray['owner_xchan'] = $contact['xchan_hash'];
$r = q("SELECT edited FROM item WHERE mid = '%s' AND uid = %d LIMIT 1",
- dbesc($item_id),
+ dbesc($datarray['mid']),
intval($importer['channel_id'])
);
@@ -1010,6 +1008,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$pmid = '';
$conv_id = get_iconfig($datarray,'ostatus','conversation');
+ // match conversations - first try ostatus:conversation
+ // next try thr:in_reply_to
+
if($conv_id) {
$c = q("select parent_mid from item left join iconfig on item.id = iconfig.iid where iconfig.cat = 'ostatus' and iconfig.k = 'conversation' and iconfig.v = '%s' and item.uid = %d order by item.id limit 1",
dbesc($conv_id),
@@ -1020,7 +1021,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$datarray['parent_mid'] = $pmid;
}
}
- else {
+ if(! $pmid) {
$x = q("select parent_mid from item where mid = '%s' and uid = %d limit 1",
dbesc($parent_mid),
intval($importer['channel_id'])
@@ -1056,12 +1057,11 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// Head post of a conversation. Have we seen it? If not, import it.
- $item_id = normalise_id($item->get_id());
$author = array();
$datarray = get_atom_elements($feed,$item,$author);
- if($datarray['mid'])
- $datarray['mid'] = normalise_id($item->get_id());
+ if(! $datarray['mid'])
+ continue;
if($contact['xchan_network'] === 'rss') {
$datarray['public_policy'] = 'specific';
@@ -1116,7 +1116,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
$r = q("SELECT edited FROM item WHERE mid = '%s' AND uid = %d LIMIT 1",
- dbesc($item_id),
+ dbesc($datarray['mid']),
intval($importer['channel_id'])
);
@@ -1136,7 +1136,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
continue;
}
- $datarray['parent_mid'] = $item_id;
+ $datarray['parent_mid'] = $datarray['mid'];
$datarray['uid'] = $importer['channel_id'];
$datarray['aid'] = $importer['channel_account_id'];