| 41 | } |
| 42 | |
| 43 | func processVCNoteGenerated(ctx context.Context, rt event.APIClient, raw *event.RawEvent, _ map[string]string) (json.RawMessage, error) { |
| 44 | var envelope struct { |
| 45 | Header struct { |
| 46 | EventID string `json:"event_id"` |
| 47 | EventType string `json:"event_type"` |
| 48 | CreateTime string `json:"create_time"` |
| 49 | } `json:"header"` |
| 50 | Event struct { |
| 51 | NoteID string `json:"note_id"` |
| 52 | } `json:"event"` |
| 53 | } |
| 54 | if err := json.Unmarshal(raw.Payload, &envelope); err != nil { |
| 55 | return raw.Payload, nil //nolint:nilerr // passthrough on malformed payload so consumers still see the event |
| 56 | } |
| 57 | |
| 58 | out := &VCNoteGeneratedOutput{ |
| 59 | Type: envelope.Header.EventType, |
| 60 | EventID: envelope.Header.EventID, |
| 61 | Timestamp: envelope.Header.CreateTime, |
| 62 | NoteID: envelope.Event.NoteID, |
| 63 | } |
| 64 | if out.Type == "" { |
| 65 | out.Type = raw.EventType |
| 66 | } |
| 67 | |
| 68 | if rt != nil && out.NoteID != "" { |
| 69 | fillVCNoteGeneratedDetails(ctx, rt, out) |
| 70 | } |
| 71 | |
| 72 | return json.Marshal(out) |
| 73 | } |
| 74 | |
| 75 | func fillVCNoteGeneratedDetails(ctx context.Context, rt event.APIClient, out *VCNoteGeneratedOutput) { |
| 76 | if rt == nil || out == nil || out.NoteID == "" { |