Remove unfeatured posts from collection
This commit is contained in:
parent
6c8ea1d0d8
commit
2764859350
|
@ -993,9 +993,25 @@ class Processor
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pcid = Contact::getIdForURL($url, 0, false);
|
||||||
|
if (empty($pcid)) {
|
||||||
|
Logger::info('Contact not found', ['contact' => $url]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = DBA::selectToArray('collection-view', ['uri-id'], ['cid' => $pcid, 'type' => Post\Collection::FEATURED]);
|
||||||
|
if (!empty($posts)) {
|
||||||
|
$old_featured = array_column($posts, 'uri-id');
|
||||||
|
}
|
||||||
|
|
||||||
$featured = ActivityPub::fetchItems($apcontact['featured']);
|
$featured = ActivityPub::fetchItems($apcontact['featured']);
|
||||||
if (empty($featured)) {
|
if (empty($featured)) {
|
||||||
Logger::info('Contact does not have featured posts', ['contact' => $url]);
|
Logger::info('Contact does not have featured posts', ['contact' => $url]);
|
||||||
|
|
||||||
|
foreach ($old_featured as $uri_id) {
|
||||||
|
Post\Collection::remove($uri_id, Post\Collection::FEATURED);
|
||||||
|
Logger::debug('Removed no longer featured post', ['uri-id' => $uri_id, 'contact' => $url]);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1018,10 +1034,20 @@ class Processor
|
||||||
Logger::debug('Post already had been featured', ['uri-id' => $item['uri-id'], 'contact' => $url]);
|
Logger::debug('Post already had been featured', ['uri-id' => $item['uri-id'], 'contact' => $url]);
|
||||||
$old++;
|
$old++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$index = array_search($item['uri-id'], $old_featured);
|
||||||
|
if (!($index === false)) {
|
||||||
|
unset($old_featured[$index]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($old_featured as $uri_id) {
|
||||||
|
Post\Collection::remove($uri_id, Post\Collection::FEATURED);
|
||||||
|
Logger::debug('Removed no longer featured post', ['uri-id' => $uri_id, 'contact' => $url]);
|
||||||
|
}
|
||||||
|
|
||||||
Logger::info('Fetched featured posts', ['new' => $new, 'old' => $old, 'contact' => $url]);
|
Logger::info('Fetched featured posts', ['new' => $new, 'old' => $old, 'contact' => $url]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user