@@ -458,8 +458,36 @@ public function test_create_item_with_invalid_request() {
458458 * @covers ::get_local_recipients
459459 */
460460 public function test_get_local_recipients_no_recipients () {
461+ // Enable actor mode to allow user actors.
462+ \update_option ( 'activitypub_actor_mode ' , ACTIVITYPUB_ACTOR_MODE );
463+
464+ // Create a remote actor and make a user follow them.
465+ $ remote_actor_url = 'https://example.com/actor/no-recipients ' ;
466+
467+ // Mock the remote actor fetch.
468+ $ remote_object_filter = function ( $ pre , $ url ) use ( $ remote_actor_url ) {
469+ if ( $ url === $ remote_actor_url ) {
470+ return array (
471+ '@context ' => 'https://www.w3.org/ns/activitystreams ' ,
472+ 'id ' => $ remote_actor_url ,
473+ 'type ' => 'Person ' ,
474+ 'preferredUsername ' => 'testactor ' ,
475+ 'name ' => 'Test Actor ' ,
476+ 'inbox ' => 'https://example.com/actor/1/inbox ' ,
477+ );
478+ }
479+ return $ pre ;
480+ };
481+ \add_filter ( 'activitypub_pre_http_get_remote_object ' , $ remote_object_filter , 10 , 2 );
482+
483+ $ remote_actor = \Activitypub \Collection \Remote_Actors::fetch_by_uri ( $ remote_actor_url );
484+
485+ // Make test user follow the remote actor.
486+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , self ::$ user_id );
487+
461488 $ activity = array (
462- 'type ' => 'Create ' ,
489+ 'type ' => 'Create ' ,
490+ 'actor ' => $ remote_actor_url ,
463491 );
464492
465493 // Use reflection to test the private method.
@@ -470,9 +498,13 @@ public function test_get_local_recipients_no_recipients() {
470498 }
471499
472500 $ result = $ method ->invoke ( $ this ->inbox_controller , $ activity );
473- // Activities with no recipients are treated as public and delivered to all local actors.
474- $ this ->assertNotEmpty ( $ result , 'Should return all local actors when no recipients (treated as public) ' );
475- $ this ->assertEquals ( Actors::get_all_ids (), $ result , 'Should match all local actor IDs ' );
501+ // Activities with no recipients are treated as public and delivered to followers only.
502+ $ this ->assertNotEmpty ( $ result , 'Should return followers when no recipients (treated as public) ' );
503+ $ this ->assertContains ( self ::$ user_id , $ result , 'Should contain the follower ' );
504+
505+ // Clean up.
506+ \delete_option ( 'activitypub_actor_mode ' );
507+ \remove_filter ( 'activitypub_pre_http_get_remote_object ' , $ remote_object_filter );
476508 }
477509
478510 /**
@@ -588,10 +620,10 @@ public function test_get_local_recipients_public_activity() {
588620 $ remote_actor = \Activitypub \Collection \Remote_Actors::fetch_by_uri ( $ remote_actor_url );
589621
590622 // Make users follow the remote actor.
591- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , self ::$ user_id );
592- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , $ user_id_1 );
593- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , $ user_id_2 );
594- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , $ user_id_3 );
623+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , self ::$ user_id );
624+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , $ user_id_1 );
625+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , $ user_id_2 );
626+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , $ user_id_3 );
595627
596628 // Public activity with "to" containing the public collection.
597629 $ activity = array (
@@ -661,8 +693,8 @@ public function test_get_local_recipients_public_activity_in_cc() {
661693 $ remote_actor = \Activitypub \Collection \Remote_Actors::fetch_by_uri ( $ remote_actor_url );
662694
663695 // Make users follow the remote actor.
664- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , self ::$ user_id );
665- \add_post_meta ( $ remote_actor ->ID , '_activitypub_followers ' , $ user_id );
696+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , self ::$ user_id );
697+ \add_post_meta ( $ remote_actor ->ID , '_activitypub_followed_by ' , $ user_id );
666698
667699 // Public activity with "cc" containing the public collection.
668700 $ activity = array (
0 commit comments