Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Add optional asyncID query param to async API calls #1027

Merged
merged 1 commit into from Jul 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 18 additions & 9 deletions api/jsonapi.go
Expand Up @@ -1803,9 +1803,12 @@ func (i *jsonAPIHandler) GETModerators(w http.ResponseWriter, r *http.Request) {
}
SanitizedResponse(w, resp)
} else {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id := base58.Encode(idBytes)
id := r.URL.Query().Get("asyncID")
if id == "" {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id = base58.Encode(idBytes)
}

type resp struct {
Id string `json:"id"`
Expand Down Expand Up @@ -2623,9 +2626,12 @@ func (i *jsonAPIHandler) POSTFetchProfiles(w http.ResponseWriter, r *http.Reques
resp += "\n]"
SanitizedResponse(w, resp)
} else {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id := base58.Encode(idBytes)
id := r.URL.Query().Get("asyncID")
if id == "" {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id = base58.Encode(idBytes)
}

type resp struct {
Id string `json:"id"`
Expand Down Expand Up @@ -3366,9 +3372,12 @@ func (i *jsonAPIHandler) POSTFetchRatings(w http.ResponseWriter, r *http.Request
resp += "\n]"
SanitizedResponse(w, resp)
} else {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id := base58.Encode(idBytes)
id := r.URL.Query().Get("asyncID")
if id == "" {
idBytes := make([]byte, 16)
rand.Read(idBytes)
id = base58.Encode(idBytes)
}

type resp struct {
Id string `json:"id"`
Expand Down