MCPcopy Create free account
hub / github.com/VitoHowe/glm-coding / bootstrap_account

Method bootstrap_account

app/services/payment_service.py:350–422  ·  view source on GitHub ↗
(
        self,
        account_id: str,
        *,
        refresh_fingerprint: bool = False,
        flow: FlowRun | None = None,
    )

Source from the content-addressed store, hash-verified

348 sess=challenge.sess,
349 sid=challenge.sid,
350 instruction=challenge.instruction,
351 raw=challenge.raw,
352 ocr=payload.get("ocr") if isinstance(payload.get("ocr"), dict) else None,
353 )
354 self.state_service.save_session(session)
355 ocr = payload.get("ocr") if isinstance(payload.get("ocr"), dict) else {}
356 self.runtime_logs.log_event(
357 flow,
358 stage="captcha_challenge",
359 status="success",
360 message="验证码图片获取成功",
361 details={
362 "instruction": challenge.instruction,
363 "image_size": len(image_bytes),
364 "ocr_points": len(ocr.get("points") or []) if isinstance(ocr.get("points"), list) else 0,
365 "ocr_confidence": ocr.get("confidence"),
366 "worker_pid": ocr.get("_worker_pid"),
367 "worker_elapsed_ms": ocr.get("_worker_elapsed_ms"),
368 },
369 )
370 if own_flow:
371 self.runtime_logs.finish_run(
372 flow,
373 status="success",
374 message="验证码获取完成",
375 )
376 return payload
377 except Exception as exc:
378 if own_flow:
379 self.runtime_logs.finish_run(
380 flow,
381 status="failed",
382 message=f"验证码获取失败:{exc}",
383 details={"error": exc.__class__.__name__},
384 level=logging.ERROR,
385 )
386 raise
387
388 def build_captcha_verify_payload(
389 self,
390 account_id: str,
391 request: CaptchaVerifyPayloadRequest,
392 ) -> dict[str, Any]:
393 account = self.state_service.get_account(account_id)
394 session = self.state_service.load_session(account_id)
395 request, tdc_result = self._hydrate_tdc_if_needed(account, session, request)
396 payload = self.captcha_service.build_verify_payload(session, request)
397 payload["challenge"] = {
398 "sess": session.captcha_challenge_sess,
399 "sid": session.captcha_challenge_sid,
400 "instruction": session.captcha_challenge_instruction,
401 "updated_at": session.captcha_challenge_updated_at,
402 }
403 if tdc_result:
404 payload["tdc"] = tdc_result
405 self._attach_pow_if_needed(session, request, payload)
406 return payload
407

Callers 5

import_accountMethod · 0.95
load_productsMethod · 0.95
_ensure_contextMethod · 0.95
bootstrap_accountFunction · 0.80

Calls 7

utc_now_isoFunction · 0.90
start_runMethod · 0.80
finish_runMethod · 0.80
log_eventMethod · 0.80
get_accountMethod · 0.80
update_accountMethod · 0.80

Tested by

no test coverage detected