From b9b72eab23263eaf4420afa25c12cb91e2d7e92d Mon Sep 17 00:00:00 2001 From: gounux Date: Tue, 5 Nov 2024 12:36:25 +0100 Subject: [PATCH] fix(qchat): add type key check when receiving a message --- qtribu/logic/qchat_websocket.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qtribu/logic/qchat_websocket.py b/qtribu/logic/qchat_websocket.py index 71f9d45d..d5613e07 100644 --- a/qtribu/logic/qchat_websocket.py +++ b/qtribu/logic/qchat_websocket.py @@ -3,6 +3,7 @@ from json import JSONEncoder from PyQt5 import QtWebSockets # noqa QGS103 +from qgis.core import Qgis from qgis.PyQt.QtCore import QObject, QUrl, pyqtSignal from qtribu.constants import ( @@ -107,6 +108,12 @@ def on_message_received(self, text: str) -> None: :param text: text message received, should be a jsonified string """ message = json.loads(text) + if "type" not in message: + self.log( + message="No 'type' key in received message. Please make sure your configured instance is running gischat v>=2.0.0", + log_level=Qgis.Critical, + ) + return msg_type = message["type"] if msg_type == QCHAT_MESSAGE_TYPE_UNCOMPLIANT: self.uncompliant_message_received.emit(QChatUncompliantMessage(**message))