Add filter to disable possible mention cache

This commit is contained in:
Alex Kirk 2022-12-10 08:46:44 +01:00
parent 7d598d92a8
commit 6feac1be3b
2 changed files with 8 additions and 1 deletions

View file

@ -413,7 +413,11 @@ class Friends_Feed_Parser_ActivityPub extends \Friends\Feed_Parser {
public function get_possible_mentions() {
static $users = null;
if ( is_null( $users ) || true ) {
if ( ! method_exists( '\Friends\User_Feed', 'get_by_parser' ) ) {
return array();
}
if ( is_null( $users ) || ! apply_filters( 'activitypub_cache_possible_friend_mentions', true ) ) {
$feeds = \Friends\User_Feed::get_by_parser( 'activitypub' );
$users = array();
foreach ( $feeds as $feed ) {

View file

@ -163,6 +163,7 @@ class Test_Friends_Feed_Parser_ActivityPub extends ActivityPub_TestCase_Cache_HT
}
public function test_friend_mentions() {
add_filter( 'friends_cache_possible_mentions', '__return_false' );
$post = \wp_insert_post(
array(
'post_author' => 1,
@ -188,6 +189,8 @@ class Test_Friends_Feed_Parser_ActivityPub extends ActivityPub_TestCase_Cache_HT
$this->assertContains( $this->actor, $activitypub_activity->get_cc() );
remove_all_filters( 'activitypub_from_post_object' );
remove_all_filters( 'activitypub_cache_possible_friend_mentions' );
\wp_trash_post( $post );
}