Commit Graph

37 Commits

Author SHA1 Message Date
ryan a07963e150 feat: enhance Safew chat handling and testing
- Updated `GroupsFromUpdates` function to return the number of updates processed, improving the polling mechanism.
- Added a new test `TestGroupsFromUpdatesCallbackAndJoinRequest` to validate handling of callback queries and join requests.
- Introduced `safewAllowedUpdates` to specify allowed update types in the polling request, enhancing chat management.
- Implemented `ensureWebhookCleared` method to manage webhook state before polling, improving reliability.
2026-08-15 01:56:12 +08:00
ryan 2000908bac feat: enhance Safew watcher initialization and token management
- Added functionality to list and start Safew tokens in the main server function, ensuring proper initialization of the Safew watcher.
- Introduced `ensureSafewWatcher` method in the ChannelHandler to manage Safew tokens during channel creation and updates.
- Implemented `StartTokens` method in the Watcher to handle multiple tokens efficiently.
- Enhanced error handling and logging for Safew watcher operations to improve observability.
2026-08-15 01:28:51 +08:00
ryan 5e783adf7a feat: implement chat merging and logging in Safew
- Introduced a new function `mergeAndLog` in the Watcher to handle merging Safew chats and logging newly discovered chats.
- Added a test `TestNewSafewChatsSkipsKnownIDs` to ensure that known chat IDs are skipped during the merging process.
- Enhanced the polling mechanism to improve chat management and reduce duplicates.
2026-08-15 01:10:35 +08:00
ryan e369f398d8 feat: enhance Safew error handling and polling mechanism
- Added error_msg field to safewAPIResponse for better error descriptions.
- Updated safewErrorDescription function to include error_msg in the output.
- Introduced a new test to verify that error messages are included in Safew error descriptions.
- Improved the polling mechanism in the Watcher to handle conflicts and ensure no overlapping polls occur.
2026-08-15 01:07:01 +08:00
ryan bd8a9ff96d feat: 增加 SafeW 已监控群列表接口
通过 getUpdates 将群写入 Redis,供创建/编辑渠道时选择 chat_id,避免前端重复传递 token。
2026-08-15 00:40:40 +08:00
ryan 0d0cd0c510 feat: 新增 SafeW 出站通知渠道
通过 Bot API sendMessage 投递渲染后的通知,MarkdownV2 自动转义标题与正文。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 00:58:44 +08:00
ryan 39f3774940 feat: 配置列表分页与钉钉机器人分钟级排队限流
统一 sources/templates/channels/rules 列表为分页响应,避免配置增多时全量返回;按钉钉 access_token 限制每分钟发送并在超限时等待下一分钟,降低触发官方封禁风险。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-10 00:34:26 +08:00
ryan 009694fee7 build(Docker构建): 限制构建阶段内存与并行度,防止低配环境 OOM
Motivation:
在 1Panel 等资源受限的部署环境中,Go 编译器并发编译和运行时内存增长可能导致构建阶段 OOM 而被 kill,通过限制并行度和设置内存上限来规避该问题。

Changes:

* 构建阶段新增 GOMEMLIMIT=512MiB 环境变量,控制 Go 运行时内存上限
* 编译命令新增 -p 1 参数,限制并行编译单元数量以减少峰值内存占用
* 构建命令参数按职责拆分为多行,提升可读性
2026-07-31 23:28:02 +08:00
ryan c74bab3033 fix(数据存储): 确保列表查询返回空数组而非 null,并补充 HTTPie/Postman API 文档
Motivation:
当数据库查询无结果时,Go 的 `var slice []Type` 声明会使 JSON 序列化输出 `null`,而非 `[]`。这在 API 响应中造成不一致,也增加了客户端的空值处理负担。改为 `make([]Type, 0)` 后空结果统一输出为 `[]`,提升 API 规范性。

Changes:

* 统一 store 层所有 List 方法使用 `make([]Type, 0)` 初始化切片,覆盖 Sources、Channels、Templates、Rules、MessageLogs 及 RuleChannels 查询
* 新增完整的 cURL 示例文档,覆盖全部 API 端点(通知、Source、Template、Channel、Rule、消息记录)
* 新增 Postman Collection JSON 文件,可直接导入 HTTPie 使用,包含环境变量配置
2026-07-31 22:09:39 +08:00
ryan 34fb0f62b9 build 2026-07-31 18:01:15 +08:00
ryan af9731f831 build 2026-07-31 17:52:26 +08:00
ryan cecf8e72f5 fix(邮件发送): 适配 MailerSend SMTP 并迁移基础设施至 1Panel
Motivation:
将通知服务部署到 1Panel 生产环境,集成 MailerSend 邮件服务,修复 SMTP 协议中 MAIL FROM 命令因携带显示名而导致的发送失败问题。

Changes:

* 修复 SMTP MAIL FROM 命令传入带显示名的完整地址导致发送失败的问题,新增 extractEmailAddr 提取裸地址
* 更新 SMTP 配置为 MailerSend 真实凭证,From 地址适配其域名验证要求
* 移除 docker-compose 中内置的 MySQL/Redis 服务,改为依赖外部 1Panel 基础设施
* 更新环境变量为生产环境实际凭据
2026-07-31 17:28:35 +08:00
ryan 6e69f6cdc3 build: 配置信息 2026-07-31 15:44:06 +08:00
ryan befb099b91 feat: add comprehensive README documentation for AIAA Notification Service, detailing core concepts, setup instructions, API endpoints, and configuration options 2026-07-31 00:54:03 +08:00
ryan a0d26fa3a3 refactor: rename database tables for notification entities to improve clarity and consistency 2026-07-02 16:04:18 +08:00
ryan c5225d8c97 feat: add Logbull remote logging via slog handler, tee to stdout 2026-06-27 15:17:59 +08:00
ryan 835b92ec00 fix: wire retry into router, fix Docker config path, fix condition error handling, remove dead code 2026-06-27 13:32:33 +08:00
ryan 062014773c fix: remove compiled binary, update gitignore 2026-06-27 13:29:33 +08:00
ryan fa7f7490f5 feat: main assembly — wire all components, gin router, graceful shutdown 2026-06-27 13:28:27 +08:00
ryan 2271a54139 feat: retry mechanism with exponential backoff 2026-06-27 13:26:13 +08:00
ryan 8e0c95edd9 feat: rule CRUD with enable/disable and message log query 2026-06-27 13:23:37 +08:00
ryan 682ca3df81 feat: management handlers — source, template, channel CRUD 2026-06-27 13:23:10 +08:00
ryan 2cf6601be0 feat: notify handler — parse, match, evaluate, render, route 2026-06-27 13:22:14 +08:00
ryan 127cf12656 feat: auth and rate limit middleware 2026-06-27 13:20:56 +08:00
ryan 83c4166f0c feat: engine — template renderer, rule matcher, channel router 2026-06-27 13:19:15 +08:00
ryan 49b2384cf7 feat: email adapter with SMTP TLS support 2026-06-27 13:17:32 +08:00
ryan 414c8c7cbf feat: channel adapters — dingtalk, wecom, bark 2026-06-27 13:15:57 +08:00
ryan 54af29e4fc feat: condition evaluator for rule filtering 2026-06-27 13:15:02 +08:00
ryan d7ae840d9a fix: atomic rate limiter and error handling in cache invalidation 2026-06-27 13:12:37 +08:00
ryan 69e32cb3ec feat: message parser with json/regex/text modes 2026-06-27 13:11:05 +08:00
ryan d030f0f0df fix: error handling in rule store 2026-06-27 13:09:34 +08:00
ryan 3f75699431 feat: redis cache layer with rule/channel caching and rate limiter 2026-06-27 13:07:56 +08:00
ryan a8e939da40 feat: rule and message_log store CRUD 2026-06-27 13:06:54 +08:00
ryan 236105ea9c feat: template and channel store CRUD 2026-06-27 13:04:57 +08:00
ryan 7cd84c8468 feat: store connection and source CRUD 2026-06-27 13:02:17 +08:00
ryan 3d0b91fe23 feat: data models and database migration 2026-06-27 12:59:33 +08:00
ryan 976ec3ca70 feat: project scaffold, config loading, skeleton main 2026-06-27 12:57:11 +08:00