(values map[string]any)
| 103 | } |
| 104 | |
| 105 | func decodeEventMeta(values map[string]any) (*ttnpb.Event, error) { |
| 106 | var ( |
| 107 | sparseEvent string |
| 108 | pb ttnpb.Event |
| 109 | ok bool |
| 110 | ) |
| 111 | if sparseEvent, ok = values[eventSparseKey].(string); ok { |
| 112 | b64, err := decodeBinary(sparseEvent) |
| 113 | if err != nil { |
| 114 | return nil, err |
| 115 | } |
| 116 | if err = proto.Unmarshal(b64, &pb); err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | } |
| 120 | if pb.UniqueId, ok = values[eventUIDKey].(string); !ok { |
| 121 | return nil, errUnknownEncoding.New() |
| 122 | } |
| 123 | if pb.Name, ok = values[eventNameKey].(string); !ok { |
| 124 | return nil, errUnknownEncoding.New() |
| 125 | } |
| 126 | if entityType, ok := values[entityTypeKey].(string); ok { |
| 127 | if uid, ok := values[entityIDKey].(string); ok { |
| 128 | switch entityType { |
| 129 | case "application": |
| 130 | id, err := unique.ToApplicationID(uid) |
| 131 | if err != nil { |
| 132 | return nil, err |
| 133 | } |
| 134 | pb.Identifiers = append(pb.Identifiers, id.GetEntityIdentifiers()) |
| 135 | case "client": |
| 136 | id, err := unique.ToClientID(uid) |
| 137 | if err != nil { |
| 138 | return nil, err |
| 139 | } |
| 140 | pb.Identifiers = append(pb.Identifiers, id.GetEntityIdentifiers()) |
| 141 | case "end device": |
| 142 | id, err := unique.ToDeviceID(uid) |
| 143 | if err != nil { |
| 144 | return nil, err |
| 145 | } |
| 146 | pb.Identifiers = append(pb.Identifiers, id.GetEntityIdentifiers()) |
| 147 | case "gateway": |
| 148 | id, err := unique.ToGatewayID(uid) |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | pb.Identifiers = append(pb.Identifiers, id.GetEntityIdentifiers()) |
| 153 | case "organization": |
| 154 | id, err := unique.ToOrganizationID(uid) |
| 155 | if err != nil { |
| 156 | return nil, err |
| 157 | } |
| 158 | pb.Identifiers = append(pb.Identifiers, id.GetEntityIdentifiers()) |
| 159 | case "user": |
| 160 | id, err := unique.ToUserID(uid) |
| 161 | if err != nil { |
| 162 | return nil, err |
no test coverage detected