Преглед на файлове

Assign empty object for ISP info when not available

If somehow in the telemetry data ISP info is empty,
write an empty JSON object as ISP info into the
database to avoid parsing errors
Maddie Zhan преди 6 години
родител
ревизия
687a5aeca0
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      results/telemetry.go

+ 5 - 1
results/telemetry.go

@@ -166,7 +166,11 @@ func Record(w http.ResponseWriter, r *http.Request) {
 
 	var record schema.TelemetryData
 	record.IPAddress = ipAddr
-	record.ISPInfo = ispInfo
+	if ispInfo == "" {
+		record.ISPInfo = "{}"
+	} else {
+		record.ISPInfo = ispInfo
+	}
 	record.Extra = extra
 	record.UserAgent = userAgent
 	record.Language = language