feat: add Telegram bot config UI (#1747)

* Add retry wait for telegram.GetUpdates

* Add support to set telegram robot token from UI

* Change validator of UserSettingTelegramUserID

* Add support to set telegram user id from UI

* Fix typescript check

* Add validator for SystemSettingTelegramRobotTokenName

* Optimize error notice while config telegram params

* Change for review

* Fix telegram user id could not be empty

* Fix telegram robot could not be empty

* Fix for eslint (again)

* Update web/src/components/Settings/SystemSection.tsx

---------

Co-authored-by: Athurg Feng <athurg@gooth.org>
Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
Athurg Gooth
2023-05-26 19:16:51 +08:00
committed by GitHub
parent 4ea5426e18
commit 8628d1e4b2
8 changed files with 138 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package api
import (
"encoding/json"
"fmt"
"strings"
"golang.org/x/exp/slices"
)
@ -186,6 +187,15 @@ func (upsert SystemSettingUpsert) Validate() error {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
case SystemSettingTelegramRobotTokenName:
if upsert.Value == "" {
return nil
}
fragments := strings.Split(upsert.Value, ":")
if len(fragments) != 2 {
return fmt.Errorf(systemSettingUnmarshalError, settingName)
}
default:
return fmt.Errorf("invalid system setting name")
}