Skip to content
Snippets Groups Projects
Unverified Commit f6fa6da4 authored by Simone Basso's avatar Simone Basso Committed by GitHub
Browse files

collector: unconditionally write the ReportID (#104)

* collector: unconditionally write the ReportID

Issue reported by @FedericoCeratto

* Update mkevent.go
parent 66e81e9d
No related branches found
No related tags found
No related merge requests found
...@@ -124,13 +124,14 @@ type updateResponse struct { ...@@ -124,13 +124,14 @@ type updateResponse struct {
} }
// SubmitMeasurement submits a measurement belonging to the report // SubmitMeasurement submits a measurement belonging to the report
// to the OONI collector. On success, we will modify the measurement // to the OONI collector. We will unconditionally modify the measurement
// updating its ReportID field. If the collector supports sending back to // with the ReportID it should contain. If the collector supports sending
// us a measurement ID, we also update the m.OOID field with it. // back to us a measurement ID, we also update the m.OOID field with it.
func (r *Report) SubmitMeasurement( func (r *Report) SubmitMeasurement(
ctx context.Context, m *model.Measurement, ctx context.Context, m *model.Measurement,
) error { ) error {
var updateResponse updateResponse var updateResponse updateResponse
m.ReportID = r.ID
err := (&jsonapi.Client{ err := (&jsonapi.Client{
BaseURL: r.client.BaseURL, BaseURL: r.client.BaseURL,
HTTPClient: r.client.HTTPClient, HTTPClient: r.client.HTTPClient,
...@@ -143,7 +144,6 @@ func (r *Report) SubmitMeasurement( ...@@ -143,7 +144,6 @@ func (r *Report) SubmitMeasurement(
}, &updateResponse, }, &updateResponse,
) )
if err == nil { if err == nil {
m.ReportID = r.ID
m.OOID = updateResponse.ID m.OOID = updateResponse.ID
} }
return err return err
......
...@@ -20,7 +20,7 @@ func Handle( ...@@ -20,7 +20,7 @@ func Handle(
) { ) {
if event.Key == "measurement" { if event.Key == "measurement" {
// We reparse the measurement and overwrite it. This is how we manage to // We reparse the measurement and overwrite it. This is how we manage to
// return the measurement to the caller. Seriousy. // return the measurement to the caller. Seriously.
// //
// We panic if we cannot parse because since MK v0.9.0 the vendored // We panic if we cannot parse because since MK v0.9.0 the vendored
// nlohmann/json library should throw if passed non UTF-8 input. // nlohmann/json library should throw if passed non UTF-8 input.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment