mirror of
https://github.com/block/buzz.git
synced 2026-10-28 21:11:48 +00:00
fix(db): log transactional claim denials
Co-authored-by: Codex <codex@openai.com> Signed-off-by: Brad Seiler <seiler@squareup.com> Signed-off-by: Local Builder <1c476cb1127ea270cb900bdc3891060140bdd1173f91498030ee9b4db01c2f20@buzz.block.builderlab.xyz>
This commit is contained in:
@@ -361,6 +361,8 @@ pub async fn claim_relay_invite_with_owner(
|
||||
|
||||
lock_admission(&mut tx, community).await?;
|
||||
if claim_owner::claimant_restricted(&mut tx, community, claimer_pubkey, verified_owner).await? {
|
||||
tx.rollback().await?;
|
||||
log_claim_outcome(community, None, "restricted", None, None);
|
||||
return Ok(ClaimOutcome::Restricted.into());
|
||||
}
|
||||
|
||||
@@ -405,11 +407,17 @@ pub async fn claim_relay_invite_with_owner(
|
||||
|
||||
let revoked_at: Option<DateTime<Utc>> = invite.try_get("revoked_at")?;
|
||||
let issuer: String = invite.try_get("created_by")?;
|
||||
if revoked_at.is_some() {
|
||||
return Ok(ClaimOutcome::Revoked.into());
|
||||
}
|
||||
if principal_restricted(&mut tx, community, &issuer).await? {
|
||||
return Ok(ClaimOutcome::IssuerRestricted.into());
|
||||
let denial = if revoked_at.is_some() {
|
||||
Some((ClaimOutcome::Revoked, "revoked"))
|
||||
} else if principal_restricted(&mut tx, community, &issuer).await? {
|
||||
Some((ClaimOutcome::IssuerRestricted, "issuer_restricted"))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
if let Some((outcome, label)) = denial {
|
||||
tx.rollback().await?;
|
||||
log_claim_outcome(community, Some(invite_id), label, max_uses, Some(use_count));
|
||||
return Ok(outcome.into());
|
||||
}
|
||||
|
||||
let uses_remaining = || max_uses.map(|mu| mu - use_count);
|
||||
|
||||
Reference in New Issue
Block a user