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

Method updater

app/services/account_state.py:78–155  ·  view source on GitHub ↗
(records: list[dict[str, Any]])

Source from the content-addressed store, hash-verified

76 break
77 else:
78 for idx, item in enumerate(records):
79 if item.get("label") == request.label:
80 index = idx
81 account_id = str(item.get("id") or "")
82 break
83 if not account_id:
84 account_id = make_id("acct")
85 resolved_account_id["value"] = account_id
86
87 existing = records[index] if index >= 0 else None
88 created_at = str(existing.get("created_at")) if existing else now
89 last_bootstrap_at = existing.get("last_bootstrap_at") if existing else None
90 existing_impersonate = str(existing.get("browser_impersonate") or "") if existing else ""
91 requested_impersonate = (request.browser_impersonate or "").strip()
92 if requested_impersonate:
93 browser_impersonate = resolve_browser_impersonate(requested_impersonate)
94 elif existing_impersonate:
95 browser_impersonate = resolve_browser_impersonate(existing_impersonate)
96 else:
97 browser_impersonate = random_browser_impersonate()
98 record = AccountRecord(
99 id=account_id,
100 label=request.label,
101 token=token,
102 cookie_header=cookie_header,
103 cookies=cookies,
104 org_id=request.org_id.strip(),
105 project_id=request.project_id.strip(),
106 invitation_code=request.invitation_code.strip() or DEFAULT_INVITATION_CODE,
107 proxy_url=request.proxy_url.strip(),
108 user_agent=request.user_agent.strip(),
109 browser_impersonate=browser_impersonate,
110 schedule_enabled=bool(existing.get("schedule_enabled")) if existing else False,
111 scheduled_start_time=str(existing.get("scheduled_start_time") or DEFAULT_SCHEDULED_START_TIME) if existing else DEFAULT_SCHEDULED_START_TIME,
112 last_scheduled_run_at=existing.get("last_scheduled_run_at") if existing else None,
113 last_schedule_status=str(existing.get("last_schedule_status") or "") if existing else "",
114 last_schedule_message=str(existing.get("last_schedule_message") or "") if existing else "",
115 account_status=str(existing.get("account_status") or "unchecked") if existing else "unchecked",
116 account_status_message=str(existing.get("account_status_message") or "") if existing else "",
117 account_checked_at=existing.get("account_checked_at") if existing else None,
118 created_at=created_at,
119 updated_at=now,
120 last_bootstrap_at=last_bootstrap_at,
121 ).model_dump()
122 if index >= 0:
123 records[index] = record
124 else:
125 records.append(record)
126 return records
127
128 updated_records = self.accounts_store.update(updater)
129 account = next(
130 AccountRecord.model_validate(item)
131 for item in updated_records
132 if item.get("id") == resolved_account_id["value"]
133 )
134
135 session = self.load_session(account.id)

Callers

nothing calls this directly

Calls 6

AccountRecordClass · 0.90
NotFoundErrorClass · 0.90
make_idFunction · 0.85

Tested by

no test coverage detected