Merge pull request #5066 from FinnStutzenstein/notifyLogging

Logs notify messages on server
This commit is contained in:
Emanuel Schütze 2019-10-05 08:14:55 +02:00 committed by GitHub
commit 41627da5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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",