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.
21 lines
1 KiB
SQL
21 lines
1 KiB
SQL
-- Durable per-device qts queue for channel-membership self-notifications
|
|
-- (kick/ban/promote/demote/ownership transfer). Shares the qts number space
|
|
-- in secret_qts_watermarks with encrypted_message_queue: a device has one
|
|
-- qts sequence, and updateChannelParticipant rides it per the MTProto spec,
|
|
-- so a disconnected device can recover a missed kick/ban via
|
|
-- updates.getDifference instead of losing it once its live push is missed.
|
|
CREATE TABLE public.channel_participant_event_queue (
|
|
receiver_auth_key_id bigint NOT NULL,
|
|
qts integer NOT NULL,
|
|
receiver_user_id bigint NOT NULL,
|
|
channel_id bigint NOT NULL,
|
|
actor_user_id bigint NOT NULL,
|
|
date integer NOT NULL,
|
|
previous_participant jsonb,
|
|
new_participant jsonb,
|
|
acked boolean DEFAULT false NOT NULL,
|
|
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
|
PRIMARY KEY (receiver_auth_key_id, qts)
|
|
);
|
|
|
|
CREATE INDEX idx_cpeq_unacked ON public.channel_participant_event_queue USING btree (receiver_auth_key_id, qts) WHERE (acked = false);
|