32 lines
984 B
Go
32 lines
984 B
Go
package dispatcher
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"git.ipao.vip/rogee/go-sip/internal/contract"
|
|
"git.ipao.vip/rogee/go-sip/internal/store"
|
|
)
|
|
|
|
func (r *Runtime) rejectSIPSources(ctx context.Context, sources []store.SIPSource, cause error) error {
|
|
var failure *contract.ValidationFailure
|
|
if !errors.As(cause, &failure) || failure.Resource != "sip_config" || len(sources) == 0 {
|
|
return cause
|
|
}
|
|
for _, source := range sources {
|
|
if err := r.Bootstrap.Store.RejectData(r.Bootstrap.DispatcherID, source.Original, cause); err != nil {
|
|
return errors.Join(cause, err)
|
|
}
|
|
if err := r.Bootstrap.Store.CompleteSIPSource(source); err != nil {
|
|
return errors.Join(cause, err)
|
|
}
|
|
}
|
|
if r.Execute.Publisher == nil {
|
|
return errors.Join(cause, errors.New("SIP rejection requires an outbox publisher"))
|
|
}
|
|
if err := r.Execute.FlushOutbox(ctx); err != nil {
|
|
return errors.Join(cause, err)
|
|
}
|
|
return cause // Invalid configuration still closes admission; feedback isn't a fix.
|
|
}
|