Make radio secondary now-playing message self-only

This commit is contained in:
Jage9
2026-02-25 01:14:17 -05:00
parent 08d74b8e2c
commit 6143798b83
4 changed files with 11 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version. // Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2) // Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.25 R260"; window.CHGRID_WEB_VERSION = "2026.02.25 R261";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid. // Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit"; window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -27,7 +27,7 @@ def secondary_use_item(item: WorldItem, _nickname: str, _clock_formatter: Callab
if item.params.get("enabled") is False: if item.params.get("enabled") is False:
return ItemUseResult( return ItemUseResult(
self_message=f"{item.title} is off.", self_message=f"{item.title} is off.",
others_message=f"{item.title} is off.", others_message="",
) )
station_name = str(item.params.get("stationName", "")).strip() station_name = str(item.params.get("stationName", "")).strip()
@@ -40,4 +40,4 @@ def secondary_use_item(item: WorldItem, _nickname: str, _clock_formatter: Callab
message = f"Playing from {station_name}." message = f"Playing from {station_name}."
else: else:
message = "No now playing data." message = "No now playing data."
return ItemUseResult(self_message=message, others_message=message) return ItemUseResult(self_message=message, others_message="")

View File

@@ -1708,6 +1708,7 @@ class SignalingServer:
item.version += 1 item.version += 1
self._request_state_save() self._request_state_save()
await self._broadcast_item(item) await self._broadcast_item(item)
if secondary_result.others_message.strip():
await self._broadcast( await self._broadcast(
BroadcastChatMessagePacket(type="chat_message", message=secondary_result.others_message, system=True), BroadcastChatMessagePacket(type="chat_message", message=secondary_result.others_message, system=True),
exclude=client.websocket, exclude=client.websocket,

View File

@@ -118,12 +118,13 @@ async def test_item_secondary_use_radio_reports_now_playing(monkeypatch: pytest.
server.item_service.add_item(radio) server.item_service.add_item(radio)
send_payloads: list[object] = [] send_payloads: list[object] = []
broadcast_payloads: list[object] = []
async def fake_send(websocket: ServerConnection, packet: object) -> None: async def fake_send(websocket: ServerConnection, packet: object) -> None:
send_payloads.append(packet) send_payloads.append(packet)
async def fake_broadcast(packet: object, exclude: ServerConnection | None = None) -> None: async def fake_broadcast(packet: object, exclude: ServerConnection | None = None) -> None:
return None broadcast_payloads.append(packet)
monkeypatch.setattr(server, "_send", fake_send) monkeypatch.setattr(server, "_send", fake_send)
monkeypatch.setattr(server, "_broadcast", fake_broadcast) monkeypatch.setattr(server, "_broadcast", fake_broadcast)
@@ -135,6 +136,7 @@ async def test_item_secondary_use_radio_reports_now_playing(monkeypatch: pytest.
assert results[-1].ok is True assert results[-1].ok is True
assert results[-1].action == "secondary_use" assert results[-1].action == "secondary_use"
assert "Playing Song Y from Station X." in results[-1].message assert "Playing Song Y from Station X." in results[-1].message
assert broadcast_payloads == []
@pytest.mark.asyncio @pytest.mark.asyncio