fix: correct Telegram allowlist configuration key (#31)
This commit is contained in:
committed by
GitHub
Unverified
parent
f0c1931018
commit
518b5f6323
@@ -120,6 +120,23 @@ export function saveChannelConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Special handling for Telegram: convert allowedUsers string to allowlist array
|
||||||
|
if (channelType === 'telegram') {
|
||||||
|
const { allowedUsers, ...restConfig } = config;
|
||||||
|
transformedConfig = { ...restConfig };
|
||||||
|
|
||||||
|
if (allowedUsers && typeof allowedUsers === 'string') {
|
||||||
|
const users = allowedUsers.split(',')
|
||||||
|
.map(u => u.trim())
|
||||||
|
.filter(u => u.length > 0);
|
||||||
|
|
||||||
|
if (users.length > 0) {
|
||||||
|
transformedConfig.allowFrom = users; // Use 'allowFrom' (correct key)
|
||||||
|
// transformedConfig.groupPolicy = 'allowlist'; // Default is allowlist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Merge with existing config
|
// Merge with existing config
|
||||||
currentConfig.channels[channelType] = {
|
currentConfig.channels[channelType] = {
|
||||||
...currentConfig.channels[channelType],
|
...currentConfig.channels[channelType],
|
||||||
@@ -177,6 +194,18 @@ export function getChannelFormValues(channelType: string): Record<string, string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (channelType === 'telegram') {
|
||||||
|
// Special handling for Telegram: convert allowFrom array to allowedUsers string
|
||||||
|
if (Array.isArray(saved.allowFrom)) {
|
||||||
|
values.allowedUsers = saved.allowFrom.join(', ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Also extract other string values
|
||||||
|
for (const [key, value] of Object.entries(saved)) {
|
||||||
|
if (typeof value === 'string' && key !== 'enabled') {
|
||||||
|
values[key] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// For other channel types, extract all string values directly
|
// For other channel types, extract all string values directly
|
||||||
for (const [key, value] of Object.entries(saved)) {
|
for (const [key, value] of Object.entries(saved)) {
|
||||||
|
|||||||
@@ -309,6 +309,10 @@ export class WhatsAppLoginManager extends EventEmitter {
|
|||||||
// Close socket gracefully to avoid conflict with Gateway
|
// Close socket gracefully to avoid conflict with Gateway
|
||||||
await this.stop();
|
await this.stop();
|
||||||
|
|
||||||
|
// Add a small delay to ensure socket is fully closed and released
|
||||||
|
// This prevents "401 Conflict" when Gateway tries to connect immediately
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||||
|
|
||||||
this.emit('success', { accountId });
|
this.emit('success', { accountId });
|
||||||
}
|
}
|
||||||
} catch (innerErr) {
|
} catch (innerErr) {
|
||||||
|
|||||||
@@ -127,6 +127,14 @@ export const CHANNEL_META: Record<ChannelType, ChannelMeta> = {
|
|||||||
required: true,
|
required: true,
|
||||||
envVar: 'TELEGRAM_BOT_TOKEN',
|
envVar: 'TELEGRAM_BOT_TOKEN',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'allowedUsers',
|
||||||
|
label: 'Allowed User IDs (optional)',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: 'e.g. 123456789, 987654321',
|
||||||
|
description: 'Comma separated list of User IDs allowed to use the bot. Leave empty to allow everyone (if public) or require pairing.',
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
instructions: [
|
instructions: [
|
||||||
'Open Telegram and search for @BotFather',
|
'Open Telegram and search for @BotFather',
|
||||||
|
|||||||
Reference in New Issue
Block a user