Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/changelog/1516-from-description
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Use the `$from` account for the object in Move activity for internal Moves
2 changes: 1 addition & 1 deletion includes/class-move.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static function internally( $from, $to ) {
$activity->set_type( 'Move' );
$activity->set_actor( $actor );
$activity->set_origin( $actor );
$activity->set_object( $to );
$activity->set_object( $actor );
$activity->set_target( $to );

return add_to_outbox( $activity, null, $user->get__id(), ACTIVITYPUB_CONTENT_VISIBILITY_QUIET_PUBLIC );
Expand Down
34 changes: 34 additions & 0 deletions tests/includes/class-test-move.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,38 @@ public function test_internally_with_valid_input() {
$also_known_as = Actors::get_by_id( self::$user_id )->get_also_known_as();
$this->assertContains( $from, $also_known_as );
}

/**
* Test that the Move Activity created by internally() has the correct properties.
*
* @covers ::internally
*/
public function test_internally_activity_object_properties() {
$from = get_author_posts_url( self::$user_id );
$to = Actors::get_by_id( self::$user_id )->get_id();

// Call the method and get the outbox item ID.
$outbox_id = \Activitypub\Move::internally( $from, $to );

// Verify we got a valid outbox ID.
$this->assertIsInt( $outbox_id );

// Get the outbox item from the database.
$outbox_item = get_post( $outbox_id );

// Verify the outbox item exists.
$this->assertNotNull( $outbox_item );

// Get the activity JSON from the outbox item.
$activity = json_decode( $outbox_item->post_content );

// Verify the activity type is Move.
$this->assertEquals( 'Move', $activity->type );

// Verify the activity object is set to the actor, not the target.
$this->assertEquals( $from, $activity->object );
$this->assertEquals( $from, $activity->actor );
$this->assertEquals( $from, $activity->origin );
$this->assertEquals( $to, $activity->target );
}
}
Loading