feat: Enhances registration notifications
Adds moderator messages to registration emails. Introduces 'notify' flag to control email notifications. Improves customization of user communication during status updates.
This commit is contained in:
parent
9a94f4b905
commit
7de4a3f2c5
2 changed files with 32 additions and 18 deletions
|
@ -23,6 +23,8 @@ class UserRegistration(models.Model):
|
|||
status = models.IntegerField(choices=STATUS_CHOICES, default=STATUS_STARTED)
|
||||
token = models.CharField(max_length=64, unique=True)
|
||||
email_verified = models.BooleanField(default=False)
|
||||
mod_message = models.TextField(blank=True, default="")
|
||||
notify = models.BooleanField(default=True)
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -37,10 +37,16 @@ def handle_status_change(sender, instance, created, **kwargs):
|
|||
headers={"Authorization": f"Bearer {settings.SYNAPSE_ADMIN_TOKEN}"},
|
||||
)
|
||||
|
||||
if instance.notify:
|
||||
message = f"Congratulations, your registration request at {settings.MATRIX_DOMAIN} has been approved."
|
||||
|
||||
if instance.mod_message:
|
||||
message += f"\n\nMessage from moderator: {instance.mod_message}"
|
||||
|
||||
try:
|
||||
send_mail(
|
||||
"Registration Approved",
|
||||
f"Congratulations, {instance.username}! Your registration at {settings.MATRIX_DOMAIN} has been approved.",
|
||||
message,
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
[instance.email],
|
||||
)
|
||||
|
@ -62,10 +68,16 @@ def handle_status_change(sender, instance, created, **kwargs):
|
|||
[settings.ADMIN_EMAIL],
|
||||
)
|
||||
|
||||
if instance.notify:
|
||||
message = f"Sorry, your registration request at {settings.MATRIX_DOMAIN} has been denied."
|
||||
|
||||
if instance.mod_message:
|
||||
message += f"\n\nMessage from moderator: {instance.mod_message}"
|
||||
|
||||
try:
|
||||
send_mail(
|
||||
"Registration Denied",
|
||||
f"Sorry, your registration request at {settings.MATRIX_DOMAIN} has been denied.",
|
||||
message,
|
||||
settings.DEFAULT_FROM_EMAIL,
|
||||
[instance.email],
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue