diff --git a/src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php b/src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php index d82e2bc..6f1ce3c 100644 --- a/src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php +++ b/src/Compatibility/FlarumTags/FlarumTagsPurgeMiddleware.php @@ -43,6 +43,7 @@ protected function processPurge( return $response; } + $response->getBody()->rewind(); $payload = $response->getBody()->getContents(); $payload = json_decode($payload, true); diff --git a/src/Middleware/LSCachePurgeMiddleware.php b/src/Middleware/LSCachePurgeMiddleware.php index 3136adf..74730e8 100644 --- a/src/Middleware/LSCachePurgeMiddleware.php +++ b/src/Middleware/LSCachePurgeMiddleware.php @@ -43,6 +43,23 @@ protected function processPurge( if (($isPostUpdate && Arr::has($body, 'data.attributes.isHidden')) || ! $isPostUpdate) { array_push($purgeParams, 'tag=default', 'tag=index', 'tag=discussions.index'); } + + // User profile cache + $response->getBody()->rewind(); + $payload = json_decode($response->getBody()->getContents(), true); + + if (isset($payload, $payload['included'])) { + $userData = Arr::first($payload['included'], fn($value, $key) => $value['type'] === 'users'); + if ($userData) { + $userId = $userData['id']; + $userName = Arr::get($userData, 'attributes.username'); + + array_push( + $purgeParams, + "tag=user_$userId", "tag=user_$userName", "tag=users_$userId", "tag=users_$userName" + ); + } + } } if ($isPost) {