Made message signing in Cryptography use SHA512 as the message content for... #1

Closed
netkas wants to merge 421 commits from master into dev
Showing only changes of commit 7eae62cfd8 - Show all commits

View file

@ -3,6 +3,7 @@
namespace Socialbox\Objects\Database; namespace Socialbox\Objects\Database;
use DateTime; use DateTime;
use InvalidArgumentException;
use Socialbox\Classes\Configuration; use Socialbox\Classes\Configuration;
use Socialbox\Enums\Flags\PeerFlags; use Socialbox\Enums\Flags\PeerFlags;
use Socialbox\Interfaces\SerializableInterface; use Socialbox\Interfaces\SerializableInterface;
@ -25,6 +26,7 @@
private ?array $flags; private ?array $flags;
private bool $enabled; private bool $enabled;
private DateTime $created; private DateTime $created;
private DateTime $updated;
/** /**
* Constructor for initializing class properties from provided data. * Constructor for initializing class properties from provided data.
@ -59,7 +61,7 @@
} }
else else
{ {
throw new \InvalidArgumentException("The birthday field must be a valid timestamp or date string."); throw new InvalidArgumentException("The birthday field must be a valid timestamp or date string.");
} }
if($data['flags']) if($data['flags'])
@ -87,7 +89,24 @@
} }
else else
{ {
throw new \InvalidArgumentException("The created field must be a valid timestamp or date string."); throw new InvalidArgumentException("The created field must be a valid timestamp or date string.");
}
if(!isset($data['updated']))
{
$this->updated = new DateTime();
}
elseif(is_int($data['updated']))
{
$this->updated = (new DateTime())->setTimestamp($data['updated']);
}
elseif(is_string($data['updated']))
{
$this->updated = new DateTime($data['updated']);
}
else
{
throw new InvalidArgumentException("The updated field must be a valid timestamp or date string.");
} }
} }
@ -235,6 +254,16 @@
return $this->created; return $this->created;
} }
/**
* Retrieves the last update date and time.
*
* @return DateTime The last update date and time.
*/
public function getUpdated(): DateTime
{
return $this->updated;
}
/** /**
* Determines if the user is considered external by checking if the username is 'host' and the server * Determines if the user is considered external by checking if the username is 'host' and the server
* is not the same as the domain from the configuration. * is not the same as the domain from the configuration.
@ -290,7 +319,8 @@
'birthday' => $this->birthday?->getTimestamp(), 'birthday' => $this->birthday?->getTimestamp(),
'flags' => PeerFlags::toString($this->flags), 'flags' => PeerFlags::toString($this->flags),
'enabled' => $this->enabled, 'enabled' => $this->enabled,
'created' => $this->created 'created' => $this->created,
'updated' => $this->updated
]; ];
} }
} }