feat(server): implement chat file TTL cleanup and enhance JPush vendor channel support
All checks were successful
Build Backend / build (push) Successful in 3m1s
Build Backend / build-docker (push) Successful in 2m10s

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:
lafay
2026-06-17 20:41:55 +08:00
parent d9aa4b46c3
commit a0e210feab
24 changed files with 1573 additions and 127 deletions

View File

@@ -0,0 +1,26 @@
package model
import "time"
// UploadedFile 聊天/通用文件上传记录
// 用于跟踪 files/ 前缀下的 S3 对象,配合 FileCleanupWorker 实现 TTL 过期清理。
// 注意images/avatars/covers 等内容寻址资源不记录本表,不会被自动清理。
type UploadedFile struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
URL string `gorm:"size:512;index;not null" json:"url"` // 完整访问 URLDTO 标记失效用
ObjectName string `gorm:"size:256;index;not null" json:"object_name"` // S3 对象名 files/{folder}/{hash}{ext}
Name string `gorm:"size:255" json:"name"` // 原始文件名
Size int64 `json:"size"` // 字节数
MimeType string `gorm:"size:128" json:"mime_type"`
Folder string `gorm:"size:32;index" json:"folder"` // chat / post 等来源
UploaderID string `gorm:"size:50;index" json:"uploader_id"` // 上传者 UUID
Expired bool `gorm:"index;default:false" json:"expired"` // 是否已从 S3 清理
ExpiredAt *time.Time `json:"expired_at,omitempty"` // 清理时间
CreatedAt time.Time `gorm:"index" json:"created_at"` // 上传时间TTL 计算基准
UpdatedAt time.Time `json:"updated_at"`
}
// TableName 表名
func (UploadedFile) TableName() string {
return "uploaded_files"
}