⏪️(backend) stop deleting document in yhub

One feature we have is to still be able to read a soft deleted document
in the application. Calling the yhub service to delete the document
inside yhub make it unreachable, so it does not load anymore in the
editor. Yhub map the permission on what Docs returns in its abilities.
A soft deleted document will be in read only.
This commit is contained in:
Manuel Raynaud
2026-10-09 11:14:06 +02:00
parent e80751d157
commit aaa3176fee
2 changed files with 0 additions and 37 deletions
-8
View File
@@ -795,14 +795,6 @@ class DocumentViewSet(
"""Override to implement a soft delete instead of dumping the record in database."""
instance.soft_delete()
# the collaboration server holds the content: until it is told, it goes
# on serving the document to the clients editing it. On commit, because
# the task reads back what was just written to know what to report — it
# would find the document alive and restore it instead
transaction.on_commit(
partial(sync_service_deletions_in_cascade.delay, str(instance.id))
)
posthog_capture(
PosthogEventName.DOC_DELETED, self.request.user, {}, document=instance
)
@@ -148,32 +148,3 @@ def test_api_documents_delete_authenticated_owner(via, mock_user_teams):
{},
document=document,
)
def test_api_documents_delete_reports_the_deletion_to_the_collaboration_server(
django_capture_on_commit_callbacks,
):
"""
Deleting a document should tell the collaboration server, which holds its
content and would otherwise go on serving it to the clients editing it.
"""
user = factories.UserFactory()
document = factories.DocumentFactory(users=[(user, "owner")])
child = factories.DocumentFactory(parent=document)
client = APIClient()
client.force_login(user)
# the report is made once the deletion is committed: the task reads it back
with (
mock.patch("core.tasks.documents.YHubService") as mock_service,
django_capture_on_commit_callbacks(execute=True),
):
response = client.delete(f"/api/v1.0/documents/{document.id!s}/")
assert response.status_code == 204
# the subtree goes with it
assert mock_service.return_value.delete_ydoc.call_args_list == [
mock.call(document),
mock.call(child),
]