[#347] Resolve "send channel redemption notifications instantly"
Closes #347 (closed)
Context
- in !384 (merged) we added support for delayed recycling, in which admins get a warning and a 24-hour grace period to "redeem" channels slated for recyling before they are actually recycled
- however, in the current implementation, admins who act on the warning to redeem their channel are not notified until the end of the grace period (potentially as long as 24 hours after they respond to the warning) that the channels will not be recycled
- this seems quite stressful and likely to make users who want to use us very sad and confused
- instead, let's notify them instantly
Behavior
GIVEN a recycle request has been issued for a channel
- WHEN an admin sends any message to the channel
- THEN the recycle request will be deleted immediately
- AND THEN the admin will get a notification immediately confirming the success of the deletion
Implementation
data model update:
- add
hasOne
association btw/ channel & recycleRequest - include
recycleRequest
inchannelRepository.findDeep
registrar layer: split redeem & recycle logic into 2 functions:
- extract a
phoneNumberRegistrar.redeem
, which may be called from dispatcher as soon as a redemption message is received. it:- deletes recycle request for redeemed channel
- immediately notifies channel admins and instance maintainers that channel has been redeemed (no more waiting 24 hours! :))
- refactor
recycleRequestRepository.evaluateRecycleRequests
- rename to
recycleRequest.getMaturerecycleRequests
- only retrieve and return mature recycle requests
- don't worry about filtering out redeemed channel phone numbers
anymore, since this will be done atomically and directly by calls
to
#redeem
above
- rename to
- simplify
phoneNumberRegistrar.processRecycleRequests
:- don't worry about redeemed nubmers
- just get the mature requests, recycle their channels, and notify the admins that this happened
dispatcher layer: redeem channels in `dispatcher.dispatch
- check if any incoming message is from a channel with a pending recycle request
- if so, redeem it (and notify admins/maintainers) right away!
side-effects:
- refactor dispatcher.dispatch to extract handling of early-returning
and non-early returning side-efffects just before
relay
- tuck all logic that detects actionable state from system messages
and possibly returns early after processing it into a
detectInterventions
helper (which returns anintervetnion
func and returns early after calling it) - tuck all logic that detects and takes action but does not require
returning early into a
detectSideEffects
function, which returns an array of side-effects to perform before proceeding torelay
- tuck all logic that detects actionable state from system messages
and possibly returns early after processing it into a
- drop e2e tests from
make.test.all
(for now)
Edited by aguestuser