channels: give kicked/banned/promoted/transferred users a real qts so their client applies it

updateChannelParticipant carries the account's qts per the MTProto spec, but
the server always sent Qts: 0, so real clients silently discarded it as a
stale duplicate -- the banned/kicked user's channel never vanished locally
and no correct "removed by admin" message showed, even though the update was
delivered successfully at the transport layer.

Add a durable per-device qts queue (channel_participant_event_queue) sharing
its qts number space with the existing secret-chat queue (one qts sequence
per device, per spec), and use it to stamp a correct, monotonically
increasing qts on the update for every device of the affected user -- for
channel bans/kicks, admin promotion/demotion, and ownership transfer. A
device offline when it happened can now recover the event via
updates.getDifference instead of missing it permanently.
This commit is contained in:
Astra 2026-09-15 15:43:52 +01:00
parent 97711c9d2e
commit 206bde18e0
16 changed files with 482 additions and 42 deletions

View file

@ -1237,6 +1237,17 @@ type SecretChatService interface {
MarkStateEventsDelivered(ctx context.Context, deviceAuthKeyID int64, eventIDs []int64) error
PutEncryptedFile(ctx context.Context, ownerUserID int64, ref domain.EncryptedFileRef) error
GetEncryptedFile(ctx context.Context, id, accessHash int64) (domain.EncryptedFileRef, bool, error)
// AppendChannelParticipantEvent durably enqueues a channel-membership
// self-notification (kick/ban/promote/transfer) for one device, reserving
// that device's next qts from the same watermark as secret chat messages.
AppendChannelParticipantEvent(ctx context.Context, ev domain.DeviceChannelParticipantEvent) (domain.DeviceChannelParticipantEvent, error)
// ListChannelParticipantEventsSince returns a device's channel-membership
// self-notifications with qts > sinceQts (getDifference catch-up).
ListChannelParticipantEventsSince(ctx context.Context, deviceAuthKeyID int64, sinceQts, limit int) ([]domain.DeviceChannelParticipantEvent, error)
// AckChannelParticipantEvents marks a device's channel-membership
// self-notifications up to maxQts as delivered.
AckChannelParticipantEvents(ctx context.Context, deviceAuthKeyID int64, maxQts int) error
}
// PhoneService 抽象私聊 1:1 通话信令状态机app/phone。所有返回值都是状态快照