feat: sync multilayer td integration

This commit is contained in:
A 2026-07-15 13:32:06 +08:00
parent 20a310f6ca
commit 766c5db992
491 changed files with 26235 additions and 35340 deletions

View file

@ -5,9 +5,12 @@ import "time"
// Authorization 是一条设备授权auth_key 与 user 的绑定 + initConnection 设备信息。
// auth_key 是协议产物、授权是业务产物,故独立于 store.AuthKeyData。
type Authorization struct {
AuthKeyID [8]byte // 协议原生 auth_key_idstore 边界按小端转 int64
UserID int64
Hash int64
AuthKeyID [8]byte // 协议原生 auth_key_idstore 边界按小端转 int64
UserID int64
Hash int64
// Layer is the last supported protocol profile explicitly observed for this
// auth key. It is a durable default for a new session, never an instruction
// to rewrite an already-active session's own profile.
Layer int
DeviceModel string
Platform string
@ -23,13 +26,18 @@ type Authorization struct {
}
// AuthKeyClientInfo 是未登录 auth_key 也需要保留的客户端协商元数据。
// 登录后的设备授权仍由 Authorization 表达;这里仅用于服务端重启后恢复
// pre-auth / setup 流程的 client type 与 layer。
// 登录后的设备授权仍由 Authorization 表达。Layer 保存最后一次受支持的显式
// wire profile供服务端重启后为同一 auth key 的新 session 初始化默认值;活跃
// session 仍以自己的显式 invokeWithLayer 纠正值为准。
type AuthKeyClientInfo struct {
Layer int
DeviceModel string
Platform string
SystemVersion string
APIID int
AppVersion string
Layer int
// LayerObservationID is a read-only ordering token owned by the protocol
// store. Generic client metadata updates must never manufacture or advance
// it; only ordered invokeWithLayer evidence may do so.
LayerObservationID int64
DeviceModel string
Platform string
SystemVersion string
APIID int
AppVersion string
}

View file

@ -1,4 +1,4 @@
// Package domain 存放业务实体与值对象User、Peer、Dialog、Message、MessageID 等)。
//
// 铁律:本包禁止依赖 gotd/td/tg 等协议层类型TL 类型只允许出现在 RPC/MTProto 边界。
// 铁律:本包禁止依赖 iamxvbaba/td/tg 等协议层类型TL 类型只允许出现在 RPC/MTProto 边界。
package domain

View file

@ -8,3 +8,14 @@ type UpdateState struct {
Date int
Seq int
}
// UpdateStateCommitMode describes what a physically delivered update-state
// response proves. Every delivered baseline advances the device-local
// confirmed cursor; only an explicitly audited getState baseline also proves
// that retention may advance the client-observed cursor to the same point.
type UpdateStateCommitMode uint8
const (
UpdateStateCommitDeliveredOnly UpdateStateCommitMode = iota + 1
UpdateStateCommitDeliveredAndObservedBaseline
)