Refactor image job object, fixed image commands that don't require an existing image

This commit is contained in:
Essem 2021-12-09 22:31:52 -06:00
parent 30bcb7a969
commit 39ebae8cd7
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
5 changed files with 28 additions and 12 deletions

View file

@ -31,3 +31,18 @@ A client sends *requests* (T-messages) to a server, which subsequently *replies*
- Twait tag[2] jid[4]
- Rwait tag[2]
- Rinit tag[2] max_jobs[2] formats[j]
### Job Object
The job object is formatted like this:
```json
{
"cmd": string, // name of internal image command, e.g. caption
"path": string, // canonical image URL, used for getting the actual image
"url": string, // original image URL, used for message filtering
"params": { // content varies depending on the command, some common parameters are listed here
"type": string, // mime type of output, should usually be the same as input
"delay": integer, // for manually specifying GIF frame delay, set to 0 to use the default delay
...
}
}
```

View file

@ -241,7 +241,7 @@ const runJob = (job, ws) => {
const object = JSON.parse(job.msg);
// If the image has a path, it must also have a type
if (object.path && !object.type) {
if (object.path && !object.params.type) {
reject(new TypeError("Unknown image type"));
}