implement missing get_follower logic

This commit is contained in:
Matthias Pfefferle 2023-06-16 16:46:49 +02:00
parent 793214cea2
commit daf7acb1b0

View file

@ -235,7 +235,13 @@ class Followers {
public static function remove_follower( $user_id, $actor ) { public static function remove_follower( $user_id, $actor ) {
wp_cache_delete( sprintf( self::CACHE_KEY_INBOXES, $user_id ), 'activitypub' ); wp_cache_delete( sprintf( self::CACHE_KEY_INBOXES, $user_id ), 'activitypub' );
return wp_remove_object_terms( $user_id, $actor, self::POST_TYPE ); $follower = self::get_follower( $user_id, $actor );
if ( ! $follower ) {
return false;
}
return delete_post_meta( $follower->get_id(), 'user_id', $user_id );
} }
/** /**
@ -251,8 +257,12 @@ class Followers {
$post_id = $wpdb->get_var( $post_id = $wpdb->get_var(
$wpdb->prepare( $wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid=%s", "SELECT p.ID FROM $wpdb->posts p INNER JOIN $wpdb->postmeta pm ON p.ID = pm.post_id WHERE p.post_type = %s AND pm.meta_key = 'user_id' AND pm.meta_value = %d AND p.guid = %s",
esc_sql( $actor ) array(
esc_sql( self::POST_TYPE ),
esc_sql( $user_id ),
esc_sql( $actor ),
)
) )
); );