Cap sound and stream URL fields at 2048 chars
This commit is contained in:
@@ -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.22 R145";
|
window.CHGRID_WEB_VERSION = "2026.02.22 R146";
|
||||||
// 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";
|
||||||
|
|||||||
@@ -86,8 +86,16 @@ ITEM_TYPE_TOOLTIPS: dict[ItemType, str] = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLOBAL_ITEM_PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
GLOBAL_ITEM_PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||||
"useSound": {"valueType": "sound", "tooltip": "One-shot sound played when this item is used successfully."},
|
"useSound": {
|
||||||
"emitSound": {"valueType": "sound", "tooltip": "Looping sound emitted from this item on the grid."},
|
"valueType": "sound",
|
||||||
|
"tooltip": "One-shot sound played when this item is used successfully.",
|
||||||
|
"maxLength": 2048,
|
||||||
|
},
|
||||||
|
"emitSound": {
|
||||||
|
"valueType": "sound",
|
||||||
|
"tooltip": "Looping sound emitted from this item on the grid.",
|
||||||
|
"maxLength": 2048,
|
||||||
|
},
|
||||||
"useCooldownMs": {"valueType": "number", "tooltip": "Global cooldown in milliseconds between uses for this item type."},
|
"useCooldownMs": {"valueType": "number", "tooltip": "Global cooldown in milliseconds between uses for this item type."},
|
||||||
"emitRange": {"valueType": "number", "tooltip": "Maximum distance in squares where emitted audio can be heard."},
|
"emitRange": {"valueType": "number", "tooltip": "Maximum distance in squares where emitted audio can be heard."},
|
||||||
"directional": {"valueType": "boolean", "tooltip": "Whether emitted audio favors the item's facing direction."},
|
"directional": {"valueType": "boolean", "tooltip": "Whether emitted audio favors the item's facing direction."},
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ EFFECT_OPTIONS: tuple[str, ...] = ("reverb", "echo", "flanger", "high_pass", "lo
|
|||||||
|
|
||||||
PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
||||||
"title": {"valueType": "text", "tooltip": "Display name spoken and shown for this item.", "maxLength": 80},
|
"title": {"valueType": "text", "tooltip": "Display name spoken and shown for this item.", "maxLength": 80},
|
||||||
"streamUrl": {"valueType": "text", "tooltip": "Audio stream URL used by this radio."},
|
"streamUrl": {"valueType": "text", "tooltip": "Audio stream URL used by this radio.", "maxLength": 2048},
|
||||||
"enabled": {"valueType": "boolean", "tooltip": "Turns playback on or off for this radio."},
|
"enabled": {"valueType": "boolean", "tooltip": "Turns playback on or off for this radio."},
|
||||||
"mediaVolume": {
|
"mediaVolume": {
|
||||||
"valueType": "number",
|
"valueType": "number",
|
||||||
@@ -75,6 +75,8 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
|||||||
"""Validate and normalize radio params."""
|
"""Validate and normalize radio params."""
|
||||||
|
|
||||||
stream_url = str(next_params.get("streamUrl", "")).strip()
|
stream_url = str(next_params.get("streamUrl", "")).strip()
|
||||||
|
if len(stream_url) > 2048:
|
||||||
|
raise ValueError("streamUrl must be 2048 characters or less.")
|
||||||
previous_stream_url = str(item.params.get("streamUrl", "")).strip()
|
previous_stream_url = str(item.params.get("streamUrl", "")).strip()
|
||||||
next_params["streamUrl"] = stream_url
|
next_params["streamUrl"] = stream_url
|
||||||
|
|
||||||
|
|||||||
@@ -81,8 +81,16 @@ PROPERTY_METADATA: dict[str, dict[str, object]] = {
|
|||||||
"tooltip": "Amount for emit effect.",
|
"tooltip": "Amount for emit effect.",
|
||||||
"range": {"min": 0, "max": 100, "step": 0.1},
|
"range": {"min": 0, "max": 100, "step": 0.1},
|
||||||
},
|
},
|
||||||
"useSound": {"valueType": "sound", "tooltip": "Sound played on use. Filename assumes sounds folder, or use full URL."},
|
"useSound": {
|
||||||
"emitSound": {"valueType": "sound", "tooltip": "Looping emitted sound. Filename assumes sounds folder, or use full URL."},
|
"valueType": "sound",
|
||||||
|
"tooltip": "Sound played on use. Filename assumes sounds folder, or use full URL.",
|
||||||
|
"maxLength": 2048,
|
||||||
|
},
|
||||||
|
"emitSound": {
|
||||||
|
"valueType": "sound",
|
||||||
|
"tooltip": "Looping emitted sound. Filename assumes sounds folder, or use full URL.",
|
||||||
|
"maxLength": 2048,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,6 +177,10 @@ def validate_update(item: WorldItem, next_params: dict) -> dict:
|
|||||||
|
|
||||||
next_params["useSound"] = _normalize_sound_value(next_params.get("useSound", item.params.get("useSound", "")))
|
next_params["useSound"] = _normalize_sound_value(next_params.get("useSound", item.params.get("useSound", "")))
|
||||||
next_params["emitSound"] = _normalize_sound_value(next_params.get("emitSound", item.params.get("emitSound", "")))
|
next_params["emitSound"] = _normalize_sound_value(next_params.get("emitSound", item.params.get("emitSound", "")))
|
||||||
|
if len(next_params["useSound"]) > 2048:
|
||||||
|
raise ValueError("useSound must be 2048 characters or less.")
|
||||||
|
if len(next_params["emitSound"]) > 2048:
|
||||||
|
raise ValueError("emitSound must be 2048 characters or less.")
|
||||||
return next_params
|
return next_params
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user