diff --git a/lib/Model/ActivityPub/Object/Note.php b/lib/Model/ActivityPub/Object/Note.php index 361ed872..0efb3ac4 100644 --- a/lib/Model/ActivityPub/Object/Note.php +++ b/lib/Model/ActivityPub/Object/Note.php @@ -33,7 +33,6 @@ namespace OCA\Social\Model\ActivityPub\Object; use DateTime; use JsonSerializable; use OCA\Social\Model\ActivityPub\ACore; -use OCA\Social\Service\SignatureService; class Note extends ACore implements JsonSerializable { @@ -195,7 +194,6 @@ class Note extends ACore implements JsonSerializable { */ public function convertPublished() { $dTime = new DateTime($this->getPublished()); - $dTime->format(SignatureService::DATE_FORMAT); $this->setPublishedTime($dTime->getTimestamp()); } diff --git a/lib/Service/SignatureService.php b/lib/Service/SignatureService.php index b59d8367..6ce7ddfc 100644 --- a/lib/Service/SignatureService.php +++ b/lib/Service/SignatureService.php @@ -65,7 +65,9 @@ class SignatureService { const ORIGIN_SIGNATURE = 2; - const DATE_FORMAT = 'D, d M Y H:i:s T'; + const DATE_HEADER = 'D, d M Y H:i:s T'; + const DATE_OBJECT = 'Y-m-d\TH:i:s\Z'; + const DATE_DELAY = 30; @@ -135,7 +137,7 @@ class SignatureService { * @throws SocialAppConfigException */ public function signRequest(Request $request, RequestQueue $queue) { - $date = gmdate(self::DATE_FORMAT); + $date = gmdate(self::DATE_HEADER); $path = $queue->getInstance(); $localActor = $this->actorsRequest->getFromId($queue->getAuthor()); @@ -178,7 +180,6 @@ class SignatureService { */ public function checkRequest(IRequest $request, int &$time = 0): string { $dTime = new DateTime($request->getHeader('date')); - $dTime->format(self::DATE_FORMAT); $time = $dTime->getTimestamp(); if ($time < (time() - self::DATE_DELAY)) { @@ -249,7 +250,7 @@ class SignatureService { $signature->setPrivateKey($actor->getPrivateKey()); $signature->setType('RsaSignature2017'); $signature->setCreator($actor->getId() . '#main-key'); - $signature->setCreated($object->getPublished()); + $signature->setCreated($date = gmdate(self::DATE_OBJECT)); $signature->setObject(json_decode(json_encode($object), true)); try {