(enc string, evt *ttnpb.Event)
| 54 | var errUnknownEncoding = errors.DefineInvalidArgument("unknown_encoding", "unknown encoding") |
| 55 | |
| 56 | func decodeEventData(enc string, evt *ttnpb.Event) error { |
| 57 | if !strings.HasPrefix(enc, protoEncodingPrefix) { |
| 58 | return errUnknownEncoding.New() |
| 59 | } |
| 60 | bpb, err := decodeBinary(strings.TrimPrefix(enc, protoEncodingPrefix)) |
| 61 | if err != nil { |
| 62 | return err |
| 63 | } |
| 64 | // NOTE: We override the contents of `evt` with the contents `enc` explicitly. |
| 65 | // proto.UnmarshalMerge has append semantics for slices, and as such identifiers |
| 66 | // and event visibility will be duplicated, as `evt` most likely contains them |
| 67 | // from the sparse event representation. |
| 68 | return proto.Unmarshal(bpb, evt) |
| 69 | } |
| 70 | |
| 71 | const ( |
| 72 | eventUIDKey = "event_uid" |
no test coverage detected