feat(server): implement chat file TTL cleanup and enhance JPush vendor channel support
Add FileCleanupWorker for automatic expiration of chat files with configurable retention period and batch processing. Files uploaded via `/api/v1/uploads/files` are tracked in `uploaded_files` table with expiration timestamps, then deleted from S3 and database upon expiry. Expired file URLs are injected as `"expired": true` in message responses. Extend JPush push notification configuration with vendor-specific channel_id support (xiaomi, huawei, oppo, vivo, meizu, honor, fcm) for differentiating system vs chat notifications. Add iOS APNs thread-id grouping configuration for notification categorization.
This commit is contained in:
@@ -68,9 +68,10 @@ func ProvideMessageHandler(
|
||||
messageService service.MessageService,
|
||||
userService service.UserService,
|
||||
groupService service.GroupService,
|
||||
uploadService service.UploadService,
|
||||
publisher ws.MessagePublisher,
|
||||
) *handler.MessageHandler {
|
||||
return handler.NewMessageHandler(chatService, messageService, userService, groupService, publisher)
|
||||
return handler.NewMessageHandler(chatService, messageService, userService, groupService, uploadService, publisher)
|
||||
}
|
||||
|
||||
// ProvideSystemMessageHandler 提供系统消息处理器
|
||||
|
||||
@@ -55,6 +55,9 @@ var RepositorySet = wire.NewSet(
|
||||
|
||||
// 版本日志同步
|
||||
repository.NewConversationVersionLogRepository,
|
||||
|
||||
// 文件上传记录(聊天文件 TTL 过期清理)
|
||||
repository.NewUploadedFileRepository,
|
||||
)
|
||||
|
||||
// ProvideUserActivityRepository 提供用户活跃数据仓储
|
||||
|
||||
@@ -60,6 +60,7 @@ var ServiceSet = wire.NewSet(
|
||||
ProvideAdminDashboardService,
|
||||
ProvideQRCodeLoginService,
|
||||
ProvideHotRankWorker,
|
||||
ProvideFileCleanupWorker,
|
||||
ProvideMaterialService,
|
||||
ProvideCallService,
|
||||
ProvideLiveKitService,
|
||||
@@ -112,8 +113,9 @@ func ProvidePushService(
|
||||
messageRepo repository.MessageRepository,
|
||||
publisher ws.MessagePublisher,
|
||||
jpushClient *jpush.Client,
|
||||
cfg *config.Config,
|
||||
) service.PushService {
|
||||
return service.NewPushService(pushRepo, deviceTokenRepo, messageRepo, publisher, jpushClient)
|
||||
return service.NewPushService(pushRepo, deviceTokenRepo, messageRepo, publisher, jpushClient, cfg.JPush.Channel)
|
||||
}
|
||||
|
||||
// ProvideSystemMessageService 提供系统消息服务
|
||||
@@ -291,8 +293,23 @@ func ProvideGroupService(
|
||||
func ProvideUploadService(
|
||||
s3Client *s3.Client,
|
||||
userService service.UserService,
|
||||
uploadedRepo repository.UploadedFileRepository,
|
||||
) service.UploadService {
|
||||
return service.NewUploadService(s3Client, userService)
|
||||
return service.NewUploadService(s3Client, userService, uploadedRepo)
|
||||
}
|
||||
|
||||
// ProvideFileCleanupWorker 提供聊天文件过期清理 worker
|
||||
func ProvideFileCleanupWorker(
|
||||
cfg *config.Config,
|
||||
uploadedRepo repository.UploadedFileRepository,
|
||||
s3Client *s3.Client,
|
||||
redisClient *redis.Client,
|
||||
) *service.FileCleanupWorker {
|
||||
var rdb *redisPkg.Client
|
||||
if redisClient != nil {
|
||||
rdb = redisClient.GetClient()
|
||||
}
|
||||
return service.NewFileCleanupWorker(cfg, uploadedRepo, s3Client, rdb)
|
||||
}
|
||||
|
||||
// ProvideUserActivityService 提供用户活跃统计服务
|
||||
|
||||
Reference in New Issue
Block a user