Skip to content

Commit

Permalink
objectId for refund mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
calebtuttle committed May 16, 2024
1 parent a2672d5 commit 80c1837
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/services/aml-sessions/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ async function refund(req, res) {
// per session can be processed at a time. Otherwise, if the user
// spams this refund endpoint, we could send multiple transactions
// before the first one is confirmed.
const mutex = await SessionRefundMutex.findOne({ _id: _id }).exec();
const mutex = await SessionRefundMutex.findOne({ _id: objectId }).exec();
if (mutex) {
return res.status(400).json({ error: "Refund already in progress" });
}
const newMutex = new SessionRefundMutex({ _id: _id });
const newMutex = new SessionRefundMutex({ _id: objectId });
await newMutex.save();
// Perform refund logic
const response = await refundMintFeeOnChain(session, to);
Expand Down
4 changes: 2 additions & 2 deletions src/services/sessions/endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -710,11 +710,11 @@ async function refund(req, res) {
// before the first one is confirmed.
// TODO: Do not use MongoDB for mutex purposes. Use something like
// like Redis instead.
const mutex = await SessionRefundMutex.findOne({ _id: _id }).exec();
const mutex = await SessionRefundMutex.findOne({ _id: objectId }).exec();
if (mutex) {
return res.status(400).json({ error: "Refund already in progress" });
}
const newMutex = new SessionRefundMutex({ _id: _id });
const newMutex = new SessionRefundMutex({ _id: objectId });
await newMutex.save();

// Perform refund logic
Expand Down

0 comments on commit 80c1837

Please sign in to comment.