diff --git a/zerver/lib/retention.py b/zerver/lib/retention.py index a2d1dce327..8f65f2af57 100644 --- a/zerver/lib/retention.py +++ b/zerver/lib/retention.py @@ -322,14 +322,14 @@ def delete_messages(msg_ids: List[int]) -> None: def delete_expired_attachments(realm: Realm) -> None: - attachments_deleted, _ = Attachment.objects.filter( + (num_deleted, ignored) = Attachment.objects.filter( messages__isnull=True, realm_id=realm.id, id__in=ArchivedAttachment.objects.filter(realm_id=realm.id), ).delete() - if attachments_deleted > 0: - logger.info("Cleaned up %s attachments for realm %s", attachments_deleted, realm.string_id) + if num_deleted > 0: + logger.info("Cleaned up %s attachments for realm %s", num_deleted, realm.string_id) def move_related_objects_to_archive(msg_ids: List[int]) -> None: diff --git a/zilencer/views.py b/zilencer/views.py index 0951dca3ac..dbe9607ecf 100644 --- a/zilencer/views.py +++ b/zilencer/views.py @@ -194,10 +194,10 @@ def unregister_remote_push_device( validate_bouncer_token_request(token, token_kind) user_identity = UserPushIdentityCompat(user_id=user_id, user_uuid=user_uuid) - deleted = RemotePushDeviceToken.objects.filter( + (num_deleted, ignored) = RemotePushDeviceToken.objects.filter( user_identity.filter_q(), token=token, kind=token_kind, server=server ).delete() - if deleted[0] == 0: + if num_deleted == 0: raise JsonableError(err_("Token does not exist")) return json_success(request)