Commit 5f0bdfaa authored by Emiliano Balbuena's avatar Emiliano Balbuena

(feat): Hydrate referrer

1 merge request!393(feat): Withdrawal status support
Pipeline #95662660 failed with stages
in 2 minutes and 50 seconds
......@@ -25,7 +25,11 @@ class RequestHydrationDelegate
return $request;
}
$user = new User($userGuid);
try {
$user = new User($userGuid);
} catch (Exception $exception) {
$user = null;
}
return $request
->setUser($user);
......@@ -33,10 +37,30 @@ class RequestHydrationDelegate
public function hydrateForAdmin(Request $request)
{
// TBD
if (!$request->getUser()) {
$request = $this->hydrate($request);
if (!$request->getUser()) {
return $request;
}
}
// TODO: Hydrate referrer
$referrerGuid = $request->getUser()->referrer;
return $request;
if (!$referrerGuid) {
return $request;
}
try {
$user = new User($referrerGuid);
} catch (Exception $exception) {
// Faux user in case of banned/deleted accounts
$user = new User();
$user->guid = $referrerGuid;
$user->username = $referrerGuid;
}
return $request
->setReferrer($user);
}
}
......@@ -28,6 +28,8 @@ use Minds\Traits\MagicAttributes;
* @method Request setTimestamp(int $timestamp)
* @method User|null getUser()
* @method Request setUser(User|null $user)
* @method User|null getReferrer()
* @method Request setReferrer(User|null $referrer)
*/
class Request implements JsonSerializable
{
......
Please register or to comment