refactor: use shared pairing store for telegram

This commit is contained in:
Ayaan Zaidi
2026-02-01 14:55:41 +05:30
committed by Ayaan Zaidi
parent ca92597e1f
commit 24fbafa9a7
23 changed files with 95 additions and 288 deletions

View File

@@ -29,6 +29,7 @@ import { formatCliCommand } from "../cli/command-format.js";
import { readSessionUpdatedAt, resolveStorePath } from "../config/sessions.js";
import { logVerbose, shouldLogVerbose } from "../globals.js";
import { recordChannelActivity } from "../infra/channel-activity.js";
import { upsertChannelPairingRequest } from "../pairing/pairing-store.js";
import { resolveAgentRoute } from "../routing/resolve-route.js";
import { resolveThreadSessionKeys } from "../routing/session-key.js";
import { withTelegramApiErrorLogging } from "./api-logging.js";
@@ -52,7 +53,6 @@ import {
hasBotMention,
resolveTelegramForumThreadId,
} from "./bot/helpers.js";
import { upsertTelegramPairingRequest } from "./pairing-store.js";
type TelegramMediaRef = {
path: string;
@@ -252,11 +252,14 @@ export const buildTelegramMessageContext = async ({
}
| undefined;
const telegramUserId = from?.id ? String(from.id) : candidate;
const { code, created } = await upsertTelegramPairingRequest({
chatId: candidate,
username: from?.username,
firstName: from?.first_name,
lastName: from?.last_name,
const { code, created } = await upsertChannelPairingRequest({
channel: "telegram",
id: String(candidate),
meta: {
username: from?.username,
firstName: from?.first_name,
lastName: from?.last_name,
},
});
if (created) {
logger.info(