@@ -601,4 +601,50 @@ public function get_moved_to() {
601601
602602 return $ moved_to && $ moved_to !== $ this ->get_id () ? $ moved_to : null ;
603603 }
604+
605+ /**
606+ * Get the actor-level interaction policy.
607+ *
608+ * Overrides the magic property accessor on Base_Object so that we always
609+ * compute the policy from the current site setting rather than returning a
610+ * cached property value. Currently only emits `canFeature` (FEP-7aa9).
611+ * Driven by the site option `activitypub_default_feature_policy` and
612+ * defaults to denying all featured-collection requests, in line with
613+ * FEP-7aa9's "absence of policy = no consent" rule.
614+ *
615+ * @see https://w3id.org/fep/7aa9
616+ *
617+ * @since 9.0.0
618+ *
619+ * @return array
620+ */
621+ public function get_interaction_policy () {
622+ $ policy = array ( 'canFeature ' => $ this ->build_can_feature_policy () );
623+
624+ // Merge with an explicitly set interaction policy, if any.
625+ if ( $ this ->interaction_policy ) {
626+ $ policy = \array_merge ( (array ) $ this ->interaction_policy , $ policy );
627+ }
628+
629+ return $ policy ;
630+ }
631+
632+ /**
633+ * Build the `canFeature` policy array from the site option.
634+ *
635+ * @return array
636+ */
637+ protected function build_can_feature_policy () {
638+ $ policy = \get_option ( 'activitypub_default_feature_policy ' , ACTIVITYPUB_INTERACTION_POLICY_ME );
639+
640+ switch ( $ policy ) {
641+ case ACTIVITYPUB_INTERACTION_POLICY_ANYONE :
642+ return array ( 'automaticApproval ' => array ( 'https://www.w3.org/ns/activitystreams#Public ' ) );
643+ case ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS :
644+ return array ( 'automaticApproval ' => array ( $ this ->get_followers () ) );
645+ case ACTIVITYPUB_INTERACTION_POLICY_ME :
646+ default :
647+ return array ( 'automaticApproval ' => array ( $ this ->get_id () ) );
648+ }
649+ }
604650}
0 commit comments