From 4bee8397e0ee1371407b496e496cdd27d7139e67 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sat, 13 Jun 2020 00:21:41 -0600 Subject: [PATCH] Update AP Helpers, update bio + name --- app/Util/ActivityPub/Helpers.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/Util/ActivityPub/Helpers.php b/app/Util/ActivityPub/Helpers.php index b748598b3..ef13e7b70 100644 --- a/app/Util/ActivityPub/Helpers.php +++ b/app/Util/ActivityPub/Helpers.php @@ -131,6 +131,10 @@ class Helpers { public static function validateUrl($url) { + if(is_array($url)) { + $url = $url[0]; + } + $localhosts = [ '127.0.0.1', 'localhost', '::1' ]; @@ -433,6 +437,16 @@ class Helpers { // RemoteFollowImportRecent::dispatch($res, $profile); CreateAvatar::dispatch($profile); } + } else { + // Update info after 24 hours + if($profile->last_fetched_at == null || + $profile->last_fetched_at->lt(now()->subHours(24)) == true + ) { + $profile->name = isset($res['name']) ? Purify::clean($res['name']) : 'user'; + $profile->bio = isset($res['summary']) ? Purify::clean($res['summary']) : null; + $profile->last_fetched_at = now(); + $profile->save(); + } } return $profile; }