-
Notifications
You must be signed in to change notification settings - Fork 83
Remove actor mode setting in favor of capability-based actors #2420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from 12 commits
e469d95
b1bcb92
866cd57
2ecd9c7
5e4d89b
4bf2159
eb711e8
ba3744d
7e8db6e
6ab384e
b61c0a5
8396876
2a4b34d
dfb1c79
7af1f6d
5bec5eb
0841201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -211,6 +211,7 @@ public static function maybe_migrate() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( \version_compare( $version_from_db, 'unreleased', '<' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self::migrate_actor_mode_to_capabilities(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| self::clean_up_inbox(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \wp_schedule_single_event( \time(), 'activitypub_migrate_avatar_to_remote_actors' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -478,6 +479,43 @@ public static function migrate_to_4_7_2() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Migrate from actor mode settings to capability-based system. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * User actors are controlled solely via the 'activitypub' capability. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This migration handles sites that were previously in blog-only mode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * by setting a flag to prevent new users from automatically getting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * the activitypub capability. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static function migrate_actor_mode_to_capabilities() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $actor_mode = \get_option( 'activitypub_actor_mode', ACTIVITYPUB_ACTOR_MODE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pfefferle marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If site was in blog-only mode, set flag to disable users by default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( ACTIVITYPUB_BLOG_MODE === $actor_mode ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| \update_option( 'activitypub_disable_users_by_default', true ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+493
to
+495
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If site was in blog-only mode, set flag to disable users by default. | |
| if ( ACTIVITYPUB_BLOG_MODE === $actor_mode ) { | |
| \update_option( 'activitypub_disable_users_by_default', true ); | |
| /** | |
| * Migration strategy: | |
| * - ACTIVITYPUB_BLOG_MODE: Disable users by default. | |
| * - ACTIVITYPUB_ACTOR_MODE: Grant 'activitypub' capability to all users who previously had ActivityPub access. | |
| * - ACTIVITYPUB_ACTOR_AND_BLOG_MODE: Grant 'activitypub' capability to all users who previously had ActivityPub access, and keep blog actor enabled. | |
| * For all modes, clean up legacy options. | |
| */ | |
| if ( defined( 'ACTIVITYPUB_BLOG_MODE' ) && ACTIVITYPUB_BLOG_MODE === $actor_mode ) { | |
| // Blog-only mode: disable users by default. | |
| \update_option( 'activitypub_disable_users_by_default', true ); | |
| } elseif ( | |
| ( defined( 'ACTIVITYPUB_ACTOR_MODE' ) && ACTIVITYPUB_ACTOR_MODE === $actor_mode ) || | |
| ( defined( 'ACTIVITYPUB_ACTOR_AND_BLOG_MODE' ) && ACTIVITYPUB_ACTOR_AND_BLOG_MODE === $actor_mode ) | |
| ) { | |
| // Actor mode or both: ensure users who previously had ActivityPub access retain the capability. | |
| $users = \get_users( array( 'fields' => array( 'ID' ) ) ); | |
| foreach ( $users as $user ) { | |
| $user_obj = \get_userdata( $user->ID ); | |
| if ( $user_obj && ! $user_obj->has_cap( 'activitypub' ) ) { | |
| $user_obj->add_cap( 'activitypub' ); | |
| } | |
| } | |
| // Optionally, you may want to set 'activitypub_disable_users_by_default' to false. | |
| \update_option( 'activitypub_disable_users_by_default', false ); | |
| } else { | |
| // Unknown mode: document that no migration was performed. | |
| // You may want to log this event. |
Uh oh!
There was an error while loading. Please reload this page.