[#382] Resolve "give admins more warning before deleting channel"
Closes #382 (closed)
context
- we want to delete metadata associated with unused channels as frequently as possible to keep our users safe
- we also want to prevent deleting channels that people still wanted to use but failed to redeem because they didn't receive or pay attention to the deletion notices we send before deleting
- this MR provides a design to (1) extend the grace period we offer before deleting a channel from 1 day to 3 days and (2) "nudge" users 3 times (instead of just 1) before actually deleting the channel
changes
configs:
- increase channel destruction grace period to 3 days (from 1)
data model:
- add
lastNotifiedAt
field todestructionRequest
model - index date fields on destruction requests, rn: lastNotifiedAt
repository layer:
add destructionRequestRepository#getNotifiableDestructionRequests
:
- retrieve all pending destruction requests (ie:
createdAt
> grace period start) that have not been notified in at least 1 day (ie:lastNotifiedAt
<= grace period start / 3`) - pass these to registrar layer
registrar layer:
add pending destruction notification logic to phoneNumberRegistrar#processDestructionRequest
:
- use
#getNotifiableDestructionRequests()
to retrieve all destruction requests that have not been notified in over 1 day - calculate the remaining time to live of each channel in hours
- construct a pending deletion message in each admin's language around this number and send it to each admin (via
#_warnOfPendingDestruction
) - update the
lastNotifiedAt
field on each destruction request to record the notification for the next round of processing
side-effects:
- extend
notifier#notifyAdmins
to support notification keys for notifications that are functions with arguments (and not just static strings) - add
util#millisAs
: convenience func to convert milliseconds to different units (weeks, days, hours, minutes) - modify
#getMatureDestructionRequests
to return destruction requests (not phone numbers)
Edited by aguestuser