feat: 增加 SafeW 已监控群列表接口

通过 getUpdates 将群写入 Redis,供创建/编辑渠道时选择 chat_id,避免前端重复传递 token。
This commit is contained in:
2026-08-15 00:40:40 +08:00
parent 0d0cd0c510
commit bd8a9ff96d
14 changed files with 2265 additions and 4 deletions
+18 -1
View File
@@ -15,6 +15,7 @@ import (
"aiaa-notification-service/internal/config"
"aiaa-notification-service/internal/engine"
"aiaa-notification-service/internal/handler"
"aiaa-notification-service/internal/safew"
"aiaa-notification-service/internal/store"
"github.com/gin-gonic/gin"
@@ -125,7 +126,21 @@ func main() {
notifyH := handler.NewNotifyHandler(st, redisCache, matcher, renderer, router)
sourceH := handler.NewSourceHandler(st, redisCache)
templateH := handler.NewTemplateHandler(st, redisCache)
channelH := handler.NewChannelHandler(st, redisCache)
poller := func(token string, offset int64, timeout int) ([]adapter.SafewChat, int64, error) {
return (&adapter.SafeWSender{}).PollGroupChats(token, offset, timeout)
}
var watcherStore safew.ChatStore
if redisCache != nil {
watcherStore = redisCache
} else {
watcherStore = safew.NewMemStore()
slog.Warn("safew chats using in-memory store")
}
safewWatcher := safew.NewWatcher(watcherStore, poller)
defer safewWatcher.Stop()
channelH := handler.NewChannelHandler(st, redisCache, safewWatcher)
ruleH := handler.NewRuleHandler(st, redisCache)
msgLogH := handler.NewMessageLogHandler(st)
@@ -168,6 +183,8 @@ func main() {
admin.DELETE("/templates/:id", templateH.Delete)
// Channels
admin.POST("/channels/safew/chats", channelH.ListSafewChats)
admin.GET("/channels/:id/chats", channelH.ListChannelSafewChats)
admin.POST("/channels", channelH.Create)
admin.GET("/channels", channelH.List)
admin.GET("/channels/:id", channelH.Get)