()
| 11 | ) |
| 12 | |
| 13 | func ProcessEvents() (string, error) { |
| 14 | functionName := "ProcessEvents" |
| 15 | |
| 16 | var comDB ComDB |
| 17 | // Read comDB from file |
| 18 | if readErr := ReadComFile(auxiliary.StateInstance.ComDBPath, &comDB); readErr != nil { |
| 19 | return "", fmt.Errorf("reading ComDB failed -> %v: %w", functionName, readErr) |
| 20 | } |
| 21 | |
| 22 | // Iteratve over comDB events |
| 23 | for _, event := range comDB.Events { |
| 24 | // Filter for confirm events (the only events targeted at CLI) |
| 25 | if event.Path == auxiliary.StateInstance.WorkingPath && event.Receiver == "CLI" && !event.Received { |
| 26 | // Mark event as received in comDB |
| 27 | if markErr := MarkComDBReceived(event); markErr != nil { |
| 28 | return "", fmt.Errorf("could not mark event as received -> %v --- %v: %w", event.Type, functionName, markErr) |
| 29 | } |
| 30 | |
| 31 | if event.Type == "confirmed" { |
| 32 | return "confirmed", nil |
| 33 | } |
| 34 | |
| 35 | if event.Type == "canceled" { |
| 36 | return "canceled", nil |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return "", nil |
| 42 | } |
| 43 | |
| 44 | func WatchComDBFallback() (bool, error) { |
| 45 | functionName := "WatchComDBFallback" |
no test coverage detected