Skip to content

Commit 19f8852

Browse files
authored
Outbox: Process first batch right away (#1334)
Helps with cutting down the number of events the need processing.
1 parent 7cacd89 commit 19f8852

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
* Setting to adjust the number of days Outbox items are kept before being purged.
1313

14+
### Changed
15+
16+
* Outbox now precesses the first batch of followers right away to avoid delays in processing new Activities.
17+
1418
### Fixed
1519

1620
* The Outbox purging routine no longer is limited to deleting 5 items at a time.

includes/class-dispatcher.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,11 @@ public static function process_outbox( $id ) {
9090
self::send_to_interactees( $activity, $actor->get__id(), $outbox_item );
9191

9292
if ( self::should_send_to_followers( $activity, $actor, $outbox_item ) ) {
93-
\wp_schedule_single_event(
94-
\time(),
95-
'activitypub_async_batch',
96-
array(
97-
self::$callback,
98-
$outbox_item->ID,
99-
self::$batch_size,
100-
\get_post_meta( $outbox_item->ID, '_activitypub_outbox_offset', true ) ?: 0, // phpcs:ignore
101-
)
93+
Scheduler::async_batch(
94+
self::$callback,
95+
$outbox_item->ID,
96+
self::$batch_size,
97+
\get_post_meta( $outbox_item->ID, '_activitypub_outbox_offset', true ) ?: 0 // phpcs:ignore
10298
);
10399
} else {
104100
// No followers to process for this update. We're done.

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ For reasons of data protection, it is not possible to see the followers of other
134134
* Added: Allow Activities on URLs instead of requiring Activity-Objects. This is useful especially for sending Announces and Likes.
135135
* Added: Undo API for Outbox items.
136136
* Added: Setting to adjust the number of days Outbox items are kept before being purged.
137+
* Changed: Outbox now precesses the first batch of followers right away to avoid delays in processing new Activities.
137138
* Fixed: The Outbox purging routine no longer is limited to deleting 5 items at a time.
138139
* Fixed an issue where the outbox could not send object types other than `Base_Object` (introduced in 5.0.0).
139140

tests/includes/class-test-dispatcher.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,7 @@ public function test_process_outbox() {
9393

9494
Dispatcher::process_outbox( $outbox_item->ID );
9595

96-
$this->assertNotFalse(
97-
wp_next_scheduled(
98-
'activitypub_async_batch',
99-
array(
100-
Dispatcher::$callback,
101-
$outbox_item->ID,
102-
Dispatcher::$batch_size,
103-
0,
104-
)
105-
)
106-
);
96+
$this->assertEquals( 'publish', \get_post( $outbox_item->ID )->post_status );
10797

10898
remove_filter( 'activitypub_send_activity_to_followers', $test_callback );
10999
}

0 commit comments

Comments
 (0)