mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 06:56:36 +08:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user