Automattic / wordpress-activitypub

ActivityPub for WordPress
https://wordpress.org/plugins/activitypub/
MIT License
493 stars 74 forks source link

Feature request: Filter audience (or other post properties) #349

Closed janboddez closed 9 months ago

janboddez commented 1 year ago

I have posts that are not shown on my home or archive pages. They show in feeds, but they're not followers-only, because anyone with the URL can access them. I call them "unlisted." (Some would call them "RSS Cl...") :-D

Either way, it would be cool if I could also filter the to and cc properties of posts.

Might be as simple as adding a filter to https://github.com/Automattic/wordpress-activitypub/blob/ba7f57d6ff346eddba2c3f861c969542227b5fff/includes/model/class-post.php#L169 (although I'm not entirely sure which properties could then be filtered and which could not).

janboddez commented 1 year ago

I just noticed apply_filters( 'activitypub_post', $array, $this->post ), my bad!

janboddez commented 1 year ago

For anyone interested:

add_filter( 'activitypub_post', function( $array, $post ) {
    if ( has_category( 'rss-only', $post ) ) { // Just an example.
        // Make this post "unlisted."
        $array['to'] = array( rest_url( "activitypub/1.0/users/{$post->post_author}/followers" ) );
        $array['cc'] = array( 'https://www.w3.org/ns/activitystreams#Public' );
    }

    return $array;
}, 99, 2 );
janboddez commented 1 year ago

No longer works (for me?). I can only guess somehow this hook is no longer called?

github-actions[bot] commented 9 months ago

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days.