From 9564d8ab4fda060df0779a42f1a9fddbf40a186a Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 28 Sep 2020 12:00:28 +0100 Subject: [PATCH] EDDN: Allow sending of empty market data for updating FCs. --- plugins/eddn.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index 5e7f27fe..7809cdd9 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -147,6 +147,13 @@ Headers\t{r.headers} Content:\n{r.text} Msg:\n{msg}''') + # Check if EDDN is still objecting to an empty commodities list + if r.status_code == 400 \ + and msg['$schemaRef'] == 'https://eddn.edcd.io/schemas/commodity/3' \ + and this.commodities == [] \ + and r.text == "FAIL: []": + logger.trace("EDDN is still objecting to empty commodities data") + r.raise_for_status() def sendreplay(self) -> None: @@ -238,7 +245,13 @@ Msg:\n{msg}''') commodities.sort(key=lambda c: c['name']) - if commodities and this.commodities != commodities: # Don't send empty commodities list - schema won't allow it + # This used to have a check `commodities and ` at the start so as to + # not send an empty commodities list, as the EDDN Schema doesn't allow + # it (as of 2020-09-28). + # BUT, Fleet Carriers can go from having buy/sell orders to having + # none and that really does need to be recorded over EDDN so that, e.g. + # EDDB can update in a timely manner. + if this.commodities != commodities: message: OrderedDictT[str, Any] = OrderedDict([ ('timestamp', data['timestamp']), ('systemName', data['lastSystem']['name']),