Add scoreDecayService tests, webhook docs, action_url migration, fix …#1031
Open
ExcelDsigN-tech wants to merge 3 commits into
Open
Add scoreDecayService tests, webhook docs, action_url migration, fix …#1031ExcelDsigN-tech wants to merge 3 commits into
ExcelDsigN-tech wants to merge 3 commits into
Conversation
added 2 commits
May 28, 2026 16:59
…README clone URL - scoreDecayService tests: inactivity decay, floor, idempotency - Webhook integration guide with event types, payloads, HMAC, retry - Migration adding action_url to notifications + service/controller wiring - Fix placeholder clone URL to LabsCrypt/remitlend
Replace top-level static imports with lazy dynamic imports so jest ESM environment resolves them at runtime instead of module load time.
| if (!process.env.SENDGRID_API_KEY || !fromEmail) { | ||
| if (!fromEmail) { | ||
| logger.info( | ||
| `[Email] FROM_EMAIL not set. Would send to ${email}: ${message}`, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix/feat: Score Decay Tests, Notification Deep-Links, Webhook Guide, and README Clone URL Fix | Closes #955, Closes #957, Closes #959, Closes #1023
Overview
This PR addresses two backend gaps and two documentation issues. The scoreDecayService, which
handles financially sensitive credit score mutations for inactive borrowers, gains a dedicated
test suite covering the core decay logic that was previously untested. The notifications system
gains an action_url column and supporting schema changes so that every notification type can
carry a deep-link to its relevant entity, unblocking the inbox feature in #892. On the
documentation side, a webhook integration guide is added to give external subscribers a single
authoritative reference for consuming the RemitLend webhook system. A stale placeholder clone
URL in the README Quick Start is corrected to point at the real repository.
Feature Summary
no-decay, score floor enforcement, idempotency, and batch processing
payloads, HMAC-SHA256 signature verification, delivery semantics, and circuit-breaker behavior
Technical Implementation
Score Decay Service Tests (#955):
mock pattern established by existing service tests
calls are made in any test case
threshold decays by exactly the configured decay amount; a user whose last activity is within
the threshold receives no score change; a user whose computed post-decay score falls below
the configured minimum is floored at that minimum rather than going below it; running the
decay job twice within the same inactivity window does not apply a second decay to the same
user (idempotency); and a batch of mixed active and inactive users produces mutations only
for the inactive subset with correct amounts
Notification Deep-Links (#959):
notifications table with no backfill; existing rows return null for the field
repaid, loan defaulted, dispute opened, remittance completed) to construct and pass the
appropriate action_url using the entity ID available at that call site
in both the response schema and any shared notification type definitions
so no controller logic changes are required beyond confirming the field passes through
Webhook Integration Guide (#957):
list) with example request and response shapes; full table of supported event types with
the object and trigger condition for each; example JSON payload per event type; delivery
and retry semantics documenting the backoff schedule and maximum attempt count; circuit
breaker behavior documenting the threshold at which deliveries are suspended and how they
resume; HMAC-SHA256 signature verification section documenting the X-RemitLend-Signature
header format and including a verification code snippet in Node.js, with a cross-reference
to [Backend] Sign outgoing webhook deliveries with HMAC-SHA256 X-RemitLend-Signature header #880 for the signing implementation; and expected HTTP response codes from the subscriber
endpoint with notes on what triggers a retry
documentation section
README Clone URL Fix (#1023):
LabsCrypt/remitlend in the git clone command so the Quick Start works on first copy-paste
Test Coverage
score floor at minimum boundary, idempotency across two runs in the same window, and batch
processing with a mixed user set asserting per-user mutation correctness
or contract calls are made
notification type (loan approved used as the representative case)
continues to pass
the column is nullable with no default constraint
Checklists
delivery and retry semantics, circuit-breaker behavior, and HMAC verification