Skip to content

Commit

Permalink
resolve addr in syncack
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Jul 30, 2024
1 parent a184ed6 commit f54a231
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions packages/delivery-service/src/delivery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export default (
'/messages/:ensName/contact/:contactEnsName',
async (req: express.Request, res, next) => {
try {
//normalize the contact name
const contactEnsName = await normalizeEnsName(
req.params.contactEnsName,
);
//retive the address for the contact name since it is used as a key in the db
const receiverAddress = await web3Provider.resolveName(
req.params.ensName,
Expand All @@ -69,6 +65,11 @@ export default (
});
}

//normalize the contact name
const contactEnsName = await normalizeEnsName(
req.params.contactEnsName,
);

//The new layout resolves conversations using a conversation id [addr(reiceiver),ensName(sender)]
const conversationId = getConversationId(
receiverAddress,
Expand Down Expand Up @@ -133,8 +134,22 @@ export default (
}

try {
const ensName = await db.getIdEnsName(req.params.ensName);
console.log('lets go');
const receiverAddress = await web3Provider.resolveName(
req.params.ensName,
);

//If the address is not found we return a 404. This should normally not happen since the receiver always is known to the delivery service
if (!receiverAddress) {
console.error(
'receiver address not found for name ',
req.params.ensName,
);
return res.status(404).send({
error:
'receiver address not found for name ' +
req.params.ensName,
});
}

await Promise.all(
req.body.acknowledgments.map(
Expand All @@ -143,7 +158,7 @@ export default (
ack.contactAddress,
);
const conversationId = getConversationId(
ensName,
receiverAddress,
contactEnsName,
);

Expand Down

0 comments on commit f54a231

Please sign in to comment.