Orbeo DevОткрыть в Orbeo

Архив · страница 2 из 2 · 2 ноября 2026 — 7 ноября 2026

⚡ How we made opening a chat 40× faster

This week we dug into why chats were slow to open. The culprit wasn't the network or the phone — it was the database access rules (Row Level Security in Postgres).

Before. The rule "only members can see a conversation's members" called a check function for every row. In a conversation with hundreds of people that's hundreds of calls per query: 117 ms.

After. The function now returns the whole set of the user's conversations, and the rule checks membership in it:

using (conversation_id in (select my_conversation_ids()))

Postgres evaluates that subquery once and matches rows against a hash table: 3 ms. Message search got the same treatment — from ~0.7 s down to 18 ms.

💡 Tips if you run Postgres or Supabase too:
• wrap calls inside policies in (select …) — even auth.uid(): user_id = (select auth.uid());
• run EXPLAIN ANALYZE as the real role (set role authenticated), not as an admin — admins bypass policies, so everything looks "fast";
• before swapping a policy, compare what every user sees before and after inside a transaction ending in rollback. We checked 635 accounts this way — not a single extra or missing row.

Questions — DM @orbeo_help.

#orbeodev #postgres #performance

⚡ Как мы ускорили открытие чата в 40 раз

На этой неделе разбирались, почему чат открывается с задержкой. Виновником оказалась не сеть и не телефон, а правила доступа в базе (Row Level Security в Postgres).

Что было. Правило «видеть участников беседы может только её участник» вызывало проверочную функцию для каждой строки. В беседе на сотни человек — сотни вызовов на один запрос: 117 мс.

Что стало. Функция теперь возвращает сразу множество бесед человека, а правило проверяет вхождение:

using (conversation_id in (select my_conversation_ids()))

Postgres считает такой подзапрос один раз и сверяет строки по хеш-таблице: 3 мс. Поиск по сообщениям тем же приёмом — с ~0,7 с до 18 мс.

💡 Совет, если у вас тоже Postgres или Supabase:
• оборачивайте вызовы в правилах в (select …) — даже auth.uid(): user_id = (select auth.uid());
• смотрите EXPLAIN ANALYZE от имени настоящей роли (set role authenticated), а не от админа — у админа правила не работают и всё «быстро»;
• перед заменой правила сравните, что видит каждый пользователь до и после, в транзакции с rollback. Мы так сверили 635 аккаунтов — ни одной лишней или пропавшей строки.

Вопросы — в личку @orbeo_help.

#orbeodev #postgres #performance

📎 Bots can now send files and videos

Until now sendDocument and sendVideo in the Orbeo Bot API returned an error: only photos and audio were accepted. Fixed as of November 6:

• sendDocument — any file: PDFs, archives, spreadsheets;
• sendVideo — videos with a cover and duration;
• the file_id from the response can be sent again without re-uploading;
• getFile returns a link the bot can use to download files sent to it.

Same as Telegram: aiogram and Telegraf code works unchanged.

🔒 Protected chats. When forwarding is disabled in a chat, messages arrive with has_protected_content: true, and copyMessage won't copy them (or view-once photos).

💡 Telegraf: end the server address with a slash — apiRoot: 'https://orbeo.me/botapi/'. Without it, requests go to the wrong place.

Questions — DM @orbeo_help.

#orbeodev #botapi

📎 Боты теперь отправляют файлы и видео

Раньше sendDocument и sendVideo в Bot API Orbeo отвечали ошибкой: принимались только фото и звук. С 6 ноября это починено:

• sendDocument — любые файлы: PDF, архивы, таблицы;
• sendVideo — ролики с обложкой и длительностью;
• file_id из ответа можно отправить снова, без повторной загрузки;
• getFile отдаёт ссылку, по которой бот скачивает присланный ему файл.

Всё как в Telegram: код на aiogram и Telegraf работает без правок.

🔒 Защищённые чаты. Если в беседе включён запрет пересылки, у сообщений приходит has_protected_content: true, а copyMessage такое сообщение (и «одноразовое» фото) не копирует.

💡 Telegraf: адрес сервера пишите со слешем на конце — apiRoot: 'https://orbeo.me/botapi/'. Без слеша запросы уходят мимо.

Вопросы — в личку @orbeo_help.

#orbeodev #botapi

orbeo-bot-starter.zip11,3 КБ · скачать в Orbeo

📦 Все файлы канала одним архивом · All files in one archive

Эхо-бот, aiogram, Telegraf, репост из Telegram, ИИ-автопостер, шпаргалка. · Echo bot, aiogram, Telegraf, Telegram mirror, AI autoposter, cheatsheet.

Вопросы и идеи для следующих постов — в личку @orbeo_help. · Questions and ideas for next posts — DM @orbeo_help.

orbeo.me · мессенджер без номера телефона