diff --git a/lib/Interfaces/Actor/PersonInterface.php b/lib/Interfaces/Actor/PersonInterface.php index 6e22a0da..48f36793 100644 --- a/lib/Interfaces/Actor/PersonInterface.php +++ b/lib/Interfaces/Actor/PersonInterface.php @@ -171,6 +171,5 @@ class PersonInterface implements IActivityPubInterface { $this->cacheActorsRequest->deleteFromId($item->getId()); } - } diff --git a/lib/Model/ActivityPub/ACore.php b/lib/Model/ActivityPub/ACore.php index 4f981840..7eb48a58 100644 --- a/lib/Model/ActivityPub/ACore.php +++ b/lib/Model/ActivityPub/ACore.php @@ -32,6 +32,7 @@ namespace OCA\Social\Model\ActivityPub; use daita\MySmallPhpTools\Traits\TArrayTools; use daita\MySmallPhpTools\Traits\TPathTools; +use daita\MySmallPhpTools\Traits\TStringTools; use JsonSerializable; use OCA\Social\Exceptions\ActivityCantBeVerifiedException; use OCA\Social\Exceptions\InvalidOriginException; @@ -45,6 +46,7 @@ class ACore extends Item implements JsonSerializable { use TArrayTools; + use TStringTools; use TPathTools; @@ -238,11 +240,7 @@ class ACore extends Item implements JsonSerializable { $base = $this->withoutEndSlash($this->withBeginSlash($base)); } - $uuid = sprintf( - '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) - ); + $uuid = $this->uuid(); $this->setId($url . $base . '/' . $uuid); } diff --git a/lib/Model/RequestQueue.php b/lib/Model/RequestQueue.php index afe0c1f5..a3fd0365 100644 --- a/lib/Model/RequestQueue.php +++ b/lib/Model/RequestQueue.php @@ -32,6 +32,7 @@ namespace OCA\Social\Model; use daita\MySmallPhpTools\Traits\TArrayTools; +use daita\MySmallPhpTools\Traits\TStringTools; use DateTime; use JsonSerializable; @@ -45,6 +46,7 @@ class RequestQueue implements JsonSerializable { use TArrayTools; + use TStringTools; const STATUS_STANDBY = 0; @@ -162,11 +164,7 @@ class RequestQueue implements JsonSerializable { * @return RequestQueue */ public function resetToken(): RequestQueue { - $uuid = sprintf( - '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) - ); + $uuid = $this->uuid(); $this->setToken($uuid); diff --git a/lib/Service/CacheDocumentService.php b/lib/Service/CacheDocumentService.php index 8f5c3fe0..cf861a2f 100644 --- a/lib/Service/CacheDocumentService.php +++ b/lib/Service/CacheDocumentService.php @@ -33,6 +33,7 @@ namespace OCA\Social\Service; use daita\MySmallPhpTools\Exceptions\MalformedArrayException; use daita\MySmallPhpTools\Model\Request; use daita\MySmallPhpTools\Traits\TArrayTools; +use daita\MySmallPhpTools\Traits\TStringTools; use Exception; use OCA\Social\Exceptions\CacheContentException; use OCA\Social\Exceptions\CacheContentMimeTypeException; @@ -52,6 +53,7 @@ class CacheDocumentService { use TArrayTools; + use TStringTools; /** @var IAppData */ @@ -103,11 +105,7 @@ class CacheDocumentService { */ public function saveRemoteFileToCache(string $url, &$mime = '') { - $filename = sprintf( - '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), - mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, - mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) - ); + $filename = $this->uuid(); // creating a path aa/bb/cc/dd/ from the filename aabbccdd-0123-[...] $path = chunk_split(substr($filename, 0, 8), 2, '/');