Move the canFeature policy out of the Activity vocabulary layer#3406
Merged
Conversation
Activity classes are generic vocabulary and must not contain application logic. The canFeature computation (FEP-7aa9) moves from Activity\Actor into a model-layer trait used by the User and Blog models. The generic Actor class no longer injects the local site policy into remote actor representations, and the Application actor stops advertising a consent policy altogether.
There was a problem hiding this comment.
Pull request overview
This PR moves FEP-7aa9 interactionPolicy.canFeature computation out of the generic Activity vocabulary layer and into the model layer, so that only local actors (blog/author) advertise the site’s consent policy while remote and system actors do not.
Changes:
- Introduces a model-layer
Interaction_Policytrait and applies it to theUserandBlogmodels. - Removes the interaction policy computation from
Activity\Actorto prevent leaking local policy into remote actor re-serialization. - Adds/extends PHPUnit coverage for generic actors and the Application actor behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/phpunit/tests/includes/model/class-test-interaction-policy.php | Adds tests ensuring generic actors don’t emit local policy and Application emits no interactionPolicy. |
| includes/model/trait-interaction-policy.php | New trait that computes canFeature from the activitypub_default_feature_policy option for local actors. |
| includes/model/class-user.php | Applies the new interaction policy trait so user actors still emit canFeature. |
| includes/model/class-blog.php | Applies the new interaction policy trait so blog actors still emit canFeature. |
| includes/activity/class-actor.php | Removes policy computation from the vocabulary-layer actor to avoid app-logic leakage to remote actors/system actor. |
| .github/changelog/update-move-interaction-policy-to-models | Adds a patch changelog entry describing the behavior change. |
Declare the methods the trait relies on as abstract, so using it in a class that does not provide them fails at compile time, and document the Activity\Actor inheritance requirement.
Inline the canFeature computation into the User and Blog models and only merge with an interaction policy when one is explicitly set. The trait's implicit requirements on the using class (inherited accessor, actor methods) made it too easy to use incorrectly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes:
Other information:
Testing instructions: