diff --git a/platforms/dreamsync-api/src/controllers/WebhookController.ts b/platforms/dreamsync-api/src/controllers/WebhookController.ts index 86c721a6..694b97bc 100644 --- a/platforms/dreamsync-api/src/controllers/WebhookController.ts +++ b/platforms/dreamsync-api/src/controllers/WebhookController.ts @@ -164,6 +164,13 @@ export class WebhookController { return res.status(200).send("Skipped Match ID group"); } + // Check if this is a DM with DM ID in description (already processed) + if (local.data.description && typeof local.data.description === 'string' && local.data.description.startsWith('DM ID:')) { + console.log("⏭️ Skipping DM creation - this DM has DM ID in description (already processed)"); + await this.webhookProcessingService.markWebhookCompleted(req.body); + return res.status(200).send("Skipped DM ID group"); + } + let participants: User[] = []; if ( local.data.participants && diff --git a/platforms/dreamsync-api/src/services/ConsentService.ts b/platforms/dreamsync-api/src/services/ConsentService.ts index 5ce347e3..25ed1cfc 100644 --- a/platforms/dreamsync-api/src/services/ConsentService.ts +++ b/platforms/dreamsync-api/src/services/ConsentService.ts @@ -1379,14 +1379,14 @@ DreamSync Team // Create new mutual chat console.log(`🔧 ConsentService: Creating mutual chat with:`); console.log(` - Name: DreamSync Chat with ${userId}`); - console.log(` - Description: Private chat with DreamSync platform`); + console.log(` - Description: DM ID: ${userId}::${dreamsyncUser.id}`); console.log(` - Owner: ${dreamsyncUser.id}`); console.log(` - Members: [${dreamsyncUser.id}, ${userId}]`); console.log(` - Private: true`); const mutualChat = await this.groupService.createGroup( `DreamSync Chat with ${userId}`, - "Private chat with DreamSync platform", + `DM ID: ${userId}::${dreamsyncUser.id}`, dreamsyncUser.id, [dreamsyncUser.id], [dreamsyncUser.id, userId], diff --git a/platforms/dreamsync-api/src/services/MatchNotificationService.ts b/platforms/dreamsync-api/src/services/MatchNotificationService.ts index 1c8dea66..bbf264cb 100644 --- a/platforms/dreamsync-api/src/services/MatchNotificationService.ts +++ b/platforms/dreamsync-api/src/services/MatchNotificationService.ts @@ -82,8 +82,8 @@ export class MatchNotificationService { console.log(`🆕 No existing mutual chat found, creating new one...`); // Create a new mutual chat - const chatName = `DreamSync Chat`; - const chatDescription = `Private chat between DreamSync and user for match notifications`; + const chatName = `DreamSync Chat with ${targetUserId}`; + const chatDescription = `DM ID: ${targetUserId}::${dreamsyncUser.id}`; console.log(`🔧 Creating mutual chat with:`); console.log(` - Name: ${chatName}`); diff --git a/platforms/dreamsync-api/src/web3adapter/watchers/subscriber.ts b/platforms/dreamsync-api/src/web3adapter/watchers/subscriber.ts index 30533ab0..7568346a 100644 --- a/platforms/dreamsync-api/src/web3adapter/watchers/subscriber.ts +++ b/platforms/dreamsync-api/src/web3adapter/watchers/subscriber.ts @@ -414,6 +414,12 @@ export class PostgresSubscriber implements EntitySubscriberInterface { return; } + // Skip DMs with DM ID in description (already processed) + if (data.description && typeof data.description === 'string' && data.description.startsWith('DM ID:')) { + console.log(`🔍 Skipping DM webhook - has DM ID in description: ${data.description}`); + return; + } + let globalId = await this.adapter.mappingDb.getGlobalId(data.id); globalId = globalId ?? "";