Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix: infra-status storage path + SDK timestamp & PHP type accuracy (#472)

Yudhi Armyndhariseb1be2b784fc
diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.ts
index 228c318ac..b98076f1c 100644
--- a/sdk/javascript/src/types.ts
+++ b/sdk/javascript/src/types.ts
@@ -87,7 +87,7 @@ export interface SessionStatsOverview {
/** Returned by every send operation. */
export interface MessageResponse {
messageId: string;
- /** Unix timestamp in milliseconds. */
+ /** Unix timestamp in seconds. */
timestamp: number;
}
@@ -191,7 +191,7 @@ export interface MessageRecord {
body?: string | null;
type: string;
direction: MessageDirection;
- /** Unix timestamp in milliseconds. */
+ /** Unix timestamp in seconds. */
timestamp?: number | null;
metadata?: Record<string, unknown> | null;
status: DeliveryStatus;
diff --git a/sdk/php/src/Client.php b/sdk/php/src/Client.php
index 0a37628dc..74980d50f 100644
--- a/sdk/php/src/Client.php
+++ b/sdk/php/src/Client.php
@@ -118,7 +118,7 @@ class Client
* @param mixed|null $body JSON-serializable request body.
* @return mixed Decoded JSON, or null for empty/204 responses.
*/
- public function request(string $method, string $path, array $query = [], $body = null)
+ public function request(string $method, string $path, array $query = [], mixed $body = null): mixed
{
return $this->http->request($method, $path, $query, $body);
}
diff --git a/src/modules/infra/infra.controller.spec.ts b/src/modules/infra/infra.controller.spec.ts
index 8dc13a32f..d3fe76504 100644
--- a/src/modules/infra/infra.controller.spec.ts
+++ b/src/modules/infra/infra.controller.spec.ts
@@ -618,6 +618,39 @@ describe('InfraController.getStatus engine (F7 — reads the real engine.puppete
});
});
+describe('InfraController.getStatus storage (reads the real storage.localPath key)', () => {
+ const buildController = (map: Record<string, unknown>) => {
+ const config = { get: (key: string, def?: unknown) => (key in map ? map[key] : def) };
+ const cache = { isAvailable: () => Promise.resolve(false) };
+ const ds = { isInitialized: true };
+ return new InfraController(
+ config as never,
+ ds as never,
+ ds as never,
+ {} as never,
+ {} as never,
+ cache as never,
+ {} as never,
+ {} as never,
+ );
+ };
+
+ it('reports the configured storage.localPath, not the ./uploads fallback', async () => {
+ // The bug: status read the non-existent `storage.path` key, so it always reported the
+ // `./uploads` fallback instead of the real path StorageService uses (`storage.localPath`).
+ const status = await buildController({
+ 'storage.type': 'local',
+ 'storage.localPath': '/srv/openwa/media',
+ }).getStatus();
+ expect(status.storage.path).toBe('/srv/openwa/media');
+ });
+
+ it('falls back to ./data/media (matching StorageService) when storage.localPath is unset', async () => {
+ const status = await buildController({ 'storage.type': 'local' }).getStatus();
+ expect(status.storage.path).toBe('./data/media');
+ });
+});
+
describe('InfraController.exportStorage keeps the export import-able and sweeps it', () => {
function buildController(storage: Partial<{ createExportStream: jest.Mock }>) {
return new InfraController(
diff --git a/src/modules/infra/infra.controller.ts b/src/modules/infra/infra.controller.ts
index a5034972d..efe204291 100644
--- a/src/modules/infra/infra.controller.ts
+++ b/src/modules/infra/infra.controller.ts
@@ -237,7 +237,9 @@ export class InfraController {
const redisConnected = await this.cacheService.isAvailable();
const storageType = this.configService.get<'local' | 's3'>('storage.type', 'local');
- const storagePath = this.configService.get<string>('storage.path', './uploads');
+ // Read the key StorageService actually uses (`storage.localPath`, default `./data/media`).
+ // The old `storage.path` key never existed, so status always reported the `./uploads` fallback.
+ const storagePath = this.configService.get<string>('storage.localPath', './data/media');
const engineType = this.configService.get<string>('engine.type', 'whatsapp-web.js');
// configuration.ts nests these under engine.puppeteer.{headless,args}; the old flat