feat(settings): propagate user_timezone to briefing scheduler on save
When user_timezone is saved via PUT /api/settings, immediately call update_user_schedule if briefing is enabled so the scheduler picks up the new timezone without requiring a restart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ from fabledassistant.auth import login_required, get_current_user_id
|
|||||||
from fabledassistant.config import Config
|
from fabledassistant.config import Config
|
||||||
from fabledassistant.services.caldav import CALDAV_SETTING_KEYS, get_caldav_config, test_connection
|
from fabledassistant.services.caldav import CALDAV_SETTING_KEYS, get_caldav_config, test_connection
|
||||||
from fabledassistant.services.llm import get_installed_models, _is_private_url
|
from fabledassistant.services.llm import get_installed_models, _is_private_url
|
||||||
from fabledassistant.services.settings import delete_setting, get_all_settings, set_settings_batch
|
from fabledassistant.services.settings import delete_setting, get_all_settings, get_setting, set_settings_batch
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -80,6 +80,18 @@ async def update_settings_route():
|
|||||||
if to_save:
|
if to_save:
|
||||||
await set_settings_batch(uid, to_save)
|
await set_settings_batch(uid, to_save)
|
||||||
|
|
||||||
|
# When timezone changes, live-patch the briefing scheduler immediately
|
||||||
|
if "user_timezone" in to_save:
|
||||||
|
import json as _json
|
||||||
|
from fabledassistant.services.briefing_scheduler import update_user_schedule
|
||||||
|
config_raw = await get_setting(uid, "briefing_config", "{}")
|
||||||
|
try:
|
||||||
|
config = _json.loads(config_raw) if isinstance(config_raw, str) else {}
|
||||||
|
except Exception:
|
||||||
|
config = {}
|
||||||
|
if config.get("enabled"):
|
||||||
|
update_user_schedule(uid, config, tz_override=to_save["user_timezone"] or None)
|
||||||
|
|
||||||
if "default_model" in to_save and to_save["default_model"]:
|
if "default_model" in to_save and to_save["default_model"]:
|
||||||
asyncio.create_task(_prime_kv_cache_bg(uid, to_save["default_model"]))
|
asyncio.create_task(_prime_kv_cache_bg(uid, to_save["default_model"]))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user