Commands for a Namjai server
Two commands for developers that send data to a Namjai server; you do not need them to read your WhatsApp.
Both read their settings as the other commands do, the environment first and then the settings file (see Settings). A missing setting prints nj: configuration: and one line per problem, and exits with 2. A send that fails prints the error, after the count lines, and exits with 1.
wp sync
Send the chats marked client to a Namjai server.
Reads the new messages of the chats listed in NAMJAI_WHATSAPP_CLIENT_CHATS, and only those, puts them in a sealed outbox, and sends them to the server. With the list empty it reads no chat and sends nothing. It remembers how far it read in NAMJAI_STATE_DIR, with a device ID it makes on its first run. Only one sync runs at a time: a second one prints another sync is running on this computer and does nothing. It takes no words: nj wp sync: does not take words, got "extra" and See: nj help, exit code 2. It never follows a redirect: when the server answers with one, nothing goes to the other address, the messages stay in the outbox and it exits with 1, so set NAMJAI_SERVER to the server's own address. demo send does the same.
| Option | Default | Accepted values | What it does |
|---|---|---|---|
--server URL | NAMJAI_SERVER | an http or https address | The server to send to. |
It needs NAMJAI_SERVER (or --server), NAMJAI_ENV, NAMJAI_OUTBOX_KEY, NAMJAI_WHATSAPP_STORE, NAMJAI_WHATSAPP_ACCOUNT, NAMJAI_STATE_DIR and NAMJAI_TIME_ZONE; nj setup saves all but the server and the account. With none set, on a Mac where setup was run:
nj wp syncnj: configuration: NAMJAI_SERVER is not set and no --server was given NAMJAI_WHATSAPP_ACCOUNT must be the salesperson's own WhatsApp number in E.164, such as +999812345678
Printed on success (from the program's code, not a captured run), one line each, with the real numbers:
| Line | Means |
|---|---|
chats_in_store= | Chats in WhatsApp's file |
chats_marked_client= | Chats in the client list |
chats_marked_client_found= | How many of those WhatsApp holds |
chats_never_read= | Chats in the file that were not read: all but the client chats found |
chats_read_again= | Client chats read again from their first message because WhatsApp's file is not the one the last run read, as after a reinstall or a restore. The server keeps each message once |
messages_read= | Messages of client chats read this run |
events_queued= | How many became events in the outbox |
messages_not_sent= | Messages read that became no event |
messages_not_sent_by_reason= | The same, by reason, such as kind_15:1 for a kind not sent yet, empty_text, no_message_id or no_date, separated by commas |
events_sent= | Events offered to the server, including what an earlier run left in the outbox |
events_new= | Events the server stored for the first time |
events_duplicate= | Events the server already held |
outbox_set_aside= | Outbox items moved, still sealed and never sent, to the set-aside folder inside the outbox because they cannot be opened with NAMJAI_OUTBOX_KEY or read. The run sends everything else. Put the old key back and run again to send the ones the old key opens |
outbox_left= | Items still in the outbox, to be sent next run |
demo send
Send a made-up demo call and conversation to a Namjai server, to test the server. It reads nothing from WhatsApp.
| Option | Default | Accepted values | What it does |
|---|---|---|---|
--server URL | NAMJAI_SERVER | an http or https address | The server to send to. |
--seed n | 1 | a whole number | Which made-up scenario; the same seed sends the same content. |
--account number | +99900000101 | a number with + and the country code | The salesperson's own number in the demo. |
--device id | demo-device-0001 | text | The device ID sent with every call to the server. |
It needs NAMJAI_SERVER (or --server), NAMJAI_ENV and NAMJAI_OUTBOX_KEY. NAMJAI_OUTBOX_DIR is used when set; otherwise a new temporary folder, removed when everything was confirmed. A value --seed cannot read prints nj demo send: --seed must be a whole number, got "x"; words print nj demo send: does not take words, got "extra"; each is followed by See: nj help and exits with 2. With no server set:
nj demo sendnj: configuration: NAMJAI_SERVER is not set and no --server was given
Printed on success (from the program's code, not a captured run):
| Line | Means |
|---|---|
batch_id= | The ID of the batch sent |
conversation_id= | The demo conversation's ID |
call_conversation_id= | The demo call's ID |
events_sent= | Events the batch carried |
events_new= | Events the server stored for the first time |
events_duplicate= | Events the server already held |
media_uploaded= | Files sent through the upload address |
media_new= | Files stored for the first time |
media_in_raw_store= | Files the server confirmed it keeps; only those leave the outbox |
bytes_uploaded= | Bytes of files offered to the server |
outbox_left= | Items still in the outbox |
When some items are not confirmed, it also prints nj demo send: and how many unconfirmed items stay in the outbox, and where.