MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / parseCodexDevicePollInterval

Function parseCodexDevicePollInterval

sdk/auth/codex_device.go:229–248  ·  view source on GitHub ↗
(raw json.RawMessage)

Source from the content-addressed store, hash-verified

227}
228
229func parseCodexDevicePollInterval(raw json.RawMessage) time.Duration {
230 defaultInterval := time.Duration(codexDeviceDefaultPollIntervalSeconds) * time.Second
231 if len(raw) == 0 {
232 return defaultInterval
233 }
234
235 var asString string
236 if err := json.Unmarshal(raw, &asString); err == nil {
237 if seconds, convErr := strconv.Atoi(strings.TrimSpace(asString)); convErr == nil && seconds > 0 {
238 return time.Duration(seconds) * time.Second
239 }
240 }
241
242 var asInt int
243 if err := json.Unmarshal(raw, &asInt); err == nil && asInt > 0 {
244 return time.Duration(asInt) * time.Second
245 }
246
247 return defaultInterval
248}
249
250func codexDeviceIsSuccessStatus(code int) bool {
251 return code >= 200 && code < 300

Callers 1

loginWithDeviceFlowMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected