Skip to content

Commit

Permalink
fix(qchat): add type key check when receiving a message
Browse files Browse the repository at this point in the history
  • Loading branch information
gounux committed Nov 5, 2024
1 parent 76298ce commit b9b72ea
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions qtribu/logic/qchat_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit b9b72ea

Please sign in to comment.