feat: sync bot keyboards and callbacks

Sync telesrv b96f2dd (feat(bot): complete keyboards callbacks and durable delivery).

Skipped private docs and preserved public README files per sync rules; normalized the appearance seed log label for public naming.
This commit is contained in:
A 2026-07-19 20:38:48 +08:00
parent 0c99ae0a9d
commit bf965f610c
80 changed files with 7212 additions and 349 deletions

View file

@ -0,0 +1,27 @@
CREATE TABLE public.bot_api_webhooks (
bot_user_id bigint PRIMARY KEY REFERENCES public.users(id) ON DELETE CASCADE,
url text NOT NULL,
secret_token varchar(256) NOT NULL DEFAULT '',
max_connections integer NOT NULL DEFAULT 40,
allowed_updates text[],
failure_count integer NOT NULL DEFAULT 0,
last_error_date integer NOT NULL DEFAULT 0,
last_error_message varchar(512) NOT NULL DEFAULT '',
next_attempt_at timestamptz NOT NULL DEFAULT now(),
delivery_owner text NOT NULL DEFAULT '',
delivery_expires_at timestamptz,
updated_at timestamptz NOT NULL DEFAULT now(),
CONSTRAINT bot_api_webhooks_url_check CHECK (length(url) BETWEEN 1 AND 2048),
CONSTRAINT bot_api_webhooks_max_connections_check CHECK (max_connections BETWEEN 1 AND 100),
CONSTRAINT bot_api_webhooks_failure_count_check CHECK (failure_count >= 0),
CONSTRAINT bot_api_webhooks_allowed_updates_check CHECK (
allowed_updates IS NULL OR array_position(allowed_updates, NULL) IS NULL
),
CONSTRAINT bot_api_webhooks_delivery_lease_check CHECK (
(delivery_owner = '' AND delivery_expires_at IS NULL)
OR (delivery_owner <> '' AND delivery_expires_at IS NOT NULL)
)
);
CREATE INDEX bot_api_webhooks_due_idx
ON public.bot_api_webhooks (next_attempt_at, bot_user_id);