diff --git a/cloud/src/Ingest/IngestController.php b/cloud/src/Ingest/IngestController.php index bc9f8ed..18d35aa 100644 --- a/cloud/src/Ingest/IngestController.php +++ b/cloud/src/Ingest/IngestController.php @@ -36,13 +36,13 @@ final class IngestController return Response::json(['error' => 'unauthorized'], 401); } if (!Hmac::verify($secret, $nonce, $ts, $req->body(), $sig)) { - return Response::json(['error' => 'bad_signature'], 401); + return Response::json(['error' => 'unauthorized'], 401); } if (abs($now - (int)(float)$ts) > $this->cfg->timestampWindow()) { - return Response::json(['error' => 'stale_timestamp'], 401); + return Response::json(['error' => 'unauthorized'], 401); } if ($this->nonces->seen($nonce)) { - return Response::json(['error' => 'replay'], 401); + return Response::json(['error' => 'unauthorized'], 401); } $this->nonces->remember($nonce, $now + $this->cfg->nonceTtl()); @@ -54,7 +54,7 @@ final class IngestController $img = ImageProcessor::reencode((string)$b64); if (!$img['ok']) continue; $path = rtrim($this->cfg->snapshotDir(), '/\\') . '/' . $img['uuid'] . '.jpg'; - file_put_contents($path, $img['bytes']); + if (file_put_contents($path, $img['bytes']) === false) continue; $this->snapshots->add($eventId, $img['uuid'], $img['hash']); } return Response::json(['event_id' => $eventId], 201);