Logs notify messages on server

This commit is contained in:
FinnStutzenstein 2019-10-04 11:58:07 +02:00
parent 50bd31a9a6
commit 9ae66fb33b

View File

@ -1,5 +1,6 @@
from typing import Any, Dict, Optional from typing import Any, Dict, Optional
from ..utils import logging
from ..utils.auth import async_has_perm from ..utils.auth import async_has_perm
from ..utils.constants import get_constants from ..utils.constants import get_constants
from ..utils.projector import get_projector_data from ..utils.projector import get_projector_data
@ -11,6 +12,9 @@ from ..utils.websocket import (
) )
logger = logging.getLogger(__name__)
class NotifyWebsocketClientMessage(BaseWebsocketClientMessage): class NotifyWebsocketClientMessage(BaseWebsocketClientMessage):
""" """
Websocket message from a client to send a message to other clients. Websocket message from a client to send a message to other clients.
@ -64,6 +68,18 @@ class NotifyWebsocketClientMessage(BaseWebsocketClientMessage):
in_response=id, in_response=id,
) )
else: else:
# Some logging
name = content.get("name", "<unknown name>")
users = content.get("users", [])
if users is True:
users = "all"
else:
users = ", ".join(users)
reply_channels = ", ".join(content.get("replyChannels", []))
logger.info(
f"Got notify '{name}' from {consumer.channel_name} users={users} reply_channels={reply_channels}"
)
# Forward to all other active site consumers to handle the notify message. # Forward to all other active site consumers to handle the notify message.
await consumer.channel_layer.group_send( await consumer.channel_layer.group_send(
"site", "site",