feat: rewrite notification system and telegram interactive bot

This commit is contained in:
Bot
2026-04-28 00:04:29 +08:00
parent c606fd99f6
commit 3319d7344f
11 changed files with 387 additions and 26 deletions
+1
View File
@@ -156,6 +156,7 @@ func routers(r *gin.Engine, frontendDist fs.FS) {
auth.POST("/domains", commonHandler(AddDomain))
auth.POST("/domains/:id/verify", commonHandler(VerifyDomain))
auth.POST("/domains/:id/sync", commonHandler(SyncDomainWHOIS))
auth.POST("/domains/sync-all", commonHandler(SyncAllDomains))
auth.PUT("/domains/:id", commonHandler(UpdateDomain))
auth.DELETE("/domains/:id", commonHandler(DeleteDomain))
+5
View File
@@ -137,3 +137,8 @@ func SyncDomainWHOIS(c *gin.Context) (any, error) {
return domain, nil
}
func SyncAllDomains(c *gin.Context) (any, error) {
singleton.SyncAllDomains()
return nil, nil
}
+2
View File
@@ -57,6 +57,7 @@ func createNotification(c *gin.Context) (uint64, error) {
n.RequestHeader = nf.RequestHeader
n.RequestBody = nf.RequestBody
n.URL = nf.URL
n.Type = nf.Type
verifyTLS := nf.VerifyTLS
n.VerifyTLS = &verifyTLS
formatMetricUnits := nf.FormatMetricUnits
@@ -120,6 +121,7 @@ func updateNotification(c *gin.Context) (any, error) {
n.RequestHeader = nf.RequestHeader
n.RequestBody = nf.RequestBody
n.URL = nf.URL
n.Type = nf.Type
verifyTLS := nf.VerifyTLS
n.VerifyTLS = &verifyTLS
formatMetricUnits := nf.FormatMetricUnits
+2 -2
View File
@@ -111,8 +111,8 @@ func updateConfig(c *gin.Context) (any, error) {
singleton.Conf.CustomLogo = sf.CustomLogo
singleton.Conf.CustomDescription = sf.CustomDescription
singleton.Conf.CustomLinks = sf.CustomLinks
singleton.Conf.BackgroundImageDay = sf.BackgroundImageDay
singleton.Conf.BackgroundImageNight = sf.BackgroundImageNight
singleton.Conf.TelegramBotToken = sf.TelegramBotToken
singleton.Conf.TelegramAdminChatID = sf.TelegramAdminChatID
if err := singleton.Conf.Save(); err != nil {
return nil, newGormError("%v", err)