Add "server" property to RegisteredPeerRecord class

This commit is contained in:
netkas 2024-12-24 00:46:20 -05:00
parent 830133d102
commit c85ca908f0
2 changed files with 169 additions and 147 deletions

View file

@ -2,6 +2,7 @@
<module type="WEB_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" /> <excludeFolder url="file://$MODULE_DIR$/.idea/dataSources" />
<excludeFolder url="file://$MODULE_DIR$/build" /> <excludeFolder url="file://$MODULE_DIR$/build" />
</content> </content>

View file

@ -4,7 +4,6 @@ namespace Socialbox\Objects\Database;
use DateTime; use DateTime;
use Socialbox\Classes\Configuration; use Socialbox\Classes\Configuration;
use Socialbox\Classes\Logger;
use Socialbox\Enums\Flags\PeerFlags; use Socialbox\Enums\Flags\PeerFlags;
use Socialbox\Interfaces\SerializableInterface; use Socialbox\Interfaces\SerializableInterface;
use Socialbox\Objects\Standard\SelfUser; use Socialbox\Objects\Standard\SelfUser;
@ -13,6 +12,7 @@ class RegisteredPeerRecord implements SerializableInterface
{ {
private string $uuid; private string $uuid;
private string $username; private string $username;
private string $server;
private ?string $displayName; private ?string $displayName;
/** /**
* @var PeerFlags[] * @var PeerFlags[]
@ -31,6 +31,7 @@ class RegisteredPeerRecord implements SerializableInterface
{ {
$this->uuid = $data['uuid']; $this->uuid = $data['uuid'];
$this->username = $data['username']; $this->username = $data['username'];
$this->server = $data['server'];
$this->displayName = $data['display_name'] ?? null; $this->displayName = $data['display_name'] ?? null;
if($data['flags']) if($data['flags'])
@ -74,6 +75,16 @@ class RegisteredPeerRecord implements SerializableInterface
return $this->username; return $this->username;
} }
/**
* Retrieves the server.
*
* @return string The server.
*/
public function getServer(): string
{
return $this->server;
}
/** /**
* Constructs and retrieves the peer address using the current instance's username and the domain from the configuration. * Constructs and retrieves the peer address using the current instance's username and the domain from the configuration.
* *
@ -133,6 +144,16 @@ class RegisteredPeerRecord implements SerializableInterface
return $this->created; return $this->created;
} }
/**
* Determines if the server is external.
*
* @return bool True if the server is external, false otherwise.
*/
public function isExternal(): bool
{
return $this->server === 'host';
}
/** /**
* Converts the current instance to a SelfUser object. * Converts the current instance to a SelfUser object.
* *