Skip to content

Commit 1810c10

Browse files
authored
Send Update-Activity when "Actor-Mode" is changed (#1342)
* Send Update-Activity when "Actor-Mode" is changed fix #1339 * update changelog * delete defaults * Fix tests * Add phpdoc
1 parent 423b651 commit 1810c10

File tree

4 files changed

+34
-6
lines changed

4 files changed

+34
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
* Setting to adjust the number of days Outbox items are kept before being purged.
1414
* Undo API for Outbox items.
1515
* Metadata to New Follower E-Mail.
16+
* Allow Activities on URLs instead of requiring Activity-Objects. This is useful especially for sending Announces and Likes.
1617

1718
### Changed
1819

@@ -22,8 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2223
### Fixed
2324

2425
* The Outbox purging routine no longer is limited to deleting 5 items at a time.
25-
* Allow Activities on URLs instead of requiring Activity-Objects. This is useful especially for sending Announces and Likes.
2626
* Ellipses now display correctly in notification emails for Likes and Reposts.
27+
* Send Update-Activity when "Actor-Mode" is changed.
2728

2829
## [5.2.0] - 2025-02-13
2930

includes/scheduler/class-actor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public static function init() {
4343
// @todo figure out a feasible way of updating the header image since it's not unique to any user.
4444
}
4545

46+
\add_action( 'add_option_activitypub_actor_mode', array( self::class, 'blog_user_update' ) );
47+
\add_action( 'update_option_activitypub_actor_mode', array( self::class, 'blog_user_update' ) );
48+
4649
\add_action( 'transition_post_status', array( self::class, 'schedule_post_activity' ), 33, 3 );
4750
}
4851

@@ -67,6 +70,7 @@ public static function user_meta_update( $meta_id, $user_id, $meta_key ) {
6770
'user_url',
6871
'display_name',
6972
);
73+
7074
if ( in_array( $meta_key, $fields, true ) ) {
7175
self::schedule_profile_update( $user_id );
7276
}

readme.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ For reasons of data protection, it is not possible to see the followers of other
139139
* Changed: Outbox now precesses the first batch of followers right away to avoid delays in processing new Activities.
140140
* Changed: Post bulk edits no longer create Outbox items, unless author or post status change.
141141
* Fixed: The Outbox purging routine no longer is limited to deleting 5 items at a time.
142-
* Fixed an issue where the outbox could not send object types other than `Base_Object` (introduced in 5.0.0).
142+
* Fixed: An issue where the outbox could not send object types other than `Base_Object` (introduced in 5.0.0).
143143
* Fixed: Ellipses now display correctly in notification emails for Likes and Reposts.
144+
* Fixed: Send Update-Activity when "Actor-Mode" is changed.
144145

145146
= 5.2.0 =
146147

tests/includes/class-test-signature.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616
* @coversDefaultClass \Activitypub\Signature
1717
*/
1818
class Test_Signature extends \WP_UnitTestCase {
19+
/**
20+
* Tear down.
21+
*/
22+
public function tear_down() {
23+
parent::tear_down();
24+
\delete_option( 'activitypub_keypair_for_0' );
25+
\delete_option( 'activitypub_keypair_for_-1' );
26+
\delete_option( 'activitypub_keypair_for_admin' );
27+
\delete_option( 'activitypub_blog_user_public_key' );
28+
\delete_option( 'activitypub_blog_user_private_key' );
29+
\delete_option( 'activitypub_application_user_public_key' );
30+
\delete_option( 'activitypub_application_user_private_key' );
31+
\delete_option( 'activitypub_actor_mode' );
32+
\delete_user_meta( 1, 'magic_sig_public_key' );
33+
\delete_user_meta( 1, 'magic_sig_private_key' );
34+
}
1935

2036
/**
2137
* Test signature creation.
@@ -45,6 +61,8 @@ public function test_signature_legacy() {
4561
// Check user.
4662
$user = Actors::get_by_id( 1 );
4763

64+
\delete_option( 'activitypub_keypair_for_admin' );
65+
4866
$public_key = 'public key ' . $user->get__id();
4967
$private_key = 'private key ' . $user->get__id();
5068

@@ -60,11 +78,13 @@ public function test_signature_legacy() {
6078
// Check application user.
6179
$user = Actors::get_by_id( Actors::APPLICATION_USER_ID );
6280

81+
\delete_option( 'activitypub_keypair_for_-1' );
82+
6383
$public_key = 'public key ' . $user->get__id();
6484
$private_key = 'private key ' . $user->get__id();
6585

66-
add_option( 'activitypub_application_user_public_key', $public_key );
67-
add_option( 'activitypub_application_user_private_key', $private_key );
86+
\add_option( 'activitypub_application_user_public_key', $public_key );
87+
\add_option( 'activitypub_application_user_private_key', $private_key );
6888

6989
$key_pair = Signature::get_keypair_for( $user->get__id() );
7090

@@ -80,8 +100,10 @@ public function test_signature_legacy() {
80100
$public_key = 'public key ' . $user->get__id();
81101
$private_key = 'private key ' . $user->get__id();
82102

83-
add_option( 'activitypub_blog_user_public_key', $public_key );
84-
add_option( 'activitypub_blog_user_private_key', $private_key );
103+
\delete_option( 'activitypub_keypair_for_0' );
104+
105+
\add_option( 'activitypub_blog_user_public_key', $public_key );
106+
\add_option( 'activitypub_blog_user_private_key', $private_key );
85107

86108
$key_pair = Signature::get_keypair_for( $user->get__id() );
87109

0 commit comments

Comments
 (0)