|
1 | 1 | import { LogEngine } from '@wgtechlabs/log-engine'; |
2 | 2 | import { RedisService } from './redisService'; |
3 | 3 | import { config } from '../config/env'; |
| 4 | +import { redisEventConfig } from '../config/redis'; |
4 | 5 | import { |
5 | 6 | UnthreadWebhookEvent, |
6 | 7 | RedisQueueMessage, |
@@ -36,43 +37,15 @@ export class WebhookService { |
36 | 37 | return; |
37 | 38 | } |
38 | 39 |
|
39 | | - // Detect platform source with enhanced logging |
| 40 | + // Detect platform source |
40 | 41 | const sourcePlatform = this.detectPlatformSource(event); |
41 | 42 |
|
42 | | - // Enhanced audit logging for detection validation |
43 | | - if ((event.event === 'message_created' || event.event === 'conversation_updated') && event.data) { |
44 | | - if (event.event === 'message_created') { |
45 | | - const detectionSummary = [ |
46 | | - `Detection: ${sourcePlatform}`, |
47 | | - `Event: ${event.eventId}`, |
48 | | - `Conversation: ${event.data.conversationId}`, |
49 | | - `ConversationUpdates: ${event.data.metadata?.event_payload?.conversationUpdates !== undefined ? 'present' : 'missing'}`, |
50 | | - `BotName: ${event.data.botName}`, |
51 | | - `External: ${event.data.isExternal}` |
52 | | - ].join(' | '); |
53 | | - |
54 | | - LogEngine.info(`Platform detection completed - ${detectionSummary}`); |
55 | | - } else if (event.event === 'conversation_updated') { |
56 | | - const detectionSummary = [ |
57 | | - `Detection: ${sourcePlatform}`, |
58 | | - `Event: ${event.eventId}`, |
59 | | - `Conversation: ${event.data.id}`, |
60 | | - `Type: conversation_updated`, |
61 | | - `Reason: administrative action` |
62 | | - ].join(' | '); |
63 | | - |
64 | | - LogEngine.info(`Platform detection completed - ${detectionSummary}`); |
65 | | - } |
66 | | - } |
67 | | - |
68 | 43 | // Transform and queue event |
69 | 44 | const transformedEvent = this.transformEvent(event, sourcePlatform); |
70 | 45 | await this.redisService.publishEvent(transformedEvent); |
71 | 46 |
|
72 | 47 | // Mark as processed |
73 | 48 | await this.redisService.markEventProcessed(event.eventId); |
74 | | - |
75 | | - LogEngine.debug(`Event processed: ${event.event} (${event.eventId}) from ${sourcePlatform}`); |
76 | 49 | } |
77 | 50 |
|
78 | 51 | private transformEvent(unthreadEvent: UnthreadWebhookEvent, sourcePlatform: PlatformSource): RedisQueueMessage { |
|
0 commit comments