diff --git a/app/Profile.php b/app/Profile.php index 86c83bf5e..7fba6bc9a 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -119,14 +119,16 @@ class Profile extends Model { return $this->hasOne(Avatar::class)->withDefault([ 'media_path' => 'public/avatars/default.png', + 'change_count' => 0 ]); } public function avatarUrl() { - $url = Cache::remember("avatar:{$this->id}", now()->addDays(1), function () { - $path = optional($this->avatar)->media_path; - $version = hash('sha1', $this->avatar->updated_at); + $url = Cache::remember("avatar:{$this->id}", now()->addYears(1), function () { + $avatar = $this->avatar; + $path = $avatar->media_path; + $version = hash('sha256', $avatar->change_count); $path = "{$path}?v={$version}"; return url(Storage::url($path)); diff --git a/app/Services/NotificationService.php b/app/Services/NotificationService.php index 15adf6c7c..cfe61cdad 100644 --- a/app/Services/NotificationService.php +++ b/app/Services/NotificationService.php @@ -16,11 +16,11 @@ class NotificationService { const CACHE_KEY = 'pf:services:notifications:ids:'; - public static function get($id, $start = 0, $stop = 300) + public static function get($id, $start = 0, $stop = 400) { $res = collect([]); $key = self::CACHE_KEY . $id; - $stop = $stop > 300 ? 300 : $stop; + $stop = $stop > 400 ? 400 : $stop; $ids = Redis::zrangebyscore($key, $start, $stop); if(empty($ids)) { $ids = self::coldGet($id, $start, $stop); @@ -31,9 +31,9 @@ class NotificationService { return $res; } - public static function coldGet($id, $start = 0, $stop = 300) + public static function coldGet($id, $start = 0, $stop = 400) { - $stop = $stop > 300 ? 300 : $stop; + $stop = $stop > 400 ? 400 : $stop; $ids = Notification::whereProfileId($id) ->latest() ->skip($start) @@ -72,7 +72,7 @@ class NotificationService { public static function getNotification($id) { - return Cache::remember('service:notification:'.$id, now()->addDays(7), function() use($id) { + return Cache::remember('service:notification:'.$id, now()->addMonths(3), function() use($id) { $n = Notification::with('item')->findOrFail($id); $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); @@ -83,7 +83,7 @@ class NotificationService { public static function setNotification(Notification $notification) { - return Cache::remember('service:notification:'.$notification->id, now()->addDays(7), function() use($notification) { + return Cache::remember('service:notification:'.$notification->id, now()->addMonths(3), function() use($notification) { $fractal = new Fractal\Manager(); $fractal->setSerializer(new ArraySerializer()); $resource = new Fractal\Resource\Item($notification, new NotificationTransformer()); @@ -91,7 +91,7 @@ class NotificationService { }); } - public static function warmCache($id, $stop = 100, $force = false) + public static function warmCache($id, $stop = 400, $force = false) { if(self::count($id) == 0 || $force == true) { $ids = Notification::whereProfileId($id) diff --git a/app/Transformer/Api/AccountTransformer.php b/app/Transformer/Api/AccountTransformer.php index 3e1b6d34b..2c6cbcd50 100644 --- a/app/Transformer/Api/AccountTransformer.php +++ b/app/Transformer/Api/AccountTransformer.php @@ -16,7 +16,7 @@ class AccountTransformer extends Fractal\TransformerAbstract 'acct' => $profile->username, 'display_name' => $profile->name, 'locked' => (bool) $profile->is_private, - 'created_at' => $profile->created_at->format('c'), + 'created_at' => null, 'followers_count' => $profile->followerCount(), 'following_count' => $profile->followingCount(), 'statuses_count' => $profile->statusCount(),