feat(push): validate push channels presence before enabling push event

- Reject toggling an event to enabled in ToggleEvent handler if channels list is empty.
- Add model-level validation in PushEvent.Validate() to prevent enabling events without channels during creation/updates.
- Update TestPushRouters/toggle_event_status unit test to cover this verification.
This commit is contained in:
ryan
2026-06-16 08:59:03 +08:00
parent 6a913701b9
commit bfa00ae6ac
3 changed files with 17 additions and 1 deletions
+3
View File
@@ -46,6 +46,9 @@ func (pe *PushEvent) Validate() error {
if pe.Template == "" {
return errors.New("event template is required")
}
if pe.Enabled && len(pe.Channels) == 0 {
return errors.New("cannot enable event without any push channels configured")
}
return nil
}