feat(api)!: fold devices into users and report member presence

Contract 7.0.0 (breaking). Devices become an attribute of the account;
members are managed per user, and only unauthenticated guests keep a
per-terminal registration.

- rename seats -> max_members, seats_used -> members_used,
  seats_full -> members_full, SeatJoined -> JoinResult, the `seats`
  stream control message -> `members`, and POST /channels/{id}/seats ->
  POST /channels/{id}/join (stored channel settings are migrated on start)
- drop per-terminal encrypted device labels and the seat list/release
  endpoints; add GET/DELETE /channels/{id}/guests for guest terminals
- authenticate account members by account session only: the terminal key
  is optional for logged-in accounts, no seat row is written for them,
  and gated-download grants are counted per user (per terminal for guests)
- GET /channels/{id}/members now returns online, devices and
  online_devices per account; presence is tracked in memory from active
  WebSocket/SSE subscriptions and is not pushed over the stream
- owner invitation list no longer returns accounts that already joined
This commit is contained in:
justme committed 2026-10-14 22:18:59 +08:00
1 parent 0fd2a269d9
commit d946fc5e8a
35 files changed
+517 -490

No files matched your search

+3 -3
View File
@@ -46,12 +46,12 @@ try {
$ownerH = Headers 'owner' $ownerTok $ownerSecret
$created = Invoke-RestMethod "$base/api/v1/channels" -Method Post -Body $body -ContentType 'application/json' -Headers $ownerH
Check ($created.id -eq (B64 $id) -and $created.seats_used -eq 1) '创建频道成功'
Check ($created.id -eq (B64 $id) -and $created.members_used -eq 1) '创建频道成功'
$cid = B64 $id
$memberH = Headers 'write' $writeTok $memberSecret
$joined = Invoke-RestMethod "$base/api/v1/channels/$cid/seats" -Method Post -Headers $memberH
Check ($joined.seats_used -eq 2) '成员加入'
$joined = Invoke-RestMethod "$base/api/v1/channels/$cid/join" -Method Post -Headers $memberH
Check ($joined.members_used -eq 2) '成员加入'
# enc 帧:负载 = 1024 档位 + 16 标签
$item = Rand 16
+2 -2
View File
@@ -71,8 +71,8 @@ try:
check(status == 201, "创建频道")
ch = b64(cid)
status, body = call("POST", f"/api/v1/channels/{ch}/seats", member_h)
check(status == 200 and json.loads(body)["seats_used"] == 2, "成员加入")
status, body = call("POST", f"/api/v1/channels/{ch}/join", member_h)
check(status == 200 and json.loads(body)["members_used"] == 2, "成员加入")
item = os.urandom(16)
f = frame(item, 0, 9, 1040, 0x42)