diff options
Diffstat (limited to 'include/feedutils.php')
-rw-r--r-- | include/feedutils.php | 59 |
1 files changed, 40 insertions, 19 deletions
diff --git a/include/feedutils.php b/include/feedutils.php index a50214746..1487ea2d6 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -228,15 +228,24 @@ function construct_activity_target($item) { if($item['target']) { $o = '<as:target>' . "\r\n"; $r = json_decode($item['target'],false); - if(! $r) + + if (!$r) { return ''; - if($r->type) + } + + if (isset($r->type)) { $o .= '<as:obj_type>' . xmlify($r->type) . '</as:obj_type>' . "\r\n"; - if($r->id) + } + + if (isset($r->id)) { $o .= '<id>' . xmlify($r->id) . '</id>' . "\r\n"; - if($r->title) + } + + if (isset($r->title)) { $o .= '<title>' . xmlify($r->title) . '</title>' . "\r\n"; - if($r->links) { + } + + if (isset($r->link)) { /** @FIXME !!! */ if(substr($r->link,0,1) === '<') { if(strstr($r->link,'&') && (! strstr($r->link,'&'))) @@ -244,11 +253,14 @@ function construct_activity_target($item) { $r->link = preg_replace('/\<link(.*?)\"\>/','<link$1"/>',$r->link); $o .= $r->link; } - else + else { $o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n"; + } } - if($r->content) + + if(isset($r->content)) { $o .= '<content type="html" >' . xmlify(bbcode($r->content)) . '</content>' . "\r\n"; + } $o .= '</as:target>' . "\r\n"; @@ -311,7 +323,7 @@ function get_atom_author($feed, $item) { $base = $rawactor[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['link']; if($base && count($base)) { foreach($base as $link) { - if($link['attribs']['']['rel'] === 'alternate' && (! $res['author_link'])) + if($link['attribs']['']['rel'] === 'alternate' && (!$author['author_link'])) $author['author_link'] = unxmlify($link['attribs']['']['href']); if(!x($author, 'author_photo') || ! $author['author_photo']) { if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') @@ -357,7 +369,7 @@ function get_atom_author($feed, $item) { if($base && count($base)) { foreach($base as $link) { - if($link['attribs']['']['rel'] === 'alternate' && (! $res['author_link'])) + if($link['attribs']['']['rel'] === 'alternate' && (!$author['author_link'])) $author['author_link'] = unxmlify($link['attribs']['']['href']); if(! (x($author,'author_photo'))) { if($link['attribs']['']['rel'] === 'avatar' || $link['attribs']['']['rel'] === 'photo') @@ -998,7 +1010,7 @@ function process_feed_tombstones($feed,$importer,$contact,$pass) { if(! intval($item['item_deleted'])) { logger('deleting item ' . $item['id'] . ' mid=' . $item['mid'], LOGGER_DEBUG); - drop_item($item['id'],false); + drop_item($item['id']); } } } @@ -1173,15 +1185,19 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { intval($importer['channel_id']) ); - // Update content if 'updated' changes - if($r) { - if(activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE]) - && $datarray['author_xchan'] === $r[0]['author_xchan']) { + if ($r) { + // Check ownership + if ($datarray['author_xchan'] !== $r[0]['author_xchan']) { + logger('stored item author is not imported item author', LOGGER_DEBUG); + continue; + } + + if (activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE])) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); - drop_item($r[0]['id'],false); + drop_item($r[0]['id']); } continue; } @@ -1444,12 +1460,17 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Update content if 'updated' changes - if($r) { - if(isset($datarray['verb']) && activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE]) - && isset($datarray['author_xchan']) && $datarray['author_xchan'] === $r[0]['author_xchan']) { + if ($r) { + // Check ownership + if ($datarray['author_xchan'] !== $r[0]['author_xchan']) { + logger('stored item author is not imported item author', LOGGER_DEBUG); + continue; + } + + if (isset($datarray['verb']) && activity_match($datarray['verb'], ['Delete', ACTIVITY_DELETE])) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); - drop_item($r[0]['id'],false); + drop_item($r[0]['id'], uid: $importer['channel_id']); } continue; } |