added full gifts support
This commit is contained in:
parent
ea5b86de8f
commit
354128c106
35 changed files with 1502 additions and 103 deletions
|
|
@ -0,0 +1,9 @@
|
|||
-- Remove the built-in @gif seed. Its private history is left alone: chat rows
|
||||
-- reference the account, and dropping them would rewrite users' dialogs.
|
||||
DELETE FROM public.read_model_versions
|
||||
WHERE owner_user_id = 1250000015 AND peer_type = 'user' AND peer_id = 1250000015;
|
||||
|
||||
DELETE FROM public.peer_usernames
|
||||
WHERE peer_type = 'user' AND peer_id = 1250000015;
|
||||
|
||||
DELETE FROM public.bots WHERE bot_user_id = 1250000015;
|
||||
85
deploy/migrations/20260807120000_gif_service_bot.up.sql
Normal file
85
deploy/migrations/20260807120000_gif_service_bot.up.sql
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
-- Built-in @gif: answers messages.getInlineBotResults synchronously (server-side,
|
||||
-- no MTProto session or Bot API process -- see rpc.ServiceBotInlineResults) with
|
||||
-- the admin-curated GIF catalog, the same role Telegram's own @gif plays for the
|
||||
-- client's GIF picker "trending"/search panel.
|
||||
--
|
||||
-- Seeded here rather than lazily on first message so the username is occupied
|
||||
-- from the moment the schema is current, same rationale as 20260714003112's
|
||||
-- @verifybot seed.
|
||||
--
|
||||
-- access_hash is double-written with domain.GifBotAccessHash; the two must never
|
||||
-- drift, exactly as for the other service bots.
|
||||
--
|
||||
-- inline_placeholder must be non-empty: internal/rpc/bots_inline.go's
|
||||
-- onMessagesGetInlineBotResults refuses BOT_INLINE_DISABLED otherwise.
|
||||
|
||||
INSERT INTO public.users (
|
||||
id, access_hash, phone, first_name, last_name, username, country_code,
|
||||
created_at, updated_at, verified, support, about, last_seen_at,
|
||||
default_history_ttl_period, is_bot, bot_info_version, premium_expires_at,
|
||||
emoji_status_document_id, emoji_status_until, color_set, color,
|
||||
color_background_emoji_id, profile_color_set, profile_color,
|
||||
profile_color_background_emoji_id
|
||||
) VALUES (
|
||||
1250000015, 7233282977235616768, '', 'GIFs', '', 'gif', '',
|
||||
now(), now(), true, false,
|
||||
'Search and browse this server''s GIF catalog.',
|
||||
0, 0, true, 1, NULL, 0, 0, false, 0, 0, false, 0, 0
|
||||
)
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
access_hash = EXCLUDED.access_hash,
|
||||
phone = EXCLUDED.phone,
|
||||
first_name = EXCLUDED.first_name,
|
||||
last_name = EXCLUDED.last_name,
|
||||
username = EXCLUDED.username,
|
||||
verified = EXCLUDED.verified,
|
||||
support = EXCLUDED.support,
|
||||
about = EXCLUDED.about,
|
||||
is_bot = EXCLUDED.is_bot,
|
||||
bot_info_version = GREATEST(public.users.bot_info_version, EXCLUDED.bot_info_version),
|
||||
updated_at = now();
|
||||
|
||||
INSERT INTO public.bots (
|
||||
bot_user_id, owner_user_id, token_secret, description, commands,
|
||||
bot_chat_history, bot_nochats, inline_placeholder, created_at, updated_at,
|
||||
menu_button_type, menu_button_text, menu_button_url, bot_inline_geo
|
||||
) VALUES (
|
||||
1250000015, 1250000015, '',
|
||||
'Search and browse this server''s GIF catalog from the GIF picker.',
|
||||
'[]'::jsonb,
|
||||
false, true, 'Search GIFs', now(), now(), 0, '', '', false
|
||||
)
|
||||
ON CONFLICT (bot_user_id) DO UPDATE SET
|
||||
owner_user_id = EXCLUDED.owner_user_id,
|
||||
token_secret = EXCLUDED.token_secret,
|
||||
description = EXCLUDED.description,
|
||||
commands = EXCLUDED.commands,
|
||||
bot_chat_history = EXCLUDED.bot_chat_history,
|
||||
bot_nochats = EXCLUDED.bot_nochats,
|
||||
inline_placeholder = EXCLUDED.inline_placeholder,
|
||||
menu_button_type = EXCLUDED.menu_button_type,
|
||||
menu_button_text = EXCLUDED.menu_button_text,
|
||||
menu_button_url = EXCLUDED.menu_button_url,
|
||||
bot_inline_geo = EXCLUDED.bot_inline_geo,
|
||||
updated_at = now();
|
||||
|
||||
INSERT INTO public.peer_usernames (
|
||||
username_lower, username, peer_type, peer_id, active, editable, sort_order, updated_at
|
||||
)
|
||||
VALUES ('gif', 'gif', 'user', 1250000015, true, true, 0, now())
|
||||
ON CONFLICT (username_lower) DO UPDATE SET
|
||||
username = EXCLUDED.username,
|
||||
peer_type = EXCLUDED.peer_type,
|
||||
peer_id = EXCLUDED.peer_id,
|
||||
active = EXCLUDED.active,
|
||||
editable = EXCLUDED.editable,
|
||||
updated_at = now();
|
||||
|
||||
INSERT INTO public.read_model_versions (model, owner_user_id, peer_type, peer_id, version, updated_at, hash)
|
||||
VALUES
|
||||
('contact_account', 1250000015, 'user', 1250000015, 1, now(), 12500000150001),
|
||||
('channel_active_memberships', 1250000015, 'user', 1250000015, 1, now(), 12500000150002)
|
||||
ON CONFLICT (model, owner_user_id, peer_type, peer_id) DO UPDATE SET
|
||||
version = GREATEST(public.read_model_versions.version, EXCLUDED.version),
|
||||
updated_at = now(),
|
||||
hash = EXCLUDED.hash;
|
||||
1
deploy/migrations/20260807120001_gif_catalog.down.sql
Normal file
1
deploy/migrations/20260807120001_gif_catalog.down.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
DROP TABLE IF EXISTS public.gif_catalog;
|
||||
17
deploy/migrations/20260807120001_gif_catalog.up.sql
Normal file
17
deploy/migrations/20260807120001_gif_catalog.up.sql
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
-- Admin-curated GIF catalog: what @gif (see 20260807120000) serves as inline
|
||||
-- results for the client's GIF picker. document_id/document_ids are loose
|
||||
-- bigint references (no FK), matching every other media table in this schema
|
||||
-- (e.g. sticker_sets.thumb_document_id) -- documents are immutable once
|
||||
-- created, so there is nothing to cascade.
|
||||
CREATE TABLE public.gif_catalog (
|
||||
id bigint PRIMARY KEY,
|
||||
title text DEFAULT ''::text NOT NULL,
|
||||
document_id bigint NOT NULL,
|
||||
enabled boolean DEFAULT true NOT NULL,
|
||||
sort_order integer DEFAULT 0 NOT NULL,
|
||||
created_by text DEFAULT ''::text NOT NULL,
|
||||
created_at timestamp with time zone DEFAULT now() NOT NULL,
|
||||
updated_at timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX gif_catalog_enabled_sort_idx ON public.gif_catalog (enabled, sort_order, id);
|
||||
Loading…
Add table
Add a link
Reference in a new issue