-
Notifications
You must be signed in to change notification settings - Fork 5
feat: message users when no match #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -684,6 +684,68 @@ Reply with the Match ID "${match.id}" to connect with the other ${otherUserIds.l | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Send a no-match notification to a user who has a wishlist but did not get a match this run. | ||||||||||||||||||||||||||||||||||||||||||||||
| * Condition: they have made a wishlist (even if empty). | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
| async sendNoMatchNotification(userId: string): Promise<void> { | ||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`📨 [no-match] sendNoMatchNotification: starting for user ${userId}`); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const dreamsyncUser = await this.findDreamSyncUser(); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!dreamsyncUser) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.error("[no-match] Cannot send: DreamSync user not found"); | ||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const user = await this.userService.getUserById(userId); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!user) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`[no-match] Cannot send: User ${userId} not found`); | ||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`📨 [no-match] User found: ${userId} (${user.name || user.ename || "no name"})`); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const chatResult = await this.findOrCreateMutualChat(userId); | ||||||||||||||||||||||||||||||||||||||||||||||
| if (!chatResult.chat) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`[no-match] Cannot send: Could not find/create chat for user ${userId}`); | ||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`📨 [no-match] Chat ready: ${chatResult.chat.id} (wasCreated: ${chatResult.wasCreated})`); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const { chat, wasCreated } = chatResult; | ||||||||||||||||||||||||||||||||||||||||||||||
| if (wasCreated) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`⏳ [no-match] Chat was just created, waiting 15 seconds before sending...`); | ||||||||||||||||||||||||||||||||||||||||||||||
| await new Promise(resolve => setTimeout(resolve, 15000)); | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`✅ [no-match] 15-second delay completed`); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const displayName = user.name || user.ename || "User"; | ||||||||||||||||||||||||||||||||||||||||||||||
| const messageContent = `$$system-message$$ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Dear ${displayName}, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| DreamSync tried to find matches with other users using your wishlist but no conclusive matches were found. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| we would encourage you to add more details to your wishlist and add more topics you are interested in. | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Best Wishes, | ||||||||||||||||||||||||||||||||||||||||||||||
| DreamSync`; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+722
to
+732
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Polish the no‑match message copy. ✍️ Suggested copy edit- const messageContent = `$$system-message$$
-
-Dear ${displayName},
-
-DreamSync tried to find matches with other users using your wishlist but no conclusive matches were found.
-
-we would encourage you to add more details to your wishlist and add more topics you are interested in.
-
-Best Wishes,
-DreamSync`;
+ const messageContent = `$$system-message$$
+
+Dear ${displayName},
+
+DreamSync tried to find matches with other users using your wishlist, but no conclusive matches were found.
+
+We encourage you to add more details to your wishlist and include more topics you're interested in.
+
+Best wishes,
+DreamSync`;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const messageRepository = AppDataSource.getRepository(Message); | ||||||||||||||||||||||||||||||||||||||||||||||
| const message = messageRepository.create({ | ||||||||||||||||||||||||||||||||||||||||||||||
| text: messageContent, | ||||||||||||||||||||||||||||||||||||||||||||||
| sender: dreamsyncUser, | ||||||||||||||||||||||||||||||||||||||||||||||
| group: chat, | ||||||||||||||||||||||||||||||||||||||||||||||
| isSystemMessage: true, | ||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| await messageRepository.save(message); | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`✅ [no-match] Message saved for user ${userId} (messageId: ${message.id})`); | ||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.error(`❌ [no-match] Error sending no-match notification to user ${userId}:`, error); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||
| * Process a new match and send notifications | ||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limit no‑match candidates to wishlists actually analyzed (and non‑empty).
The current query scans all active wishlists (including empty) and ignores the 200‑wishlist cap used in this run, so users not processed could receive a false “no match” message. This also conflicts with the “non‑empty wishlist” requirement.
✅ Suggested fix to align eligibility with the processed, non‑empty wishlists
🤖 Prompt for AI Agents