fix: correct Telegram allowlist configuration key (#31)

This commit is contained in:
paisley
2026-02-10 16:18:34 +08:00
committed by GitHub
Unverified
parent f0c1931018
commit 518b5f6323
3 changed files with 41 additions and 0 deletions

View File

@@ -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
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 {
// For other channel types, extract all string values directly
for (const [key, value] of Object.entries(saved)) {

View File

@@ -309,6 +309,10 @@ export class WhatsAppLoginManager extends EventEmitter {
// Close socket gracefully to avoid conflict with Gateway
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 });
}
} catch (innerErr) {