1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2025-02-24 15:10:44 +00:00

Merge pull request #2546 from pixelfed/staging

Update Helpers, cache profiles
This commit is contained in:
daniel 2021-01-07 00:28:58 -07:00 committed by GitHub
commit 1847577d1b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 58 deletions

View file

@ -153,6 +153,7 @@
- Updated Follower model, increase hourly limit from 30 to 150. ([b9b84e6f](https://github.com/pixelfed/pixelfed/commit/b9b84e6f))
- Updated StatusController, fix scope bug. ([7dc3739c](https://github.com/pixelfed/pixelfed/commit/7dc3739c))
- Updated AP helpers, fixed federation bug. ([a52564f3](https://github.com/pixelfed/pixelfed/commit/a52564f3))
- Updated Helpers, cache profiles. ([1f672ecf](https://github.com/pixelfed/pixelfed/commit/1f672ecf))
## [v0.10.9 (2020-04-17)](https://github.com/pixelfed/pixelfed/compare/v0.10.8...v0.10.9)
### Added

View file

@ -403,9 +403,13 @@ class Helpers {
public static function profileFirstOrNew($url, $runJobs = false)
{
$url = self::validateUrl($url);
if($url == false) {
abort(400, 'Invalid url');
if($url == false || strlen($url) > 190) {
return;
}
$hash = base64_encode($url);
$key = 'ap:profile:by_url:' . $hash;
$ttl = now()->addMinutes(5);
$profile = Cache::remember($key, $ttl, function() use($url, $runJobs) {
$host = parse_url($url, PHP_URL_HOST);
$local = config('pixelfed.domain.app') == $host ? true : false;
@ -436,6 +440,7 @@ class Helpers {
$profile = Profile::whereRemoteUrl($res['id'])->first();
if(!$profile) {
$profile = DB::transaction(function() use($domain, $webfinger, $res, $runJobs) {
$profile = new Profile();
$profile->domain = strtolower($domain);
$profile->username = strtolower(Purify::clean($webfinger));
@ -454,6 +459,8 @@ class Helpers {
// RemoteFollowImportRecent::dispatch($res, $profile);
CreateAvatar::dispatch($profile);
}
return $profile;
});
} else {
// Update info after 24 hours
if($profile->last_fetched_at == null ||
@ -467,6 +474,8 @@ class Helpers {
}
}
return $profile;
});
return $profile;
}
public static function profileFetch($url)