add exponential registration backoff, change registration text
This commit is contained in:
parent
3647ecc77a
commit
91922bb5d4
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 4.0.4 on 2022-04-29 00:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("app", "0002_message_sent_at"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="logintoken",
|
||||||
|
name="send_count",
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
|
@ -115,12 +115,15 @@ class LoginToken(models.Model):
|
||||||
)
|
)
|
||||||
helper = models.ForeignKey(Helper, on_delete=models.CASCADE)
|
helper = models.ForeignKey(Helper, on_delete=models.CASCADE)
|
||||||
sent_at = models.DateTimeField(auto_now_add=True)
|
sent_at = models.DateTimeField(auto_now_add=True)
|
||||||
|
send_count = models.IntegerField(default=0)
|
||||||
|
|
||||||
def send(self):
|
def send(self):
|
||||||
text = f"Hallo {self.helper.name}, hier ist dein Registrierungslink zum Kontaktfestival http://short.url{self.get_absolute_url()}"
|
text = f"Dein Registrierungslink zum Helfer*inensystem: https://kontakt.rocks/{self.get_absolute_url()} \nWenn du dich nicht registiert hast, ignoriere diese SMS."
|
||||||
|
print("msglen", len(text))
|
||||||
msg = Message(to=self.helper, text=text)
|
msg = Message(to=self.helper, text=text)
|
||||||
msg.save()
|
msg.save()
|
||||||
self.sent_at = timezone.now()
|
self.sent_at = timezone.now()
|
||||||
|
self.send_count += 1
|
||||||
self.save()
|
self.save()
|
||||||
# import here to break import cycle
|
# import here to break import cycle
|
||||||
from .tasks import send_message
|
from .tasks import send_message
|
||||||
|
|
|
@ -4,7 +4,7 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("login/<slug:token>", views.login, name="token_login"),
|
path("l/<slug:token>", views.login, name="token_login"),
|
||||||
path("logout", views.logout, name="token_logout"),
|
path("logout", views.logout, name="token_logout"),
|
||||||
path("register", views.register, name="register"),
|
path("register", views.register, name="register"),
|
||||||
path("shift/<int:shiftid>", views.shift, name="shift"),
|
path("shift/<int:shiftid>", views.shift, name="shift"),
|
||||||
|
|
|
@ -10,6 +10,7 @@ from django.contrib import messages
|
||||||
import datetime
|
import datetime
|
||||||
from .decorators import event_state
|
from .decorators import event_state
|
||||||
from dynamic_preferences.registries import global_preferences_registry
|
from dynamic_preferences.registries import global_preferences_registry
|
||||||
|
import math
|
||||||
|
|
||||||
global_preferences = global_preferences_registry.manager()
|
global_preferences = global_preferences_registry.manager()
|
||||||
|
|
||||||
|
@ -118,7 +119,10 @@ def register(request):
|
||||||
messages.INFO,
|
messages.INFO,
|
||||||
f"DEBUG:{token.get_absolute_url()}",
|
f"DEBUG:{token.get_absolute_url()}",
|
||||||
)
|
)
|
||||||
if token.sent_at < (timezone.now() - datetime.timedelta(minutes=10)):
|
if token.sent_at < (
|
||||||
|
timezone.now()
|
||||||
|
- datetime.timedelta(minutes=math.pow(10, token.send_count))
|
||||||
|
):
|
||||||
token.send()
|
token.send()
|
||||||
return render(request, "register.html", context)
|
return render(request, "register.html", context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue