MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / decodeEventMeta

Function decodeEventMeta

pkg/events/redis/codec.go:105–169  ·  view source on GitHub ↗
(values map[string]any)

Source from the content-addressed store, hash-verified

103}
104
105func 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

Callers 1

eventsFromXMessagesFunction · 0.85

Calls 10

ToApplicationIDFunction · 0.92
ToClientIDFunction · 0.92
ToDeviceIDFunction · 0.92
ToGatewayIDFunction · 0.92
ToOrganizationIDFunction · 0.92
ToUserIDFunction · 0.92
decodeBinaryFunction · 0.85
UnmarshalMethod · 0.65
NewMethod · 0.65
GetEntityIdentifiersMethod · 0.65

Tested by

no test coverage detected