aboutsummaryrefslogtreecommitdiffstats
path: root/include/feedutils.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/feedutils.php')
-rw-r--r--include/feedutils.php67
1 files changed, 45 insertions, 22 deletions
diff --git a/include/feedutils.php b/include/feedutils.php
index f05c15414..1487ea2d6 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -4,6 +4,8 @@
* @brief Some functions to work with XML feeds.
*/
+use Zotlabs\Lib\Config;
+
/**
* @brief Return an Atom feed for channel.
*
@@ -226,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,'&amp;')))
@@ -242,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";
@@ -309,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')
@@ -355,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')
@@ -996,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']);
}
}
}
@@ -1037,7 +1051,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
- $sys_expire = intval(get_config('system', 'default_expire_days'));
+ $sys_expire = intval(Config::Get('system', 'default_expire_days'));
$chn_expire = intval($importer['channel_expire_days']);
$expire_days = $sys_expire;
@@ -1171,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;
}
@@ -1325,7 +1343,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
// but save the thread_parent in case we need to refer to it later.
if($importer['channel_system']) {
- if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) {
+ if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,Config::Get('system','pubstream_incl'),Config::Get('system','pubstream_excl'))) {
continue;
}
}
@@ -1442,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;
}
@@ -1481,7 +1504,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
}
if($importer['channel_system']) {
- if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) {
+ if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,Config::Get('system','pubstream_incl'),Config::Get('system','pubstream_excl'))) {
continue;
}
}