Feat/admin dispute resolution - #333
Conversation
…and trade-safety route
…arties, and evidence
…gging, user banning, and dispute tests
|
@Truphile Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Revisión — bloqueante antes de mergearRevisé el diff completo contra el alcance de #329. Dos hallazgos críticos: 1. La tabla
|
… refund/release during resolution, restore pre-state checks, and untrack .idea files
Summary of Work
Created branch micopay-protocol and implemented backend support for dispute
management and administrative dispute resolution.
1. Dispute Creation & Abuse Rate Limiting
• Added rate limiting config: Configured disputeRateLimitWindowMs (1 hr)
and disputeRateLimitMax (5 requests) in config.ts.
• Added dispute service & routes:
• Implemented recordTradeDispute in abuse.service.ts.
• Implemented POST /trades/:id/dispute in trade-safety.ts to let trade
participants report open disputes with evidence URLs and reasons.
• Commit: 1e55863: feat(disputes): add dispute data models, rate limits,
abuse service, and trade-safety route
2. Admin Open Dispute Listing (GET /admin/disputes)
• Admin authentication: Extended auth.middleware.ts with adminMiddleware to
protect admin routes and enforce is_admin permission checks and is_banned
block checks.
• Listing with trade context: Implemented listAdminDisputes in
admin.service.ts and route GET /admin/disputes in admin.ts.
• Returns open disputes populated with:
• Trade context: Amounts (amount_mxn, amount_stroops,
platform_fee_mxn), trade status, hashes, timestamps.
• Parties: Buyer, seller, and reporter accounts (id, username,
stellar_address, is_banned).
• Evidence & messages: Evidence URLs and full trade audit log trail.
• Commit: fc630f9: feat(admin): implement GET /admin/disputes with full
trade context, parties, and evidence
3. Dispute Resolution & Audit Logging (POST
/admin/disputes/:id/resolve)
• Resolution actions: Implemented resolveAdminDispute in admin.service.ts
and endpoint POST /admin/disputes/:id/resolve in admin.ts.
• refund_buyer: Closes dispute (resolved), updates trade status to
'refunded'.
• release_seller: Closes dispute (resolved), updates trade status to
'completed'.
• ban_party: Bans target party (is_banned = true), closes dispute, and
updates trade status.
• Audit trail & logging: Integrates audit.service.ts (logAuditEvent) for
system action auditing and audit-log.model.ts (insertTradeAuditEvent) for
trade lifecycle transitions.
• Verification tests: Added disputes.test.ts covering dispute creation,
rate-limiting, non-participant rejection, admin listing, refund, release,
party banning, and audit logging.
• Commit: 16a2750: feat(admin): implement POST /admin/disputes/:id/resolve
with audit logging, user banning, and dispute tests
closes #329