fix(settings): don't clobber webhook secret with its mask on save
GET /settings returns the Telegram webhook secret masked as "***<last4>". The frontend binds that masked value into its state, and any Save ships it back — the PUT handler then persisted the mask as the new secret, silently invalidating HMAC for every webhook-mode bot. The next GET re-masks the mask to itself, so the UI showed no corruption. Treat incoming values that begin with "***" as "unchanged" for the webhook-secret field. Empty strings still pass through (explicit clear).
This commit is contained in:
@@ -100,6 +100,13 @@ async def update_settings(
|
||||
if value is None:
|
||||
continue
|
||||
value_str = str(value)
|
||||
# GET masks the webhook secret as "***<last4>" so the real value is
|
||||
# never exposed to the frontend. If the client sends the mask back
|
||||
# (which happens on every save, since bind:value holds whatever GET
|
||||
# returned), treat it as "unchanged" — otherwise we'd overwrite the
|
||||
# real secret with its mask, silently breaking webhook HMAC.
|
||||
if key == "telegram_webhook_secret" and value_str.startswith("***"):
|
||||
continue
|
||||
row = await session.get(AppSetting, key)
|
||||
if row:
|
||||
row.value = value_str
|
||||
|
||||
Reference in New Issue
Block a user