Quellcode durchsuchen

fix(api): remove no-op code

Peter Thomassen vor 7 Jahren
Ursprung
Commit
01279095b8
2 geänderte Dateien mit 7 neuen und 5 gelöschten Zeilen
  1. 6 4
      api/desecapi/models.py
  2. 1 1
      api/desecapi/views.py

+ 6 - 4
api/desecapi/models.py

@@ -152,8 +152,6 @@ class Domain(models.Model, mixins.SetterMixin):
 
         if new:
             # Import RRsets that may have been created (e.g. during captcha lock).
-            # Don't perform if we do not know of any RRsets (it would delete all
-            # existing records from pdns).
             rrsets = self.rrset_set.all()
             if rrsets:
                 pdns.set_rrsets(self, rrsets)
@@ -175,8 +173,12 @@ class Domain(models.Model, mixins.SetterMixin):
                          'contents': [ds for k in self.keys for ds in k['ds']]}
                     ])
         else:
-            # Zone exists, purge it by deleting all RRsets and sync
-            pdns.set_rrsets(self, [], notify=False)
+            # Zone exists. For the case that pdns knows records that we do not
+            # (e.g. if a locked account has deleted an RRset), it is necessary
+            # to purge all records here. However, there is currently no way to
+            # do this through the pdns API (not to mention doing it atomically
+            # with setting the new RRsets). So for now, we have disabled RRset
+            # deletion for locked accounts.
             pdns.set_rrsets(self, self.rrset_set.all())
 
     @transaction.atomic

+ 1 - 1
api/desecapi/views.py

@@ -138,7 +138,7 @@ class RRsetDetail(generics.RetrieveUpdateDestroyAPIView):
 
     def delete(self, request, *args, **kwargs):
         if request.user.captcha_required:
-            detail = "You cannot delete RRset while your account is locked."
+            detail = "You cannot delete RRsets while your account is locked."
             raise PermissionDenied(detail)
         try:
             super().delete(request, *args, **kwargs)