Rename and add session update methods
This commit is contained in:
parent
a9a13f186c
commit
cd7be1c3b2
5 changed files with 58 additions and 21 deletions
|
@ -9,7 +9,8 @@ use Socialbox\Interfaces\SerializableInterface;
|
|||
class SessionRecord implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private ?string $authenticatedPeerUuid;
|
||||
private ?string $peerUuid;
|
||||
private bool $authenticated;
|
||||
private string $publicKey;
|
||||
private SessionState $state;
|
||||
private DateTime $created;
|
||||
|
@ -18,7 +19,8 @@ class SessionRecord implements SerializableInterface
|
|||
public function __construct(array $data)
|
||||
{
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->authenticatedPeerUuid = $data['authenticated_peer_uuid'] ?? null;
|
||||
$this->peerUuid = $data['peer_uuid'] ?? null;
|
||||
$this->authenticated = $data['authenticated'] ?? false;
|
||||
$this->publicKey = $data['public_key'];
|
||||
$this->created = $data['created'];
|
||||
$this->lastRequest = $data['last_request'];
|
||||
|
@ -38,9 +40,19 @@ class SessionRecord implements SerializableInterface
|
|||
return $this->uuid;
|
||||
}
|
||||
|
||||
public function getAuthenticatedPeerUuid(): ?string
|
||||
public function getPeerUuid(): ?string
|
||||
{
|
||||
return $this->authenticatedPeerUuid;
|
||||
return $this->peerUuid;
|
||||
}
|
||||
|
||||
public function isAuthenticated(): bool
|
||||
{
|
||||
if($this->peerUuid === null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->authenticated;
|
||||
}
|
||||
|
||||
public function getPublicKey(): string
|
||||
|
@ -72,7 +84,8 @@ class SessionRecord implements SerializableInterface
|
|||
{
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'authenticated_peer_uuid' => $this->authenticatedPeerUuid,
|
||||
'peer_uuid' => $this->peerUuid,
|
||||
'authenticated' => $this->authenticated,
|
||||
'public_key' => $this->publicKey,
|
||||
'state' => $this->state->value,
|
||||
'created' => $this->created,
|
||||
|
|
|
@ -10,6 +10,7 @@ use Socialbox\Objects\Database\RegisteredPeerRecord;
|
|||
class SelfUser implements SerializableInterface
|
||||
{
|
||||
private string $uuid;
|
||||
private bool $enabled;
|
||||
private string $address;
|
||||
private string $username;
|
||||
private ?string $displayName;
|
||||
|
@ -29,8 +30,9 @@ class SelfUser implements SerializableInterface
|
|||
if($data instanceof RegisteredPeerRecord)
|
||||
{
|
||||
$this->uuid = $data->getUuid();
|
||||
$this->enabled = $data->isEnabled();
|
||||
$this->username = $data->getUsername();
|
||||
$this->address =
|
||||
$this->address = $data->getAddress();
|
||||
$this->displayName = $data->getDisplayName();
|
||||
$this->flags = $data->getFlags();
|
||||
$this->created = $data->getCreated()->getTimestamp();
|
||||
|
@ -39,7 +41,9 @@ class SelfUser implements SerializableInterface
|
|||
}
|
||||
|
||||
$this->uuid = $data['uuid'];
|
||||
$this->enabled = $data['enabled'];
|
||||
$this->username = $data['username'];
|
||||
$this->address = $data['address'];
|
||||
$this->displayName = $data['display_name'] ?? null;
|
||||
|
||||
if(is_string($data['flags']))
|
||||
|
@ -77,6 +81,11 @@ class SelfUser implements SerializableInterface
|
|||
return $this->uuid;
|
||||
}
|
||||
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string The username of the user.
|
||||
|
@ -86,6 +95,11 @@ class SelfUser implements SerializableInterface
|
|||
return $this->username;
|
||||
}
|
||||
|
||||
public function getAddress(): string
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string|null The display name.
|
||||
|
@ -104,15 +118,6 @@ class SelfUser implements SerializableInterface
|
|||
return $this->flags;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEnabled(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return int The timestamp when the object was created.
|
||||
|
@ -143,7 +148,9 @@ class SelfUser implements SerializableInterface
|
|||
|
||||
return [
|
||||
'uuid' => $this->uuid,
|
||||
'enabled' => $this->enabled,
|
||||
'username' => $this->username,
|
||||
'address' => $this->address,
|
||||
'display_name' => $this->displayName,
|
||||
'flags' => $flags,
|
||||
'created' => $this->created
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue