Skip to content

Commit 00c30c7

Browse files
authored
Set defaults for the canAnnounce, canLike, and canReply Interaction Policies (#2221)
1 parent a7f70b0 commit 00c30c7

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Improved interaction policies with clearer defaults and better Mastodon compatibility.

includes/transformer/class-post.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ public function get_content_visibility() {
8383
*/
8484
public function get_interaction_policy() {
8585
return array(
86-
'canQuote' => $this->get_quote_policy(),
86+
'canAnnounce' => $this->get_public_interaction_policy(),
87+
'canLike' => $this->get_public_interaction_policy(),
88+
'canQuote' => $this->get_quote_policy(),
89+
'canReply' => $this->get_public_interaction_policy(),
8790
);
8891
}
8992

@@ -975,22 +978,31 @@ private function get_quote_policy() {
975978
return array( 'automaticApproval' => get_rest_url_by_path( sprintf( 'actors/%d/followers', $this->item->post_author ) ) );
976979

977980
case ACTIVITYPUB_INTERACTION_POLICY_ME:
978-
return array( 'automaticApproval' => $this->get_me_actors() );
981+
return array( 'automaticApproval' => $this->get_self_interaction_policy() );
979982

980983
default:
981-
return array(
982-
'automaticApproval' => 'https://www.w3.org/ns/activitystreams#Public',
983-
'always' => 'https://www.w3.org/ns/activitystreams#Public',
984-
);
984+
return $this->get_public_interaction_policy();
985985
}
986986
}
987987

988988
/**
989-
* Get the actor ID(s) for the `me` audience in the Quote interaction policy.
989+
* Get the public interaction policy.
990+
*
991+
* @return array The public interaction policy.
992+
*/
993+
private function get_public_interaction_policy() {
994+
return array(
995+
'automaticApproval' => 'https://www.w3.org/ns/activitystreams#Public',
996+
'always' => 'https://www.w3.org/ns/activitystreams#Public',
997+
);
998+
}
999+
1000+
/**
1001+
* Get the actor ID(s) for the `me` audience for use in interaction policies.
9901002
*
9911003
* @return string|array The actor ID(s).
9921004
*/
993-
private function get_me_actors() {
1005+
private function get_self_interaction_policy() {
9941006
switch ( \get_option( 'activitypub_actor_mode', ACTIVITYPUB_ACTOR_MODE ) ) {
9951007
case ACTIVITYPUB_BLOG_MODE:
9961008
return ( new Blog() )->get_id();

0 commit comments

Comments
 (0)