Send Delete for all actors on plugin uninstall
This commit is contained in:
parent
baf1378b45
commit
6a693cd806
@ -294,20 +294,22 @@ function migration_1_2_1() {
|
||||
|
||||
function purge_all_data() {
|
||||
global $wpdb;
|
||||
$blog_actor = \pterotype\actors\get_actor_by_slug( PTEROTYPE_BLOG_ACTOR_SLUG );
|
||||
$delete = \pterotype\activities\delete\make_delete(
|
||||
PTEROTYPE_BLOG_ACTOR_SLUG, $blog_actor
|
||||
);
|
||||
$delete['to'] = array(
|
||||
'https://www.w3.org/ns/activitystreams#Public',
|
||||
$blog_actor['followers']
|
||||
);
|
||||
$server = \rest_get_server();
|
||||
$request = \WP_REST_Request::from_url( $blog_actor['outbox'] );
|
||||
$request->set_method( 'POST' );
|
||||
$request->set_body( wp_json_encode( $delete ) );
|
||||
$request->add_header( 'Content-Type', 'application/ld+json' );
|
||||
$server->dispatch( $request );
|
||||
$actors = \pterotype\actors\get_all_actors();
|
||||
foreach ( $actors as $slug => $actor ) {
|
||||
$delete = \pterotype\activities\delete\make_delete(
|
||||
$slug, $actor
|
||||
);
|
||||
$delete['to'] = array(
|
||||
'https://www.w3.org/ns/activitystreams#Public',
|
||||
$actor['followers']
|
||||
);
|
||||
$server = \rest_get_server();
|
||||
$request = \WP_REST_Request::from_url( $actor['outbox'] );
|
||||
$request->set_method( 'POST' );
|
||||
$request->set_body( wp_json_encode( $delete ) );
|
||||
$request->add_header( 'Content-Type', 'application/ld+json' );
|
||||
$server->dispatch( $request );
|
||||
}
|
||||
$pfx = $wpdb->prefix;
|
||||
$wpdb->query( $wpdb->prepare(
|
||||
"DROP INDEX OBJECTS_ACTIVITYPUB_ID_INDEX ON {$pfx}pterotype_objects"
|
||||
|
@ -12,6 +12,22 @@ function get_actor( $id ) {
|
||||
return get_actor_from_row( $row );
|
||||
}
|
||||
|
||||
function get_all_actors() {
|
||||
global $wpdb;
|
||||
$results = $wpdb->get_results( $wpdb->prepare(
|
||||
"SELECT * FROM {$wpdb->prefix}pterotype_actors"
|
||||
) );
|
||||
if ( ! $results || empty( $results ) ) {
|
||||
return array();
|
||||
}
|
||||
$actors = array();
|
||||
foreach ( $results as $row ) {
|
||||
$actor = get_actor_from_row( $row );
|
||||
$actors[$row->slug] = $actor;
|
||||
}
|
||||
return $actors;
|
||||
}
|
||||
|
||||
function get_actor_by_slug ( $slug ) {
|
||||
global $wpdb;
|
||||
$row = $wpdb->get_row( $wpdb->prepare(
|
||||
|
Loading…
Reference in New Issue
Block a user