From f636836f47e463bc50244d9db469334f42086de2 Mon Sep 17 00:00:00 2001 From: Yuri Yaryshev Date: Mon, 23 Nov 2026 16:30:08 +0300 Subject: [PATCH] =?UTF-8?q?accounting=5Fautomation:=20Gmail=20=D1=87=D0=B8?= =?UTF-8?q?=D1=82=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D0=BE=D1=82=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=20agents@=20(=D1=83=D1=87=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D0=BD=D0=B8=D0=BA=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B?= =?UTF-8?q?=20invoice@),=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B0=D0=BC=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- packages/accounting_automation/src/main.ts | 1 + packages/accounting_automation/src/settings.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/accounting_automation/src/main.ts b/packages/accounting_automation/src/main.ts index a12d192..36cfb27 100644 --- a/packages/accounting_automation/src/main.ts +++ b/packages/accounting_automation/src/main.ts @@ -64,6 +64,7 @@ const app = buildApi({ const mail = new GmailClient({ auth, user: s.google.gmailUser, + query: s.google.gmailQuery, processedIds: async (ids) => { const { rows } = await pool.query("select message_id from acc_mail_processed where message_id = any($1) and result <> 'error'", [ids]); return new Set(rows.map((r) => r.message_id as string)); diff --git a/packages/accounting_automation/src/settings.ts b/packages/accounting_automation/src/settings.ts index 1685236..695108d 100644 --- a/packages/accounting_automation/src/settings.ts +++ b/packages/accounting_automation/src/settings.ts @@ -27,8 +27,10 @@ export const accountingSchema = z.object({ .object({ client_email: z.string(), private_key: z.string(), - /** Ящик, который читаем (делегирование домена). */ - gmailUser: z.string().default("invoices@khbuild.pro"), + /** Ящик пользователя, который читаем (делегирование домена; группа invoice@ доставляет письма в ящик участника agents@). */ + gmailUser: z.string().default("agents@khbuild.pro"), + /** Поиск писем в ящике: только письма, пришедшие на группу invoice@ (или алиас invoices@), с PDF. */ + gmailQuery: z.string().default("has:attachment filename:pdf (to:invoice@khbuild.pro OR cc:invoice@khbuild.pro OR to:invoices@khbuild.pro OR cc:invoices@khbuild.pro)"), /** Корневая папка Google Drive для инвойсов, чеков и т.д. (подпапки создаются сервисом). */ rootFolderId: z.string().optional(), })