-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn expiring users #56
Conversation
That's how it looks so far - it would be reeeeally nice to have this in a legit "provider chat" in the future <3 There is #57 to make this a bit nicer already :) |
We called and decided that we will not support the use case of running mailadm without a bot; the prune thread will only be started as soon as we have a working bot account object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the nice work and tests. It's a bit intricate if the policy (when to warn) changes to change all the tests but that's ok for now i guess.
Having the prune_loop re-use the bot account would be good and removing the redundancy as commented. thanks!
if user.ttl >= year: | ||
if user.warned == 0 and user.date + user.ttl < sysdate + month: | ||
timeleft = "30 days" | ||
elif user.warned == 1 and user.date + user.ttl < sysdate + week: | ||
timeleft = "7 days" | ||
elif user.warned == 2 and user.date + user.ttl < sysdate + day: | ||
timeleft = "1 day" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only occurs to me now (sorry) but what if for some reason the bot doesn't run for a few days, and then performs this expiry check? Will we not send a message "expired in 7 days" but it might only be "4 days" actually?
We are only ever warning about "X days" so maybe there can be helper function that computers the number of remaining days irrespective how often expiry-checking is performed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the message should be "You account will expire at UTC-DATE, about N days from now."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point. Problem: imo we can't expect users to know in which timezone they are. Maybe we can avoid timezone specifics? for most users a date would be enough, and if the time is shorter, just saying how many hours it will take should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, we are anyway missing localization as well.
|
||
def __init__(self, addr, date, ttl, token_name): | ||
def __init__(self, addr, date, ttl, token_name, warned=0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it need a default of 0 here?
def test_users_to_warn(conn, monkeypatch): | ||
yeartoken = conn.add_token("1y", token="asd1", expiry="1y", prefix="tmp.") | ||
monthtoken = conn.add_token("1m", token="asd2", expiry="1m", prefix="tmp.") | ||
weektoken = conn.add_token("1w", token="asd3", expiry="1w", prefix="tmp.") | ||
daytoken = conn.add_token("1d", token="asd4", expiry="1d", prefix="tmp.") | ||
|
||
yearuser = conn.add_email_account(yeartoken) | ||
monthuser = conn.add_email_account(monthtoken) | ||
weekuser = conn.add_email_account(weektoken) | ||
dayuser = conn.add_email_account(daytoken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit skeptical of this test_users_to_warn functions -- a bit intricate to follow and a lot of boilerplate. When we change the logic/ warning rhythm it might also break easily. but not sure it's worth to refactor now. The other point (of having a get_users_to_warn that produces messages fitting tot he current time) is probably more important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better improve the warnings to be less timing (downtime) sensitive
8ec6fb3
to
59753c8
Compare
Co-authored-by: holger krekel <[email protected]>
bdb648f
to
0d2e348
Compare
This needs to be done again, but it only makes sense after we decided on #78. |
closes #21
the idea is to warn users a certain timespan before their accounts run out:
right now, the expiration warnings are triggered by the prune loop; this is a bit unfortunate as it means that we have to initialize another deltachat.account object for the mailadm bot, and can't reuse the bot object. Maybe that's fine, it just complicates the handling a bit.
I tried it out manually, works so far. There are 2 tests, one of them could be more minimal I guess.
Does the database migration need a test?