capsulbrasil / zapmeow

Minimal overhead REST wrapper around WhatsApp protocol, powered by whatsmeow.
https://capsulbrasil.github.io/zapmeow/
33 stars 8 forks source link

failed to upgrade database: unable to open database file: no such file or directory #5

Closed monyuan closed 5 months ago

monyuan commented 5 months ago

failed to upgrade database: unable to open database file: no such file or directory

gabrielolivrp commented 5 months ago

This error is happening because the directory where the information is being stored does not exist, if you are using the settings from .env similar to those in .env.example:

DATABASE_PATH=.zapmeow/zapmeow.db
STORAGE_PATH=.zapmeow/storage

You can create the .zapmeow directory, or if you prefer, you can change it to some other existing directory of your choice.

monyuan commented 5 months ago

Thank you. I just have two more questions.

  1. when using a new Instance ID to get a QR code, the first time it always returns empty data

  2. Does the Send Message API support sending to multiple cell phone numbers at the same time?

gabrielolivrp commented 5 months ago
  1. This happens because instances are dynamically created according to the calls in the API, and on the first request, there is a validation to check if the instance exists and is connected to WhatsApp. If it is not, a routine is triggered to generate the QR codes and save them in the instances table. Since this is an asynchronous task, on the first call, the QR code in the database is empty because there hasn't been enough time to store the QR code yet.

https://github.com/capsulbrasil/zapmeow/blob/main/api/service/whatsapp_service.go#L120

However, this is indeed quite confusing. I will improve it by returning a status along with the QR code. When the QR code is still being generated, it will return a status of "waiting".

  1. Yes, it can be used to send messages to multiple cell phone numbers simultaneously. You will need to connect each cell phone number to an "instance", and when sending the message, specify in the URL which instance will be used for sending.