feed: fix channel links and check for top=0. also filter out Add and Remove activities when building the feed (we should probably do this in fetch_items() but that will require some refactoring

This commit is contained in:
Mario
2025-12-09 12:05:19 +00:00
parent da266f5739
commit bb49a51be3
3 changed files with 7 additions and 3 deletions

View File

@@ -148,14 +148,14 @@ class Channel extends Controller {
'rel' => 'alternate',
'type' => 'application/atom+xml',
'title' => t('Posts and comments'),
'href' => z_root() . '/feed/' . $which
'href' => z_root() . '/feed/' . $which . '?top=0'
]);
head_add_link([
'rel' => 'alternate',
'type' => 'application/atom+xml',
'title' => t('Only posts'),
'href' => z_root() . '/feed/' . $which . '?f=&top=1'
'href' => z_root() . '/feed/' . $which . '?top=1'
]);

View File

@@ -25,7 +25,7 @@ class Feed extends Controller {
$params['end'] = $_REQUEST['date_end'] ?? '';
$params['type'] = 'xml';
$params['pages'] = ((!empty($_REQUEST['pages'])) ? intval($_REQUEST['pages']) : 0);
$params['top'] = ((!empty($_REQUEST['top'])) ? intval($_REQUEST['top']) : PConfig::Get($channel['channel_id'], 'system', 'channel_simple_feed', 1));
$params['top'] = ((array_key_exists('top', $_REQUEST)) ? intval($_REQUEST['top']) : PConfig::Get($channel['channel_id'], 'system', 'channel_simple_feed', 1));
$params['start'] = ((!empty($_REQUEST['start'])) ? intval($_REQUEST['start']) : 0);
$params['records'] = ((!empty($_REQUEST['records'])) ? intval($_REQUEST['records']) : 10);
$params['cat'] = ((!empty($_REQUEST['cat'])) ? escape_tags($_REQUEST['cat']) : '');

View File

@@ -160,6 +160,10 @@ function get_feed_for($channel, $observer_hash, $params) {
if($item['item_private'])
continue;
if (in_array($item['verb'], ['Add', 'Remove'])) {
continue;
}
$atom .= atom_entry($item, $type, null, $channel, true, '', $params['compat']);
}
}