Skip to content

Commit 6dec504

Browse files
authored
fix: dual chat init dreamsync (#372)
1 parent 3105f7f commit 6dec504

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

platforms/dreamsync-api/src/controllers/WebhookController.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ export class WebhookController {
164164
return res.status(200).send("Skipped Match ID group");
165165
}
166166

167+
// Check if this is a DM with DM ID in description (already processed)
168+
if (local.data.description && typeof local.data.description === 'string' && local.data.description.startsWith('DM ID:')) {
169+
console.log("⏭️ Skipping DM creation - this DM has DM ID in description (already processed)");
170+
await this.webhookProcessingService.markWebhookCompleted(req.body);
171+
return res.status(200).send("Skipped DM ID group");
172+
}
173+
167174
let participants: User[] = [];
168175
if (
169176
local.data.participants &&

platforms/dreamsync-api/src/services/ConsentService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,14 +1379,14 @@ DreamSync Team
13791379
// Create new mutual chat
13801380
console.log(`🔧 ConsentService: Creating mutual chat with:`);
13811381
console.log(` - Name: DreamSync Chat with ${userId}`);
1382-
console.log(` - Description: Private chat with DreamSync platform`);
1382+
console.log(` - Description: DM ID: ${userId}::${dreamsyncUser.id}`);
13831383
console.log(` - Owner: ${dreamsyncUser.id}`);
13841384
console.log(` - Members: [${dreamsyncUser.id}, ${userId}]`);
13851385
console.log(` - Private: true`);
13861386

13871387
const mutualChat = await this.groupService.createGroup(
13881388
`DreamSync Chat with ${userId}`,
1389-
"Private chat with DreamSync platform",
1389+
`DM ID: ${userId}::${dreamsyncUser.id}`,
13901390
dreamsyncUser.id,
13911391
[dreamsyncUser.id],
13921392
[dreamsyncUser.id, userId],

platforms/dreamsync-api/src/services/MatchNotificationService.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export class MatchNotificationService {
8282
console.log(`🆕 No existing mutual chat found, creating new one...`);
8383

8484
// Create a new mutual chat
85-
const chatName = `DreamSync Chat`;
86-
const chatDescription = `Private chat between DreamSync and user for match notifications`;
85+
const chatName = `DreamSync Chat with ${targetUserId}`;
86+
const chatDescription = `DM ID: ${targetUserId}::${dreamsyncUser.id}`;
8787

8888
console.log(`🔧 Creating mutual chat with:`);
8989
console.log(` - Name: ${chatName}`);

platforms/dreamsync-api/src/web3adapter/watchers/subscriber.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ export class PostgresSubscriber implements EntitySubscriberInterface {
414414
return;
415415
}
416416

417+
// Skip DMs with DM ID in description (already processed)
418+
if (data.description && typeof data.description === 'string' && data.description.startsWith('DM ID:')) {
419+
console.log(`🔍 Skipping DM webhook - has DM ID in description: ${data.description}`);
420+
return;
421+
}
422+
417423
let globalId = await this.adapter.mappingDb.getGlobalId(data.id);
418424
globalId = globalId ?? "";
419425

0 commit comments

Comments
 (0)