Skip to content

Commit 211cd19

Browse files
committed
iterate
1 parent a27259e commit 211cd19

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

agent.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ async function handleDeclineMatch({senderFid, messages, response}) {
200200
const pendingMatch = await findPendingMatch(senderFid);
201201

202202
if (!pendingMatch) {
203-
await sendToolMessage({fid: senderFid, messages, content: "No pending match to found to decline."});
203+
await sendToolMessage({fid: senderFid, messages, content: "No pending match found to decline."});
204204
return;
205205
}
206206

@@ -211,16 +211,16 @@ async function handleDeclineMatch({senderFid, messages, response}) {
211211

212212
await farcaster.sendDirectMessage(senderFid, response.message);
213213

214-
// Check if the other user had already accepted
215214
const otherFid = parseInt(match.user1_fid) === senderFid
216215
? match.user2_fid
217216
: match.user1_fid;
218-
217+
219218
const otherUserStatus = parseInt(match.user1_fid) === senderFid
220219
? match.user2_status
221220
: match.user1_status;
222-
223-
if (otherUserStatus === 'accepted') {
221+
222+
// If either user had accepted, notify the other user
223+
if (match.user1_status === 'accepted' || match.user2_status === 'accepted') {
224224
const declinedUser = await findUserByFid(senderFid);
225225
const declineMessage = await prepareDeclineMessage(declinedUser);
226226
await farcaster.sendDirectMessage(otherFid, declineMessage);

db.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,31 @@ export async function updateMatchStatus(userFid, status) {
184184
updates.user2_status = status;
185185
}
186186

187+
187188
// Update overall match status if both users have accepted or one declines
188189
if (
189190
(updates.user1_status === 'accepted' && match.user2_status === 'accepted') ||
190191
(match.user1_status === 'accepted' && updates.user2_status === 'accepted')
191192
) {
192193
updates.status = 'accepted';
193-
} else if (
194+
}
195+
196+
else if (
194197
status === 'declined' ||
195198
match.user1_status === 'declined' ||
196199
match.user2_status === 'declined'
197200
) {
198201
updates.status = 'declined';
199202
}
203+
204+
else if (
205+
status === 'already_connected' ||
206+
match.user1_status === 'already_connected' ||
207+
match.user2_status === 'already_connected'
208+
) {
209+
updates.status = 'declined';
210+
}
200211

201-
console.log("updates", updates);
202212
// Update the match
203213
const result = await db('matches')
204214
.where({ id: match.id })

0 commit comments

Comments
 (0)