Renamed internal object names to represent a difference between standard objects and database records.
This commit is contained in:
parent
8e2e1eaba1
commit
dc15ce5bb9
16 changed files with 79 additions and 315 deletions
|
@ -54,7 +54,7 @@
|
|||
self::$configuration->setDefault('cache_system.cache.client_objects_ttl', 200);
|
||||
self::$configuration->setDefault('cache_system.cache.client_objects_server_preference', 'redis_master');
|
||||
self::$configuration->setDefault('cache_system.cache.client_objects_server_fallback', 'redis_slave');
|
||||
// Peer Objects
|
||||
// PeerRecord Objects
|
||||
self::$configuration->setDefault('cache_system.cache.peer_objects_enabled', true);
|
||||
self::$configuration->setDefault('cache_system.cache.peer_objects_ttl', 200);
|
||||
self::$configuration->setDefault('cache_system.cache.peer_objects_server_preference', 'redis_master');
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
use FederationLib\Exceptions\Standard\InvalidClientDescriptionException;
|
||||
use FederationLib\Exceptions\Standard\InvalidClientNameException;
|
||||
use FederationLib\Managers\ClientManager;
|
||||
use FederationLib\Objects\Client;
|
||||
use FederationLib\Objects\ClientRecord;
|
||||
use FederationLib\Objects\ResolvedIdentity;
|
||||
use FederationLib\Objects\Standard\ClientIdentity;
|
||||
use TamerLib\Enums\TamerMode;
|
||||
|
@ -197,14 +197,14 @@
|
|||
* Returns an existing client from the database
|
||||
*
|
||||
* @param ClientIdentity|null $identity
|
||||
* @param string|Client $client_uuid
|
||||
* @throws AccessDeniedException
|
||||
* @throws ClientNotFoundException
|
||||
* @param string|ClientRecord $client_uuid
|
||||
* @return Objects\Standard\Client
|
||||
*@throws ClientNotFoundException
|
||||
* @throws DatabaseException
|
||||
* @throws InternalServerException
|
||||
* @return Objects\Standard\Client
|
||||
* @throws AccessDeniedException
|
||||
*/
|
||||
public function getClient(?ClientIdentity $identity, string|Client $client_uuid): Objects\Standard\Client
|
||||
public function getClient(?ClientIdentity $identity, string|ClientRecord $client_uuid): Objects\Standard\Client
|
||||
{
|
||||
if(!$this->checkPermission(Methods::GET_CLIENT, $this->resolveIdentity($identity)))
|
||||
{
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace FederationLib\Interfaces;
|
||||
|
||||
use FederationLib\Objects\Client;
|
||||
use FederationLib\Objects\Peer;
|
||||
use FederationLib\Objects\ClientRecord;
|
||||
use FederationLib\Objects\PeerRecord;
|
||||
use FederationLib\Objects\Standard\PeerMetadata\TelegramUserMetadata;
|
||||
|
||||
interface PeerMetadataManagerInterface
|
||||
|
@ -12,27 +12,27 @@
|
|||
* Intelligently syncs the metadata of the given federated address, this will ignore raw metadata & use
|
||||
* data from the given $client_uuid
|
||||
*
|
||||
* @param Client|string $client_uuid
|
||||
* @param ClientRecord|string $client_uuid
|
||||
* @param TelegramUserMetadata $telegram_user_metadata
|
||||
* @return string
|
||||
*/
|
||||
public function syncMetadata(Client|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string;
|
||||
public function syncMetadata(ClientRecord|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string;
|
||||
|
||||
/**
|
||||
* Registers the metadata of the given federated address, this will ignore raw metadata & use data from the
|
||||
* given $client_uuid
|
||||
*
|
||||
* @param Client|string $client_uuid
|
||||
* @param ClientRecord|string $client_uuid
|
||||
* @param TelegramUserMetadata $telegram_user_metadata
|
||||
* @return string
|
||||
*/
|
||||
public function registerMetadata(Client|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string;
|
||||
public function registerMetadata(ClientRecord|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string;
|
||||
|
||||
/**
|
||||
* Returns the metadata of the given federated address, this returns the full raw metadata
|
||||
*
|
||||
* @param Peer|string $federated_address
|
||||
* @param PeerRecord|string $federated_address
|
||||
* @return TelegramUserMetadata
|
||||
*/
|
||||
public function getMetadata(Peer|string $federated_address): TelegramUserMetadata;
|
||||
public function getMetadata(PeerRecord|string $federated_address): TelegramUserMetadata;
|
||||
}
|
|
@ -19,7 +19,7 @@
|
|||
use FederationLib\Exceptions\Standard\InvalidClientNameException;
|
||||
use FederationLib\Exceptions\Standard\InvalidPermissionRoleException;
|
||||
use FederationLib\FederationLib;
|
||||
use FederationLib\Objects\Client;
|
||||
use FederationLib\Objects\ClientRecord;
|
||||
use LogLib\Log;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use TamerLib\Enums\TamerMode;
|
||||
|
@ -119,14 +119,14 @@
|
|||
/**
|
||||
* Returns an existing client from the database.
|
||||
*
|
||||
* @param string|Client $client_uuid
|
||||
* @return Client
|
||||
* @param string|ClientRecord $client_uuid
|
||||
* @return ClientRecord
|
||||
* @throws ClientNotFoundException
|
||||
* @throws DatabaseException
|
||||
*/
|
||||
public function getClient(string|Client $client_uuid): Client
|
||||
public function getClient(string|ClientRecord $client_uuid): ClientRecord
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -143,7 +143,7 @@
|
|||
|
||||
if($redis->exists($client_uuid))
|
||||
{
|
||||
$client = Client::fromArray($redis->hGetAll($client_uuid));
|
||||
$client = ClientRecord::fromArray($redis->hGetAll($client_uuid));
|
||||
Log::debug(Misc::FEDERATIONLIB, sprintf('Loaded client object %s from cache', $client_uuid));
|
||||
return $client;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@
|
|||
throw new ClientNotFoundException($client_uuid);
|
||||
}
|
||||
|
||||
$client = Client::fromArray($result->fetchAssociative());
|
||||
$client = ClientRecord::fromArray($result->fetchAssociative());
|
||||
}
|
||||
catch(ClientNotFoundException $e)
|
||||
{
|
||||
|
@ -211,16 +211,16 @@
|
|||
/**
|
||||
* Changes the name of a client.
|
||||
*
|
||||
* @param string|Client $client_uuid
|
||||
* @param string|ClientRecord $client_uuid
|
||||
* @param string|null $name
|
||||
* @return void
|
||||
* @throws ClientNotFoundException
|
||||
* @throws DatabaseException
|
||||
* @throws InvalidClientNameException
|
||||
*/
|
||||
public function changeClientName(string|Client $client_uuid, ?string $name=null): void
|
||||
public function changeClientName(string|ClientRecord $client_uuid, ?string $name=null): void
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -297,16 +297,16 @@
|
|||
/**
|
||||
* Changes the description of a client
|
||||
*
|
||||
* @param string|Client $client_uuid
|
||||
* @param string|ClientRecord $client_uuid
|
||||
* @param string|null $description
|
||||
* @return void
|
||||
* @throws ClientNotFoundException
|
||||
* @throws DatabaseException
|
||||
* @throws InvalidClientDescriptionException
|
||||
*/
|
||||
public function changeClientDescription(string|Client $client_uuid, ?string $description=null): void
|
||||
public function changeClientDescription(string|ClientRecord $client_uuid, ?string $description=null): void
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -377,16 +377,16 @@
|
|||
/**
|
||||
* Updates the permission role of a client.
|
||||
*
|
||||
* @param string|Client $client_uuid
|
||||
* @param string|ClientRecord $client_uuid
|
||||
* @param int $permission_role
|
||||
* @return void
|
||||
* @throws ClientNotFoundException
|
||||
* @throws DatabaseException
|
||||
* @throws InvalidPermissionRoleException
|
||||
*/
|
||||
public function changeClientPermissionRole(string|Client $client_uuid, int $permission_role): void
|
||||
public function changeClientPermissionRole(string|ClientRecord $client_uuid, int $permission_role): void
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -457,14 +457,14 @@
|
|||
/**
|
||||
* Updates a client's last seen timestamp.
|
||||
*
|
||||
* @param string|Client $uuid
|
||||
* @param string|ClientRecord $uuid
|
||||
* @return void
|
||||
* @throws DatabaseException
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function updateLastSeen(string|Client $uuid): void
|
||||
public function updateLastSeen(string|ClientRecord $uuid): void
|
||||
{
|
||||
if($uuid instanceof Client)
|
||||
if($uuid instanceof ClientRecord)
|
||||
{
|
||||
$uuid = $uuid->getUuid();
|
||||
}
|
||||
|
@ -593,7 +593,7 @@
|
|||
|
||||
while($row = $result->fetchAssociative())
|
||||
{
|
||||
$client_object = Client::fromArray($row);
|
||||
$client_object = ClientRecord::fromArray($row);
|
||||
|
||||
if($redis_client !== null)
|
||||
{
|
||||
|
@ -657,13 +657,13 @@
|
|||
/**
|
||||
* Deletes an existing client from the database.
|
||||
*
|
||||
* @param string|Client $uuid
|
||||
* @param string|ClientRecord $uuid
|
||||
* @return void
|
||||
* @throws DatabaseException
|
||||
*/
|
||||
public function deleteClient(string|Client $uuid): void
|
||||
public function deleteClient(string|ClientRecord $uuid): void
|
||||
{
|
||||
if($uuid instanceof Client)
|
||||
if($uuid instanceof ClientRecord)
|
||||
{
|
||||
$uuid = $uuid->getUuid();
|
||||
}
|
||||
|
|
|
@ -14,23 +14,23 @@
|
|||
use FederationLib\Exceptions\Standard\PeerMetadataNotFoundException;
|
||||
use FederationLib\Interfaces\PeerMetadataManagerInterface;
|
||||
use FederationLib\Managers\RedisConnectionManager;
|
||||
use FederationLib\Objects\Client;
|
||||
use FederationLib\Objects\Peer;
|
||||
use FederationLib\Objects\ClientRecord;
|
||||
use FederationLib\Objects\PeerRecord;
|
||||
use FederationLib\Objects\Standard\PeerMetadata\TelegramUserMetadata;
|
||||
use LogLib\Log;
|
||||
|
||||
class TelegramUserManager implements PeerMetadataManagerInterface
|
||||
{
|
||||
/**
|
||||
* @param Client|string $client_uuid
|
||||
* @param ClientRecord|string $client_uuid
|
||||
* @param TelegramUserMetadata $telegram_user_metadata
|
||||
* @return string
|
||||
* @throws DatabaseException
|
||||
* @throws InvalidPeerMetadataException
|
||||
*/
|
||||
public function syncMetadata(Client|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string
|
||||
public function syncMetadata(ClientRecord|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -126,14 +126,14 @@
|
|||
/**
|
||||
* Registers the client's metadata with the database
|
||||
*
|
||||
* @param Client|string $client_uuid
|
||||
* @param ClientRecord|string $client_uuid
|
||||
* @param TelegramUserMetadata $telegram_user_metadata
|
||||
* @return string
|
||||
* @throws DatabaseException
|
||||
*/
|
||||
public function registerMetadata(Client|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string
|
||||
public function registerMetadata(ClientRecord|string $client_uuid, TelegramUserMetadata $telegram_user_metadata): string
|
||||
{
|
||||
if($client_uuid instanceof Client)
|
||||
if($client_uuid instanceof ClientRecord)
|
||||
{
|
||||
$client_uuid = $client_uuid->getUuid();
|
||||
}
|
||||
|
@ -182,14 +182,14 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Peer|string $federated_address
|
||||
* @throws PeerMetadataNotFoundException
|
||||
* @throws DatabaseException
|
||||
* @param PeerRecord|string $federated_address
|
||||
* @return TelegramUserMetadata
|
||||
*@throws DatabaseException
|
||||
* @throws PeerMetadataNotFoundException
|
||||
*/
|
||||
public function getMetadata(Peer|string $federated_address): TelegramUserMetadata
|
||||
public function getMetadata(PeerRecord|string $federated_address): TelegramUserMetadata
|
||||
{
|
||||
if($federated_address instanceof Peer)
|
||||
if($federated_address instanceof PeerRecord)
|
||||
{
|
||||
$federated_address = $federated_address->getFederatedAddress();
|
||||
}
|
||||
|
@ -243,7 +243,7 @@
|
|||
|
||||
if($result->rowCount() === 0)
|
||||
{
|
||||
throw new PeerMetadataNotFoundException(sprintf('Peer metadata not found for federated address %s', $federated_address));
|
||||
throw new PeerMetadataNotFoundException(sprintf('PeerRecord metadata not found for federated address %s', $federated_address));
|
||||
}
|
||||
|
||||
$telegram_user_metadata = TelegramUserMetadata::fromArray($result->fetchAssociative(), true);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use FederationLib\Enums\Standard\UserPeerType;
|
||||
use FederationLib\FederationLib;
|
||||
use FederationLib\Interfaces\PeerMetadataInterface;
|
||||
use FederationLib\Interfaces\PeerMetadataManagerInterface;
|
||||
use FederationLib\Objects\Standard\PeerMetadata\TelegramUserMetadata;
|
||||
|
||||
|
@ -29,4 +30,9 @@
|
|||
$this->federationLib = $federationLib;
|
||||
$this->metadata_managers[UserPeerType::TELEGRAM_USER] = new TelegramUserMetadata();
|
||||
}
|
||||
|
||||
public function registerPeer(string $federated_address, PeerMetadataInterface $peer_metadata): void
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@
|
|||
use FederationLib\Enums\Standard\PermissionRole;
|
||||
use FederationLib\Interfaces\SerializableObjectInterface;
|
||||
|
||||
class Client implements SerializableObjectInterface
|
||||
class ClientRecord implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -238,9 +238,9 @@
|
|||
* Constructs object from an array representation.
|
||||
*
|
||||
* @param array $array
|
||||
* @return Client
|
||||
* @return ClientRecord
|
||||
*/
|
||||
public static function fromArray(array $array): Client
|
||||
public static function fromArray(array $array): ClientRecord
|
||||
{
|
||||
$client = new self();
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace FederationLib\Objects;
|
||||
|
||||
class InvokeResults
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $exit_code;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $output;
|
||||
|
||||
/**
|
||||
* InvokeResults constructor.
|
||||
*
|
||||
* @param int $exit_code
|
||||
* @param string $output
|
||||
*/
|
||||
public function __construct(int $exit_code, string $output)
|
||||
{
|
||||
$this->exit_code = $exit_code;
|
||||
$this->output = $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exit code of the command.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getExitCode(): int
|
||||
{
|
||||
return $this->exit_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the output of the command.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOutput(): string
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
use FederationLib\Interfaces\SerializableObjectInterface;
|
||||
|
||||
class Peer implements SerializableObjectInterface
|
||||
class PeerRecord implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -120,9 +120,9 @@
|
|||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $array
|
||||
* @return Peer
|
||||
* @return PeerRecord
|
||||
*/
|
||||
public static function fromArray(array $array): Peer
|
||||
public static function fromArray(array $array): PeerRecord
|
||||
{
|
||||
$object = new self();
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace FederationLib\Objects;
|
||||
|
||||
class QueryDocument
|
||||
{
|
||||
private $subject_type;
|
||||
private $client_id;
|
||||
private $client_totp_signature;
|
||||
private $timstamp;
|
||||
|
||||
private $platform;
|
||||
private $event_type;
|
||||
private $channel_peer;
|
||||
private $resent_from_peer;
|
||||
private
|
||||
}
|
|
@ -9,12 +9,12 @@
|
|||
class ResolvedIdentity
|
||||
{
|
||||
/**
|
||||
* @var Client|null
|
||||
* @var ClientRecord|null
|
||||
*/
|
||||
private $client;
|
||||
|
||||
/**
|
||||
* @var Peer|null
|
||||
* @var PeerRecord|null
|
||||
*/
|
||||
private $peer;
|
||||
|
||||
|
@ -26,10 +26,10 @@
|
|||
/**
|
||||
* ResolvedIdentity constructor.
|
||||
*
|
||||
* @param Client|null $client
|
||||
* @param Peer|null $peer
|
||||
* @param ClientRecord|null $client
|
||||
* @param PeerRecord|null $peer
|
||||
*/
|
||||
public function __construct(?Client $client, ?Peer $peer=null, bool $allow_root=false)
|
||||
public function __construct(?ClientRecord $client, ?PeerRecord $peer=null, bool $allow_root=false)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->peer = $peer;
|
||||
|
@ -73,17 +73,17 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* @return Client|null
|
||||
* @return ClientRecord|null
|
||||
*/
|
||||
public function getClient(): ?Client
|
||||
public function getClient(): ?ClientRecord
|
||||
{
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Peer|null
|
||||
* @return PeerRecord|null
|
||||
*/
|
||||
public function getPeer(): ?Peer
|
||||
public function getPeer(): ?PeerRecord
|
||||
{
|
||||
return $this->peer;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace FederationLib\Objects\Standard;
|
||||
|
||||
use FederationLib\Interfaces\SerializableObjectInterface;
|
||||
use FederationLib\Objects\ClientRecord;
|
||||
|
||||
class Client implements SerializableObjectInterface
|
||||
{
|
||||
|
@ -51,9 +52,9 @@
|
|||
/**
|
||||
* Client constructor.
|
||||
*
|
||||
* @param \FederationLib\Objects\Client|null $client
|
||||
* @param ClientRecord|null $client
|
||||
*/
|
||||
public function __construct(?\FederationLib\Objects\Client $client=null)
|
||||
public function __construct(?ClientRecord $client=null)
|
||||
{
|
||||
if($client === null)
|
||||
{
|
||||
|
|
|
@ -1,176 +0,0 @@
|
|||
<?php
|
||||
|
||||
/** @noinspection PhpMissingFieldTypeInspection */
|
||||
|
||||
namespace FederationLib\Objects\Standard;
|
||||
|
||||
use FederationLib\Interfaces\SerializableObjectInterface;
|
||||
|
||||
class Peer implements SerializableObjectInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $federated_address;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $client_first_seen;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $client_last_seen;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $active_restriction;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $permission_role;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $discovered_timestamp;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $seen_timestamp;
|
||||
|
||||
/**
|
||||
* Peer constructor.
|
||||
*
|
||||
* @param \FederationLib\Objects\Peer|null $peer
|
||||
*/
|
||||
public function __construct(?\FederationLib\Objects\Peer $peer=null)
|
||||
{
|
||||
if($peer === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->federated_address = $peer->getFederatedAddress();
|
||||
$this->client_first_seen = $peer->getClientFirstSeen();
|
||||
$this->client_last_seen = $peer->getClientLastSeen();
|
||||
$this->active_restriction = $peer->getActiveRestriction();
|
||||
$this->permission_role = $peer->getPermissionRole();
|
||||
$this->discovered_timestamp = $peer->getDiscoveredTimestamp();
|
||||
$this->seen_timestamp = $peer->getSeenTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the federated address of the peer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFederatedAddress(): string
|
||||
{
|
||||
return $this->federated_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Client UUID that first saw the peer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClientFirstSeen(): string
|
||||
{
|
||||
return $this->client_first_seen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Client UUID that last saw the peer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getClientLastSeen(): string
|
||||
{
|
||||
return $this->client_last_seen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Returns the ID of the active restriction applied to the peer
|
||||
* if null, no restriction is applied
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getActiveRestriction(): ?string
|
||||
{
|
||||
return $this->active_restriction;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the permission role of the peer
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPermissionRole(): int
|
||||
{
|
||||
return $this->permission_role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of when the peer was discovered by the client
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDiscoveredTimestamp(): int
|
||||
{
|
||||
return $this->discovered_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timestamp of when the peer was last seen by the client
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSeenTimestamp(): int
|
||||
{
|
||||
return $this->seen_timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'federated_address' => $this->federated_address,
|
||||
'client_first_seen' => $this->client_first_seen,
|
||||
'client_last_seen' => $this->client_last_seen,
|
||||
'active_restriction' => $this->active_restriction,
|
||||
'permission_role' => $this->permission_role,
|
||||
'discovered_timestamp' => $this->discovered_timestamp,
|
||||
'seen_timestamp' => $this->seen_timestamp
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs object from an array representation
|
||||
*
|
||||
* @param array $array
|
||||
* @return Peer
|
||||
*/
|
||||
public static function fromArray(array $array): Peer
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->federated_address = $array['federated_address'];
|
||||
$object->client_first_seen = $array['client_first_seen'];
|
||||
$object->client_last_seen = $array['client_last_seen'];
|
||||
$object->active_restriction = $array['active_restriction'];
|
||||
$object->permission_role = $array['permission_role'];
|
||||
$object->discovered_timestamp = $array['discovered_timestamp'];
|
||||
$object->seen_timestamp = $array['seen_timestamp'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client = new \FederationLib\Objects\ClientRecord();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
|
||||
$uuid = $federationlib->getClientManager()->registerClient($client);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
import('net.nosial.federationlib');
|
||||
$federationlib = new \FederationLib\FederationLib();
|
||||
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client = new \FederationLib\Objects\ClientRecord();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
|
||||
$uuid = $federationlib->getClientManager()->registerClient($client);
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// loop 50 times to create 50 clients
|
||||
for($i = 0; $i < 50; $i++)
|
||||
{
|
||||
$client = new \FederationLib\Objects\Client();
|
||||
$client = new \FederationLib\Objects\ClientRecord();
|
||||
$client->setDescription('This is a test client generated by a test script.');
|
||||
$client->enableAuthentication();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue