fix: 补提交校验、停用检查、入群过滤与按完成时刻清理
This commit is contained in:
@@ -23,9 +23,11 @@ type OfflineOpts struct {
|
||||
|
||||
// Limits 是与服务器配置相关的校验上限。
|
||||
type Limits struct {
|
||||
MaxBodyBytes int
|
||||
MaxMetaBytes int
|
||||
MaxFrameBytes int
|
||||
MaxBodyBytes int
|
||||
MaxMetaBytes int
|
||||
MaxFrameBytes int
|
||||
MaxTTLSeconds int64
|
||||
MaxScheduleSeconds int64
|
||||
}
|
||||
|
||||
// DefaultLimits 返回 DEVELOPMENT 示例中的默认上限。
|
||||
|
||||
@@ -167,6 +167,23 @@ func (s *Send) Validate(lim Limits) error {
|
||||
if s.SendAtMs != nil && s.DelayMs != nil {
|
||||
return badRequest("send_at_ms and delay_ms are mutually exclusive")
|
||||
}
|
||||
if EffectiveOfflineKeep(s) {
|
||||
if s.Offline != nil && s.Offline.TTLSeconds != nil && *s.Offline.TTLSeconds <= 0 {
|
||||
return badRequest("ttl_seconds must be > 0")
|
||||
}
|
||||
ttl := EffectiveOfflineTTL(s)
|
||||
if lim.MaxTTLSeconds > 0 && ttl > lim.MaxTTLSeconds {
|
||||
return badRequest("ttl_seconds exceeds max_ttl_seconds")
|
||||
}
|
||||
}
|
||||
if s.DelayMs != nil {
|
||||
if *s.DelayMs < 0 {
|
||||
return badRequest("delay_ms negative")
|
||||
}
|
||||
if lim.MaxScheduleSeconds > 0 && *s.DelayMs > lim.MaxScheduleSeconds*1000 {
|
||||
return badRequest("delay_ms exceeds max_schedule_seconds")
|
||||
}
|
||||
}
|
||||
n, err := FrameBytes(s)
|
||||
if err != nil {
|
||||
return badRequest("cannot encode frame")
|
||||
|
||||
Reference in New Issue
Block a user