Description
When the home
domain is changed, we should detect it and take action to call Move::internally
, which will need enhancing to support this case (or possibly another specific function like Move::domain
for this case.)
I worked with Windsurf to spec out what would be needed.
-
Domain Change Detection System
1.1. Create a Domain Change Monitor
- Create a new class
Domain_Change_Monitor
to track domain changes - Store the current domain in the WordPress options table
- Add a hook to
update_option_home
to detect when the site URL changes - Compare the old and new domains to determine if a domain change occurred
1.2. Domain Change Event Handling
- When a domain change is detected, trigger a domain migration process
- Log the change with timestamp and details for future reference
- Store both old and new domains in a persistent option for reference
- Create a new class
-
Extend the
internally
Function2.1. Add Domain Change Detection Parameter
- Modify the
internally
function to accept an optional$domain_change
parameter - Update function signature:
public static function internally( $from, $to, $domain_change = false )
- Add documentation explaining the new parameter's purpose
2.2. Domain-Specific Logic
- Add conditional logic to handle domain change scenarios differently
- For domain changes, generate URLs with both old and new domains
- Update the
Activity
object to include domain change information
- Modify the
-
Actor Profile Management
3.1. Update Actor Identifiers
- Modify the Blog profile to handle both old and new domains
- Update user profiles to maintain both
@[email protected]
and@[email protected]
identifiers - Store the mapping between old and new identifiers
3.2. Extend
alsoKnownAs
Property- Ensure all old domain URLs are added to the
alsoKnownAs
property - Create a helper method to generate domain-specific actor URLs
- Update both user and blog
alsoKnownAs
properties
-
Request Routing and Profile Serving
4.1. Modify
get_by_username
Method- Extend to check for usernames with both old and new domains
- Add domain-aware username parsing to extract the base username
- Implement domain detection to determine which profile version to serve
4.2. Update
get_by_various
Method- Enhance to handle resources from both old and new domains
- Add domain detection logic to map between domain variants
- Maintain backward compatibility with existing implementations
4.3. Enhance
template_redirect
Hook- Modify to detect requests coming to the old domain
- Add conditional logic to serve appropriate actor profiles
- Implement proper handling of both domain variants
4.4. Update
redirect_canonical
Hook- Prevent unnecessary redirects for ActivityPub requests to old domains
- Add domain-specific handling for actor profile requests
- Maintain the canonical URL structure while supporting legacy URLs
-
Migration Process Implementation
5.1. Create a Domain Migration Function
- Implement a function to handle the entire domain migration process
- Process all user accounts and the blog account
- Generate appropriate
Move
activities for all affected actors
5.2. User Interface for Domain Migration
- Add admin interface elements to manage domain migrations
- Provide status information about ongoing migrations
- Allow manual triggering of the migration process
-
Testing and Validation
6.1. Test Cases
- Develop test cases for domain migration scenarios
- Test with various combinations of user profiles and blog profiles
- Validate both incoming and outgoing federation
6.2. Compatibility Testing
- Test with various ActivityPub implementations (Mastodon, Pleroma, etc.)
- Verify that followers are maintained across domain changes
- Ensure proper handling of mentions and interactions
-
Implementation Approach
I recommend a phased implementation approach:
- Phase 1: Implement domain change detection and basic
internally
function updates - Phase 2: Extend actor profile management and request routing
- Phase 3: Complete the migration process and admin interface
- Phase 4: Comprehensive testing and refinement
- Phase 1: Implement domain change detection and basic