Jelajahi Sumber

Update AP Helpers, update bio + name

Daniel Supernault 5 tahun lalu
induk
melakukan
4bee8397e0
1 mengubah file dengan 14 tambahan dan 0 penghapusan
  1. 14 0
      app/Util/ActivityPub/Helpers.php

+ 14 - 0
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;
 	}