devlikeapro / waha

WAHA - WhatsApp HTTP API (REST API) that you can configure in a click! Two engines: chromium-based WEBJS and pure-websocket NOWEB
https://waha.devlike.pro/
Apache License 2.0
1.02k stars 310 forks source link

[PLUS] - WEBJS - Issue with retrieving user messages #122

Closed mehmetcoskun closed 1 year ago

mehmetcoskun commented 1 year ago
{
  "statusCode": 500,
  "timestamp": "2023-06-22T13:31:36.032Z",
  "exception": {
    "stack": "Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'mediaStage')\n    at __puppeteer_evaluation_script__:6:31\n    at ExecutionContext._evaluateInternal (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async ExecutionContext.evaluate (/app/node_modules/whatsapp-web.js/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)\n    at async Message.downloadMedia (/app/node_modules/whatsapp-web.js/src/structures/Message.js:393:24)\n    at async WhatsappSessionWebJSPlus.getMessages (/app/dist/core/session.webjs.core.js:131:25)\n    at async /app/node_modules/@nestjs/core/router/router-execution-context.js:46:28\n    at async /app/node_modules/@nestjs/core/router/router-proxy.js:9:17",
    "message": "Evaluation failed: TypeError: Cannot read properties of undefined (reading 'mediaStage')\n    at __puppeteer_evaluation_script__:6:31",
    "name": "Error"
  },
  "request": {
    "path": "/api/messages?chatId=905555555555%40c.us&limit=100&session=default",
    "method": "GET",
    "body": {},
    "query": {
      "chatId": "905555555555@c.us",
      "limit": "100",
      "session": "default"
    }
  },
  "version": {
    "version": "2023.6.9",
    "tier": "PLUS",
    "browser": "/usr/bin/chromium"
  }
}

Still get error while getting media

allburov commented 1 year ago

Original issue - https://github.com/devlikeapro/whatsapp-http-api/issues/106

allburov commented 1 year ago

Hi! I've finally found the issue - we'll skip revoked messages from now when downloading media from it.

Also added new parameter downloadMedia to the endpoint, so you can skip downloading media if you don't use it at all

Get 100 messages from the chat, skip downloading media (images, files) - GET /api/{session}/chats/{chatId}/messages?limit=100&downloadMedia=false

The same parameter's available in old endpoint too GET /api/messages