From 6bd48a163caa25fe38cb47c1846a224972327d40 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 5 Dec 2022 15:53:27 +0000 Subject: [PATCH] eddn: Ensure CAPI-sourced messages have uploaderID set If no 'live' Journal events yet, plugins/eddn won't have had an event to set this from. --- plugins/eddn.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index c7e36756..deb3fcc9 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -2409,7 +2409,7 @@ def journal_entry( # noqa: C901, CCR001 return None -def cmdr_data(data: CAPIData, is_beta: bool) -> Optional[str]: +def cmdr_data(data: CAPIData, is_beta: bool) -> Optional[str]: # noqa: CCR001 """ Process new CAPI data. @@ -2417,6 +2417,14 @@ def cmdr_data(data: CAPIData, is_beta: bool) -> Optional[str]: :param is_beta: bool - True if this is a beta version of the Game. :return: str - Error message, or `None` if no errors. """ + # 'Update' can trigger CAPI queries before plugins have been fed any + # Journal events. So this.cmdr_name might not be set otherwise. + if ( + not this.cmdr_name + and data.get('commander') and (cmdr_name := data['commander'].get('name')) + ): + this.cmdr_name = cmdr_name + if (data['commander'].get('docked') or (this.on_foot and monitor.station) and config.get_int('output') & config.OUT_EDDN_SEND_STATION_DATA): try: