fail if get_remote_metadata_by_actor
returns error
because it is not even possible to send `Accept` or `Reject` response.
This commit is contained in:
parent
dea5f38561
commit
be0f25f3d3
1 changed files with 9 additions and 21 deletions
|
@ -212,16 +212,11 @@ class Followers {
|
||||||
public static function add_follower( $user_id, $actor ) {
|
public static function add_follower( $user_id, $actor ) {
|
||||||
$meta = get_remote_metadata_by_actor( $actor );
|
$meta = get_remote_metadata_by_actor( $actor );
|
||||||
|
|
||||||
$follower = new Follower( $actor );
|
if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
|
||||||
|
return $meta;
|
||||||
if ( is_tombstone( $meta ) ) {
|
|
||||||
return;
|
|
||||||
} if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
|
|
||||||
$follower->set_error( $meta );
|
|
||||||
} else {
|
|
||||||
$follower->from_meta( $meta );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$follower = new Follower( $actor );
|
||||||
$follower->upsert();
|
$follower->upsert();
|
||||||
|
|
||||||
$result = wp_set_object_terms( $user_id, $follower->get_actor(), self::TAXONOMY, true );
|
$result = wp_set_object_terms( $user_id, $follower->get_actor(), self::TAXONOMY, true );
|
||||||
|
@ -285,9 +280,11 @@ class Followers {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function send_follow_response( $actor, $object, $user_id, $follower ) {
|
public static function send_follow_response( $actor, $object, $user_id, $follower ) {
|
||||||
//if ( is_wp_error( $follower ) ) {
|
if ( is_wp_error( $follower ) ) {
|
||||||
// @todo send error message
|
// it is not even possible to send a "Reject" because
|
||||||
//}
|
// we can not get the Remote-Inbox
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $object['user_id'] ) ) {
|
if ( isset( $object['user_id'] ) ) {
|
||||||
unset( $object['user_id'] );
|
unset( $object['user_id'] );
|
||||||
|
@ -318,7 +315,7 @@ class Followers {
|
||||||
*
|
*
|
||||||
* @return array The Term list of Followers, the format depends on $output
|
* @return array The Term list of Followers, the format depends on $output
|
||||||
*/
|
*/
|
||||||
public static function get_followers( $user_id, $output = ARRAY_N, $number = null, $offset = null, $hide_errors = false, $args = array() ) {
|
public static function get_followers( $user_id, $output = ARRAY_N, $number = null, $offset = null, $args = array() ) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'taxonomy' => self::TAXONOMY,
|
'taxonomy' => self::TAXONOMY,
|
||||||
'hide_empty' => false,
|
'hide_empty' => false,
|
||||||
|
@ -329,15 +326,6 @@ class Followers {
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( true === $hide_errors ) {
|
|
||||||
$defaults['meta_query'] = array(
|
|
||||||
array(
|
|
||||||
'key' => 'errors',
|
|
||||||
'compare' => 'NOT EXISTS',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
$terms = new WP_Term_Query( $args );
|
$terms = new WP_Term_Query( $args );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue