From de128f7a40af25ea7f72cd703056cf194a9138f1 Mon Sep 17 00:00:00 2001 From: Eichenholz Date: Tue, 4 Aug 2026 18:51:40 +0200 Subject: [PATCH] CLN - internalize device storage limits --- sky_phone/config/config.lua | 9 --------- sky_phone/source/server/phone.lua | 13 +++++++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sky_phone/config/config.lua b/sky_phone/config/config.lua index 1df0e45..af7ba2b 100644 --- a/sky_phone/config/config.lua +++ b/sky_phone/config/config.lua @@ -4,15 +4,6 @@ Config.Phone = { Item = "phone", DevelopmentCommand = false, DeviceName = "iFruit Phone", - MaxDeviceDataBytes = 100000, - AllowedDeviceNamespaces = { - settings = true, - notifications = true, - wallpaper = true, - alarms = true, - media = true, - apps = true, - }, } Config.Mail = { diff --git a/sky_phone/source/server/phone.lua b/sky_phone/source/server/phone.lua index 02aab46..74ad85a 100644 --- a/sky_phone/source/server/phone.lua +++ b/sky_phone/source/server/phone.lua @@ -7,6 +7,15 @@ SkyPhone = {} local sessions = {} local auth_attempts = {} local operation_attempts = {} +local max_device_data_bytes = 100000 +local allowed_device_namespaces = { + settings = true, + notifications = true, + wallpaper = true, + alarms = true, + media = true, + apps = true, +} local function trim(value) if type(value) ~= "string" then @@ -440,12 +449,12 @@ Sky.Cb.Register("sky_phone:device:save", function(source, data) if not session then return error_response end - if type(data) ~= "table" or not Config.Phone.AllowedDeviceNamespaces[data.namespace] then + if type(data) ~= "table" or not allowed_device_namespaces[data.namespace] then return { success = false, error = "invalid_namespace" } end local encoded = json.encode(data.payload) - if #encoded > Config.Phone.MaxDeviceDataBytes then + if #encoded > max_device_data_bytes then return { success = false, error = "payload_too_large" } end local revision = math.max(0, math.floor(tonumber(data.revision) or 0))