Personal Telegram developer console for GitHub

fix: escape workspace provider errors

davoodmehraban89 committed Oct 3, 2026 at 13:48 UTC 80e7969e7f528d5c796574a46098c3256407070c
1 file changed +18 -21
src/bot.js
+18 -21
@@ -11,6 +11,11 @@ import { PluginRouter } from './core/router.js';
11 import { createGitHubPlugin } from './plugins/github/plugin.js';
12
13 const INTENT_ID_PATTERN = /^[A-Za-z0-9_-]{8}$/;
14 +const escapeHtml = value => String(value ?? '')
15 + .replaceAll('&', '&')
16 + .replaceAll('<', '&lt;')
17 + .replaceAll('>', '&gt;')
18 + .replaceAll('"', '&quot;');
19
20 function approvalSourceCallback(payload = {}) {
21 const repoId = payload.input?.repoId;
@@ -86,7 +91,7 @@ function approvedActionFailedView(payload, error) {
91 const detail = workspaceAction
92 ? permissionDenied
93 ? 'تأیید شما معتبر بود، اما GitHub درخواست Commit شاخه را با خطای 403 رد کرد. دسترسی Contents WRITE توکن فعلی را بررسی کنید.'
89 - : `تأیید شما معتبر بود، اما Commit شاخه انجام نشد: ${reason}`
94 + : `تأیید شما معتبر بود، اما Commit شاخه انجام نشد: ${escapeHtml(reason)}`
95 : permissionDenied
96 ? 'تأیید شما معتبر بود، اما GitHub درخواست را با خطای 403 رد کرد. دسترسی توکن فعلی برای GitHub Actions WRITE کافی نیست.'
97 : 'تأیید شما معتبر بود، اما GitHub عملیات را موفق اعلام نکرد. وضعیت Run را بررسی کنید.';
@@ -266,11 +271,7 @@ export class NexaDevBot {
271 }
272
273 if (text === '/repos') {
269 - const ownerId = message.from?.id;
270 - const routed = await this.router.dispatchCommand(text, {
271 - isOwner: true,
272 - ownerId: ownerId === undefined || ownerId === null ? '' : String(ownerId)
273 - });
274 + const routed = await this.router.dispatchCommand(text, { isOwner: true });
275 if (routed?.requiresApproval || routed?.denied || !routed) {
276 return { ok: false, command: 'repos', error: routed?.reason || 'GitHub repository route unavailable' };
277 }
@@ -285,32 +286,28 @@ export class NexaDevBot {
286 }
287
288 const ownerId = message.from?.id;
288 - if (
289 - typeof message.text === 'string' &&
290 - ownerId !== undefined && ownerId !== null &&
291 - this.workspaceStore.isConfigured()
292 - ) {
293 - const owner = String(ownerId);
294 - const pending = await this.workspaceStore.getPendingInput({ ownerId: owner });
289 + if (ownerId !== undefined && ownerId !== null && this.workspaceStore.isConfigured()) {
290 + const pending = await this.workspaceStore.getPendingInput({ ownerId: String(ownerId) });
291 if (pending) {
292 const routed = await this.router.dispatchMessage(
293 { pending, text: rawText },
298 - { isOwner: true, ownerId: owner }
294 + { isOwner: true, ownerId: String(ownerId) }
295 );
296 if (routed?.requiresApproval || routed?.denied || !routed) {
301 - return {
302 - ok: false,
303 - workspaceInput: true,
304 - error: routed?.reason || 'Workspace input route unavailable'
305 - };
297 + return { ok: false, error: routed?.reason || 'Workspace input route unavailable' };
298 }
299 const res = await this.telegram.sendMessage(chatId, routed.text, routed.reply_markup);
300 return { ok: true, workspaceInput: true, res };
301 }
302 }
303
312 - const defaultText = `💡 برای دسترسی به منوهای پروژه‌ها و ابزارهای Nexa Dev، دکمه زیر را لمس کنید:`;
313 - const view = { text: defaultText, reply_markup: { inline_keyboard: [[{ text: '⚡ باز کردن منوی اصلی Nexa Dev', callback_data: 'menu:main' }]] } };
304 + const defaultText = '💡 برای دسترسی به منوهای پروژه‌ها و ابزارهای Nexa Dev، دکمه زیر را لمس کنید:';
305 + const view = {
306 + text: defaultText,
307 + reply_markup: {
308 + inline_keyboard: [[{ text: '⚡ باز کردن منوی اصلی Nexa Dev', callback_data: 'menu:main' }]]
309 + }
310 + };
311 const res = await this.telegram.sendMessage(chatId, view.text, view.reply_markup);
312 return { ok: true, default: true, res };
313 }