This commit is contained in:
Matthias Pfefferle 2023-05-10 14:55:10 +02:00
parent 17b66cb23d
commit 2570928b00
2 changed files with 24 additions and 2 deletions

View file

@ -21,6 +21,11 @@ class Scheduler {
\add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) ); \add_action( 'activitypub_cleanup_followers', array( self::class, 'cleanup_followers' ) );
} }
/**
* Schedule all ActivityPub schedules.
*
* @return void
*/
public static function register_schedules() { public static function register_schedules() {
if ( ! \wp_next_scheduled( 'activitypub_update_followers' ) ) { if ( ! \wp_next_scheduled( 'activitypub_update_followers' ) ) {
\wp_schedule_event( time(), 'hourly', 'activitypub_update_followers' ); \wp_schedule_event( time(), 'hourly', 'activitypub_update_followers' );
@ -31,6 +36,11 @@ class Scheduler {
} }
} }
/**
* Unscedule all ActivityPub schedules.
*
* @return void
*/
public static function deregister_schedules() { public static function deregister_schedules() {
wp_unschedule_hook( 'activitypub_update_followers' ); wp_unschedule_hook( 'activitypub_update_followers' );
wp_unschedule_hook( 'activitypub_cleanup_followers' ); wp_unschedule_hook( 'activitypub_cleanup_followers' );

View file

@ -406,9 +406,13 @@ class Followers {
} }
/** /**
* Undocumented function * Get all Followers that have not been updated for a given time
* *
* @return void * @param enum $output The output format, supported ARRAY_N, OBJECT and ACTIVITYPUB_OBJECT.
* @param int $number Limits the result.
* @param int $older_than The time in seconds.
*
* @return mixed The Term list of Followers, the format depends on $output.
*/ */
public static function get_outdated_followers( $output = ARRAY_N, $number = 50, $older_than = 604800 ) { public static function get_outdated_followers( $output = ARRAY_N, $number = 50, $older_than = 604800 ) {
$args = array( $args = array(
@ -449,6 +453,14 @@ class Followers {
} }
} }
/**
* Get all Followers that had errors
*
* @param enum $output The output format, supported ARRAY_N, OBJECT and ACTIVITYPUB_OBJECT
* @param integer $number The number of Followers to return.
*
* @return mixed The Term list of Followers, the format depends on $output.
*/
public static function get_faulty_followers( $output = ARRAY_N, $number = 10 ) { public static function get_faulty_followers( $output = ARRAY_N, $number = 10 ) {
$args = array( $args = array(
'taxonomy' => self::TAXONOMY, 'taxonomy' => self::TAXONOMY,