-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup(probeservices): short-circuit check_report_id
Originally included in #997. Reference issue: ooni/probe#2380.
- Loading branch information
1 parent
8df1173
commit 3f7ee48
Showing
2 changed files
with
8 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,14 @@ | ||
package probeservices | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
"github.com/ooni/probe-cli/v3/internal/httpx" | ||
"github.com/ooni/probe-cli/v3/internal/model" | ||
) | ||
import "context" | ||
|
||
// CheckReportID checks whether the given ReportID exists. | ||
func (c Client) CheckReportID(ctx context.Context, reportID string) (bool, error) { | ||
query := url.Values{} | ||
query.Add("report_id", reportID) | ||
var response model.OOAPICheckReportIDResponse | ||
err := (&httpx.APIClientTemplate{ | ||
BaseURL: c.BaseURL, | ||
HTTPClient: c.HTTPClient, | ||
Logger: c.Logger, | ||
UserAgent: c.UserAgent, | ||
}).WithBodyLogging().Build().GetJSONWithQuery(ctx, "/api/_/check_report_id", query, &response) | ||
if err != nil { | ||
return false, err | ||
} | ||
return response.Found, nil | ||
// The API has been returning true for some time now. So, it does not make | ||
// sense for us to actually issue the API call. Let's short circuit it. | ||
// | ||
// See https://github.com/ooni/api/blob/80913ffd446e7a46761c4c8fdf3e42174f0ce645/newapi/ooniapi/private.py#L208 | ||
// | ||
// TODO(https://github.com/ooni/probe/issues/2389): remove this code. | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters