Personal Telegram developer console for GitHub

fix: align workspace upload limit with editor policy

davoodmehraban89 committed Oct 4, 2026 at 11:22 UTC 4a191a2aa1bbc244970c7b04847aae0089d36343
1 file changed +7 -5
src/bot.js
+7 -5
@@ -6,6 +6,7 @@ import { ActionPolicy } from './core/action-policy.js';
6 import { ApprovalService } from './core/approval.js';
7 import { DurableApprovalReplayStore } from './core/durable-replay-store.js';
8 import { DurableWorkspaceStoreClient } from './core/workspace-store.js';
9 +import { WORKSPACE_EDITOR_LIMITS } from './core/workspace-policy.js';
10 import { AuditLogger } from './core/audit.js';
11 import { PluginRouter } from './core/router.js';
12 import { buildApprovedActionFailedView, buildCallbackFailureView } from './core/callback-failure-view.js';
@@ -314,25 +315,26 @@ export class NexaDevBot {
315 let payload = { pending, text: rawText };
316 if (pending.mode === 'draft_file') {
317 const document = message.document;
318 + const maxUploadBytes = WORKSPACE_EDITOR_LIMITS.maxBytes;
319 if (!document?.file_id) {
320 const view = {
319 - text: '📎 <b>یک فایل متنی ارسال کنید</b>\nاین Workspace در حالت بارگذاری فایل است. فایل باید UTF-8 معتبر و حداکثر 12,000 بایت باشد.',
321 + text: `📎 <b>یک فایل متنی ارسال کنید</b>\nاین Workspace در حالت بارگذاری فایل است. فایل باید UTF-8 معتبر و حداکثر ${maxUploadBytes.toLocaleString('en-US')} بایت باشد.`,
322 reply_markup: { inline_keyboard: [[{ text: '↩️ بازگشت به Draft', callback_data: `ws:${pending.workspaceId}` }]] }
323 };
324 const res = await this.telegram.sendMessage(chatId, view.text, view.reply_markup);
325 return { ok: true, workspaceInput: true, inputRequired: 'document', res };
326 }
325 - if (Number.isFinite(Number(document.file_size)) && Number(document.file_size) > 12000) {
327 + if (Number.isFinite(Number(document.file_size)) && Number(document.file_size) > maxUploadBytes) {
328 const view = {
327 - text: '⚠️ <b>فایل پذیرفته نشد</b>\nحجم فایل بیشتر از سقف 12,000 بایت است. Draft تغییر نکرد؛ یک فایل کوچک‌تر ارسال کنید.',
329 + text: `⚠️ <b>فایل پذیرفته نشد</b>\nحجم فایل بیشتر از سقف ${maxUploadBytes.toLocaleString('en-US')} بایت است. Draft تغییر نکرد؛ یک فایل کوچک‌تر ارسال کنید.`,
330 reply_markup: { inline_keyboard: [[{ text: '↩️ بازگشت به Draft', callback_data: `ws:${pending.workspaceId}` }]] }
331 };
332 const res = await this.telegram.sendMessage(chatId, view.text, view.reply_markup);
331 - return { ok: false, workspaceInput: true, inputRejected: true, error: 'Telegram file exceeds 12000 byte size limit', res };
333 + return { ok: false, workspaceInput: true, inputRejected: true, error: `Telegram file exceeds ${maxUploadBytes} byte size limit`, res };
334 }
335 let downloaded;
336 try {
335 - downloaded = await this.telegram.downloadTextFile(document.file_id, { maxBytes: 12000 });
337 + downloaded = await this.telegram.downloadTextFile(document.file_id, { maxBytes: maxUploadBytes });
338 } catch (error) {
339 const view = {
340 text: `⚠️ <b>فایل پذیرفته نشد</b>\n${escapeHtml(error?.message || 'Telegram file download failed')}\n\nDraft تغییر نکرد و می‌توانید فایل دیگری ارسال کنید.`,