do not use cache for new followers
This commit is contained in:
parent
084f108161
commit
758912da64
3 changed files with 13 additions and 9 deletions
|
@ -114,7 +114,7 @@ class Mention {
|
||||||
* @return string The Inbox-URL
|
* @return string The Inbox-URL
|
||||||
*/
|
*/
|
||||||
public static function get_inbox_by_mentioned_actor( $actor ) {
|
public static function get_inbox_by_mentioned_actor( $actor ) {
|
||||||
$metadata = get_remote_metadata_by_actor( $actor, true );
|
$metadata = get_remote_metadata_by_actor( $actor );
|
||||||
|
|
||||||
if ( \is_wp_error( $metadata ) ) {
|
if ( \is_wp_error( $metadata ) ) {
|
||||||
return $metadata;
|
return $metadata;
|
||||||
|
|
|
@ -100,7 +100,7 @@ class Scheduler {
|
||||||
$followers = Followers::get_outdated_followers();
|
$followers = Followers::get_outdated_followers();
|
||||||
|
|
||||||
foreach ( $followers as $follower ) {
|
foreach ( $followers as $follower ) {
|
||||||
$meta = get_remote_metadata_by_actor( $follower->get_actor() );
|
$meta = get_remote_metadata_by_actor( $follower->get_actor(), true );
|
||||||
|
|
||||||
if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
|
if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) {
|
||||||
$follower->set_error( $meta );
|
$follower->set_error( $meta );
|
||||||
|
@ -121,7 +121,7 @@ class Scheduler {
|
||||||
$followers = Followers::get_faulty_followers();
|
$followers = Followers::get_faulty_followers();
|
||||||
|
|
||||||
foreach ( $followers as $follower ) {
|
foreach ( $followers as $follower ) {
|
||||||
$meta = get_remote_metadata_by_actor( $follower->get_actor() );
|
$meta = get_remote_metadata_by_actor( $follower->get_actor(), true );
|
||||||
|
|
||||||
if ( is_tombstone( $meta ) ) {
|
if ( is_tombstone( $meta ) ) {
|
||||||
$follower->delete();
|
$follower->delete();
|
||||||
|
|
|
@ -54,11 +54,12 @@ function get_webfinger_resource( $user_id ) {
|
||||||
/**
|
/**
|
||||||
* Requests the Meta-Data from the Actors profile
|
* Requests the Meta-Data from the Actors profile
|
||||||
*
|
*
|
||||||
* @param string $actor The Actor URL
|
* @param string $actor The Actor URL.
|
||||||
|
* @param bool $cached If the result should be cached.
|
||||||
*
|
*
|
||||||
* @return array The Actor profile as array
|
* @return array The Actor profile as array
|
||||||
*/
|
*/
|
||||||
function get_remote_metadata_by_actor( $actor ) {
|
function get_remote_metadata_by_actor( $actor, $cached = true ) {
|
||||||
$pre = apply_filters( 'pre_get_remote_metadata_by_actor', false, $actor );
|
$pre = apply_filters( 'pre_get_remote_metadata_by_actor', false, $actor );
|
||||||
if ( $pre ) {
|
if ( $pre ) {
|
||||||
return $pre;
|
return $pre;
|
||||||
|
@ -75,11 +76,14 @@ function get_remote_metadata_by_actor( $actor ) {
|
||||||
return $actor;
|
return $actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
$transient_key = 'activitypub_' . $actor;
|
// only check the cache if needed.
|
||||||
$metadata = \get_transient( $transient_key );
|
if ( $cached ) {
|
||||||
|
$transient_key = 'activitypub_' . $actor;
|
||||||
|
$metadata = \get_transient( $transient_key );
|
||||||
|
|
||||||
if ( $metadata ) {
|
if ( $metadata ) {
|
||||||
return $metadata;
|
return $metadata;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! \wp_http_validate_url( $actor ) ) {
|
if ( ! \wp_http_validate_url( $actor ) ) {
|
||||||
|
|
Loading…
Reference in a new issue