(result)
| 562 | } |
| 563 | |
| 564 | function normalizeValidateResult(result) { |
| 565 | const raw = record(result) || {}; |
| 566 | const status = typeof raw.status === 'number' ? raw.status : (raw.ok ? 200 : 0); |
| 567 | const body = raw.body; |
| 568 | if (!raw.ok) { |
| 569 | return { |
| 570 | ok: false, |
| 571 | status, |
| 572 | reason: stableReason(raw.reason, PUBLISH_FAILURE_REASONS) || hubReason(body) || ('hub ' + status), |
| 573 | body, |
| 574 | }; |
| 575 | } |
| 576 | const payload = record(body && body.payload); |
| 577 | const passed = Boolean(payload && (payload.valid === true || payload.ok === true)); |
| 578 | return { |
| 579 | ok: passed, |
| 580 | status, |
| 581 | reason: stringField(payload, 'reason') || stringField(payload, 'error'), |
| 582 | body, |
| 583 | }; |
| 584 | } |
| 585 | |
| 586 | async function postPublish(message, deps) { |
| 587 | if (deps.publish) return deps.publish(message); |
no test coverage detected