schedule migration because it takes quite some time
This commit is contained in:
parent
fb3d6d2634
commit
5ef41dea02
4 changed files with 17 additions and 1 deletions
|
@ -35,7 +35,6 @@ function init() {
|
|||
require_once \dirname( __FILE__ ) . '/includes/class-http.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/class-signature.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/class-webfinger.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/class-migration.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/functions.php';
|
||||
|
||||
|
@ -43,6 +42,9 @@ function init() {
|
|||
require_once \dirname( __FILE__ ) . '/includes/model/class-post.php';
|
||||
require_once \dirname( __FILE__ ) . '/includes/model/class-follower.php';
|
||||
|
||||
require_once \dirname( __FILE__ ) . '/includes/class-migration.php';
|
||||
Migration::init();
|
||||
|
||||
require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php';
|
||||
Activity_Dispatcher::init();
|
||||
|
||||
|
|
|
@ -61,6 +61,9 @@ class Activity_Dispatcher {
|
|||
* @return void
|
||||
*/
|
||||
public static function send_activity( Post $activitypub_post, $activity_type ) {
|
||||
// check if a migration is needed before sending new posts
|
||||
\Activitypub\Migration::maybe_migrate();
|
||||
|
||||
// get latest version of post
|
||||
$user_id = $activitypub_post->get_post_author();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class Admin {
|
|||
public static function init() {
|
||||
\add_action( 'admin_menu', array( self::class, 'admin_menu' ) );
|
||||
\add_action( 'admin_init', array( self::class, 'register_settings' ) );
|
||||
\add_action( 'admin_init', array( self::class, 'schedule_migration' ) );
|
||||
\add_action( 'show_user_profile', array( self::class, 'add_profile' ) );
|
||||
\add_action( 'admin_enqueue_scripts', array( self::class, 'enqueue_scripts' ) );
|
||||
}
|
||||
|
@ -144,6 +145,12 @@ class Admin {
|
|||
);
|
||||
}
|
||||
|
||||
public static function schedule_migration() {
|
||||
if ( ! \wp_next_scheduled( 'activitypub_schedule_migration' ) ) {
|
||||
\wp_schedule_single_event( \time(), 'activitypub_schedule_migration' );
|
||||
}
|
||||
}
|
||||
|
||||
public static function add_settings_help_tab() {
|
||||
require_once \dirname( __FILE__ ) . '/help.php';
|
||||
}
|
||||
|
|
|
@ -9,6 +9,10 @@ class Migration {
|
|||
*/
|
||||
private static $target_version = '1.0.0';
|
||||
|
||||
public static function init() {
|
||||
\add_action( 'activitypub_schedule_migration', array( self::class, 'maybe_migrate' ) );
|
||||
}
|
||||
|
||||
public static function get_target_version() {
|
||||
return self::$target_version;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue