MCPcopy Create free account
hub / github.com/daodst/chat / ClaimKeys

Function ClaimKeys

clientapi/routing/keys.go:141–163  ·  view source on GitHub ↗
(req *http.Request, keyAPI api.ClientKeyAPI)

Source from the content-addressed store, hash-verified

139}
140
141func ClaimKeys(req *http.Request, keyAPI api.ClientKeyAPI) util.JSONResponse {
142 var r claimKeysRequest
143 resErr := httputil.UnmarshalJSONRequest(req, &r)
144 if resErr != nil {
145 return *resErr
146 }
147 claimRes := api.PerformClaimKeysResponse{}
148 keyAPI.PerformClaimKeys(req.Context(), &api.PerformClaimKeysRequest{
149 OneTimeKeys: r.OneTimeKeys,
150 Timeout: r.GetTimeout(),
151 }, &claimRes)
152 if claimRes.Error != nil {
153 util.GetLogger(req.Context()).WithError(claimRes.Error).Error("failed to PerformClaimKeys")
154 return jsonerror.InternalServerError()
155 }
156 return util.JSONResponse{
157 Code: 200,
158 JSON: map[string]interface{}{
159 "one_time_keys": claimRes.OneTimeKeys,
160 "failures": claimRes.Failures,
161 },
162 }
163}

Callers 1

SetupFunction · 0.85

Calls 4

GetTimeoutMethod · 0.95
ContextMethod · 0.80
PerformClaimKeysMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected