diff --git a/backend/src/matrix.js b/backend/src/matrix.js index c8813cb..0167592 100644 --- a/backend/src/matrix.js +++ b/backend/src/matrix.js @@ -126,10 +126,20 @@ const start = async () => { console.log('error: failed to recover signature:', e.message); } if (account) { + try { + const authorAddress = await matrixUserToAuthorAddress.get(event.sender); + if (account === authorAddress) { + await client.sendNotice(roomId, `Matrix user ${event.sender} already linked to author address ${account}`); + } else { + await client.sendNotice(roomId, `Matrix user ${event.sender} was linked to author address ${authorAddress}, now linked to ${account}`); + } + } catch (e) { + // Not found + await client.sendNotice(roomId, `Registered matrix user ${event.sender} to author address ${account}`); + } await matrixUserToAuthorAddress.put(event.sender, account); await authorAddressToMatrixUser.put(account, event.sender); } - await client.sendNotice(roomId, `Registered matrix user ${event.sender} to author address ${account}`); }; // Before we start the bot, register our command handler