diff --git a/client/lib/models/me.dart b/client/lib/models/me.dart index 6165933..dc581da 100644 --- a/client/lib/models/me.dart +++ b/client/lib/models/me.dart @@ -43,7 +43,7 @@ class Me { bool get isFree => plan == 'free'; factory Me.fromJson(Map m) { - final exp = (m['expires_at'] ?? m['expire_at']) as String?; + final exp = m['expires_at'] as String?; return Me( email: m['email'] as String? ?? '', plan: m['plan'] as String? ?? 'free', diff --git a/client/test/contract/api_contract_test.dart b/client/test/contract/api_contract_test.dart index c1d8742..fb63bd3 100644 --- a/client/test/contract/api_contract_test.dart +++ b/client/test/contract/api_contract_test.dart @@ -87,14 +87,6 @@ void main() { expect(me.weeklyGb, hasLength(7)); expect(me.totpEnabled, isTrue); }); - - test('expires_at 接受别名 expire_at(后端历史兼容)', () { - final me = Me.fromJson({ - ..._meSample()..remove('expires_at'), - 'expire_at': '2027-01-01T00:00:00Z', - }); - expect(me.expiresAt, DateTime.tryParse('2027-01-01T00:00:00Z')); - }); }); group('/v1/usage 契约快照(UsagePoint)', () { diff --git a/server/internal/httpapi/account.go b/server/internal/httpapi/account.go index 4c53253..14b16d2 100644 --- a/server/internal/httpapi/account.go +++ b/server/internal/httpapi/account.go @@ -26,9 +26,7 @@ type meResponse struct { Email string `json:"email"` DpUUID string `json:"dp_uuid"` Plan string `json:"plan"` // "free" | "pro" | "team" - // expire_at kept for the existing app; expires_at is the same value for the - // web user-center (both RFC3339 UTC, null = no active sub). - ExpireAt *string `json:"expire_at"` + // expires_at: RFC3339 UTC, null = no active subscription. ExpiresAt *string `json:"expires_at"` // Web user-center fields. DevicesUsed int `json:"devices_used"` @@ -120,7 +118,6 @@ func (a *AccountAPI) GetMe(w http.ResponseWriter, r *http.Request) { } if expiresAt.Valid { s := expiresAt.Time.UTC().Format(time.RFC3339) - resp.ExpireAt = &s resp.ExpiresAt = &s } // quota_today_min: null when the plan is unlimited, else remaining minutes. diff --git a/server/internal/httpapi/contract_test.go b/server/internal/httpapi/contract_test.go index 8e64f3a..35775d1 100644 --- a/server/internal/httpapi/contract_test.go +++ b/server/internal/httpapi/contract_test.go @@ -6,8 +6,8 @@ package httpapi // 同步客户端 model + 文档,避免控制面与客户端悄悄分叉。 // // ⚠️ 与客户端冻结集对账:client/test/contract/api_contract_test.dart 的 _frozenMeKeys -// (9 个)。后端这里多发 uuid / dp_uuid,且同时发 expire_at + expires_at(别名):客户端 -// 故意忽略 uuid/dp_uuid、把 expire_at 当 expires_at 的回退。改任一端都要回看另一端。 +// (9 个)。后端这里多发 uuid / dp_uuid(客户端故意忽略);expire_at 已废弃移除—— +// 无 web 用户中心后,两端统一只用 expires_at。改任一端都要回看另一端。 import ( "reflect" @@ -54,8 +54,7 @@ func assertFrozenKeys(t *testing.T, name string, got map[string]struct{}, want . func TestContractMeResponse(t *testing.T) { assertFrozenKeys(t, "/v1/me", jsonTagSet(meResponse{}), - "uuid", "email", "dp_uuid", "plan", - "expire_at", "expires_at", + "uuid", "email", "dp_uuid", "plan", "expires_at", "devices_used", "devices_max", "quota_today_min", "data_today_gb", "weekly_gb", "totp_enabled", )