Skip to content

Commit 9cc05b2

Browse files
authored
✨ tweak: update redis image and config
1 parent ce7bf40 commit 9cc05b2

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

docker-compose.yml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@
1414
#
1515
# Prerequisites:
1616
# - Copy .env.example to .env and configure your tokens
17-
# - Ensure external network exists: docker network create unthread-integration-network
1817
#
1918
# =============================================================================
2019

21-
version: '3.8'
22-
2320
services:
2421
# =============================================================================
2522
# REDIS - WEBHOOK OPERATIONS
2623
# =============================================================================
2724
# Dedicated Redis instance for webhook message queuing and communication
2825
redis-webhook:
29-
image: redis:7-alpine
26+
image: redis:8-alpine
27+
container_name: redis-webhook
3028
ports:
3129
- "6379:6379"
3230
volumes:
@@ -35,25 +33,24 @@ services:
3533
healthcheck:
3634
test: ["CMD", "redis-cli", "ping"]
3735
interval: 30s
38-
timeout: 3s
36+
timeout: 10s
3937
retries: 3
40-
start_period: 30s
41-
networks:
42-
- unthread-integration-network
38+
start_period: 40s
39+
command: redis-server --appendonly yes
4340

4441
# =============================================================================
4542
# WEBHOOK SERVER APPLICATION
4643
# =============================================================================
4744
# Handles incoming webhooks from Unthread and processes them
4845
webhook-server:
49-
image: wgtechlabs/unthread-webhook-server:latest
50-
container_name: docker-unthread-webhook-server
46+
build: . # Build from local Dockerfile to use current codebase
47+
image: unthread-webhook-server:local # Custom image name for local builds
48+
# image: wgtechlabs/unthread-webhook-server:latest # Uncomment to use Docker Hub image
49+
container_name: unthread-webhook-server
5150
ports:
5251
- "3000:3000"
5352
env_file:
5453
- .env
55-
environment:
56-
- REDIS_URL=redis://redis-webhook:6379
5754
depends_on:
5855
redis-webhook:
5956
condition: service_healthy
@@ -64,21 +61,10 @@ services:
6461
timeout: 10s
6562
retries: 3
6663
start_period: 40s
67-
networks:
68-
- unthread-integration-network
6964

7065
# =============================================================================
7166
# PERSISTENT VOLUMES
7267
# =============================================================================
7368
# Named volumes for data persistence across container restarts
7469
volumes:
7570
redis_webhook_data: # Redis webhook queue data
76-
77-
# =============================================================================
78-
# NETWORKING
79-
# =============================================================================
80-
# External network for communication between services
81-
# Create with: docker network create unthread-integration-network
82-
networks:
83-
unthread-integration-network:
84-
external: true

src/services/webhookService.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ export class WebhookService {
5858
// Detect platform source (enhanced with file attachment correlation)
5959
const sourcePlatform = this.detectPlatformSource(event);
6060

61+
LogEngine.debug(`Platform source detected: ${sourcePlatform}`, {
62+
eventId: event.eventId,
63+
eventType: event.event,
64+
hasFiles: this.fileAttachmentCorrelation.hasFileAttachments(event)
65+
});
66+
6167
// Handle buffered events - they will be processed later via callback
6268
if (sourcePlatform === 'buffered') {
6369
// Mark buffered events as processed to prevent duplicate buffering on retries
@@ -219,6 +225,16 @@ export class WebhookService {
219225
}
220226
}
221227

228+
// TERTIARY DETECTION: isExternal flag (additional indicator for file attachments)
229+
if (event.data?.isExternal === true) {
230+
LogEngine.debug(`Platform detected via isExternal flag: dashboard (${event.eventId})`);
231+
return 'dashboard';
232+
} else if (event.data?.isExternal === false && event.data?.sourceType) {
233+
// isExternal: false usually indicates platform -> dashboard direction
234+
LogEngine.debug(`Platform detected via isExternal flag: ${config.targetPlatform} (${event.eventId})`);
235+
return config.targetPlatform;
236+
}
237+
222238
// FALLBACK: Unknown if no reliable indicators found
223239
LogEngine.warn(`Unable to detect platform source for event ${event.eventId} - insufficient indicators`);
224240
return 'unknown';
@@ -264,21 +280,21 @@ export class WebhookService {
264280
*/
265281
private async continueEventProcessing(event: UnthreadWebhookEvent, sourcePlatform: string): Promise<void> {
266282
try {
267-
LogEngine.info('Processing buffered file attachment event', {
283+
LogEngine.info('Processing webhook event', {
268284
eventId: event.eventId,
269285
sourcePlatform,
270-
correlationSuccess: sourcePlatform !== 'unknown'
286+
hasFiles: this.fileAttachmentCorrelation.hasFileAttachments(event)
271287
});
272288

273-
// Transform and queue the event with the correlated source platform
289+
// Transform and queue the event with the detected/correlated source platform
274290
const transformedEvent = this.transformEvent(event, sourcePlatform);
275291
await this.redisService.publishEvent(transformedEvent);
276292

277293
// Mark as processed
278294
await this.redisService.markEventProcessed(event.eventId);
279295

280296
} catch (error) {
281-
LogEngine.error('Failed to process buffered file attachment event', {
297+
LogEngine.error('Failed to process webhook event', {
282298
eventId: event.eventId,
283299
sourcePlatform,
284300
error: error instanceof Error ? error.message : 'Unknown error'

src/utils/fileAttachmentCorrelation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class FileAttachmentCorrelationUtil {
150150
return correlationData.sourcePlatform;
151151
}
152152

153-
// No correlation found - buffer the file event
153+
// No correlation found - buffer the event and wait
154154
this.bufferFileEvent(event, correlationKey);
155155
return 'buffered';
156156
}

0 commit comments

Comments
 (0)