refactor: simplify webhook events list

main
borja 3 months ago committed by borja (aider)
parent 2d8a40e3b8
commit a3fae9876b

@ -23,12 +23,7 @@ export class WebhookManager {
private static readonly REQUIRED_EVENTS = [ private static readonly REQUIRED_EVENTS = [
'APPLICATION_STARTUP', 'APPLICATION_STARTUP',
'messages.upsert', 'messages.upsert',
'messages.update',
'messages.delete',
'groups.update', 'groups.update',
'presence.update',
'contacts.update',
'chats.update',
]; ];
private static validateConfig() { private static validateConfig() {
@ -76,12 +71,12 @@ export class WebhookManager {
static async registerWebhook(): Promise<WebhookResponse> { static async registerWebhook(): Promise<WebhookResponse> {
this.validateConfig(); this.validateConfig();
const config = this.getConfig(); const config = this.getConfig();
const apiUrl = this.getApiUrl(); const apiUrl = this.getApiUrl();
const logSafeUrl = (url: string) => url ? `${url.substring(0, 20)}...` : 'invalid-url'; const logSafeUrl = (url: string) => url ? `${url.substring(0, 20)}...` : 'invalid-url';
console.log(' Attempting to register webhook:', { console.log(' Attempting to register webhook:', {
apiUrl, apiUrl,
config: { config: {
@ -104,7 +99,7 @@ export class WebhookManager {
try { try {
const errorBody = await response.text(); const errorBody = await response.text();
errorDetails += ` - ${errorBody}`; errorDetails += ` - ${errorBody}`;
} catch {} } catch { }
throw new Error(`Failed to register webhook: ${errorDetails}`); throw new Error(`Failed to register webhook: ${errorDetails}`);
} }

Loading…
Cancel
Save