Skip to content

Commit

Permalink
[PAY-2263] Decode ABI for blocked users and relay if they're deactiva…
Browse files Browse the repository at this point in the history
…tion requests (#6917)
  • Loading branch information
rickyrombo authored Dec 12, 2023
1 parent dc91844 commit 7c379ff
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/identity-service/src/routes/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ module.exports = function (app) {
const reqIP = getIP(req)
detectAbuse(user, reqIP) // fired & forgotten
}

// Only reject relay for users explicitly blocked from relay
if (user.isBlockedFromRelay) {
return errorResponseForbidden(`Forbidden ${user.appliedRules}`)
}
}

let txProps
Expand Down Expand Up @@ -128,6 +123,27 @@ module.exports = function (app) {
)
}
}

// Only reject relay for users explicitly blocked from relay and not for deactivations
if (blockAbuseOnRelay && user && user.isBlockedFromRelay) {
const decodedABI = libs.AudiusABIDecoder.decodeMethod(
txProps.contractRegistryKey,
txProps.encodedABI
)
const args = {}
for (const p of decodedABI.params) {
args[p.name] = p.value
}
const isDeactivation =
!user.is_deactivated &&
decodedABI.name === 'manageEntity' &&
args._entityType === 'User' &&
args._action === 'Update' &&
JSON.parse(args._metadata).data.is_deactivated
if (!isDeactivation) {
return errorResponseForbidden(`Forbidden ${user.appliedRules}`)
}
}
receipt = await txRelay.sendTransaction(
req,
false, // resetNonce
Expand Down

0 comments on commit 7c379ff

Please sign in to comment.