Kaynağa Gözat

feat(api): add user ID to outgoing emails

Without this, we can't associate the user in some cases if she
asks a question. Example: When the email address was changed
illegitimately, and the user complains from their old address,
that email address will not be in our database at that moment.
Peter Thomassen 5 yıl önce
ebeveyn
işleme
4057ac58d7

+ 1 - 0
api/desecapi/models.py

@@ -152,6 +152,7 @@ class User(AbstractBaseUser):
 
         context = context or {}
         content = get_template(f'emails/{reason}/content.txt').render(context)
+        content += f'\nSupport Reference: user_id = {self.pk}\n'
         footer = get_template('emails/footer.txt').render()
 
         logger.warning(f'Queuing email for user account {self.pk} (reason: {reason})')

+ 1 - 0
api/desecapi/tests/test_user_management.py

@@ -160,6 +160,7 @@ class UserManagementTestCase(DesecTestCase, PublicSuffixMockMixin):
             else:
                 self.assertIn(recipient, email.recipients())
         body = email.body
+        self.assertIn('user_id = ', body)
         if reset:
             mail.outbox = []
         return body if not pattern else re.search(pattern, body).group(1)