refactored notificatoin / tgsettle responsibility boundaries

This commit is contained in:
Stephan D
2026-02-19 18:56:59 +01:00
parent 47f0a3d890
commit 2fd8a6ebb7
73 changed files with 3705 additions and 681 deletions

View File

@@ -36,11 +36,34 @@ func (crn *ConfirmationResultNotification) Serialize() ([]byte, error) {
return crn.Envelope.Wrap(data)
}
type ConfirmationDispatchNotification struct {
messaging.Envelope
payload model.ConfirmationRequestDispatch
}
func (cdn *ConfirmationDispatchNotification) Serialize() ([]byte, error) {
data, err := json.Marshal(cdn.payload)
if err != nil {
return nil, err
}
return cdn.Envelope.Wrap(data)
}
func confirmationRequestEvent() model.NotificationEvent {
return model.NewNotification(mservice.Notifications, nm.NAConfirmationRequest)
}
func confirmationResultEvent(sourceService, rail string) model.NotificationEvent {
sourceService, rail = normalizeSourceRail(sourceService, rail)
return model.NewNotification(mservice.Verification, nm.NotificationAction(sourceService+"."+rail))
}
func confirmationDispatchEvent(sourceService, rail string) model.NotificationEvent {
sourceService, rail = normalizeSourceRail(sourceService, rail)
return model.NewNotification(mservice.Verification, nm.NotificationAction(sourceService+"."+rail+".dispatch"))
}
func normalizeSourceRail(sourceService, rail string) (string, string) {
action := strings.TrimSpace(sourceService)
if action == "" {
action = "unknown"
@@ -51,7 +74,7 @@ func confirmationResultEvent(sourceService, rail string) model.NotificationEvent
rail = "default"
}
rail = strings.ToLower(rail)
return model.NewNotification(mservice.Verification, nm.NotificationAction(action+"."+rail))
return action, rail
}
func NewConfirmationRequestEnvelope(sender string, request *model.ConfirmationRequest) messaging.Envelope {
@@ -75,3 +98,14 @@ func NewConfirmationResultEnvelope(sender string, result *model.ConfirmationResu
payload: payload,
}
}
func NewConfirmationDispatchEnvelope(sender string, dispatch *model.ConfirmationRequestDispatch, sourceService, rail string) messaging.Envelope {
var payload model.ConfirmationRequestDispatch
if dispatch != nil {
payload = *dispatch
}
return &ConfirmationDispatchNotification{
Envelope: messaging.CreateEnvelope(sender, confirmationDispatchEvent(sourceService, rail)),
payload: payload,
}
}