snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-23 16:12:52 +05:00
commit a774ac673a
4541 changed files with 770499 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
-- Tighten validate_group_file_association to match the single-ownership model.
--
-- The original trigger (023_groups.sql) allowed a group_file row whenever the file
-- was shared OR owned by the group. That "shared" allowance is what let the removed
-- drag-to-link feature (#9107, removed in #9254) link a shared file into ANY
-- workspace without changing owningGroupId — the orphan rows cleaned up in migration
-- 038. Now that only two kinds of group_file rows are legitimate, tighten the check
-- so the database rejects a re-appearance of those cross-workspace links:
--
-- 1. The owning row: group_file.groupId === file.owningGroupId.
-- 2. A home guest link: group_file.groupId is a user's home group (a user exists
-- with that id) and the file is shared, i.e. the guest can actually access it.
--
-- A shared file can no longer be linked into a non-home workspace that doesn't own
-- it. All current insert paths (createFile, onEnterFile home link, moveFileToWorkspace)
-- satisfy one of the two allowed cases.
CREATE OR REPLACE FUNCTION validate_group_file_association() RETURNS TRIGGER AS $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM "file" f
WHERE f."id" = NEW."fileId"
AND (
-- the group owns the file
f."owningGroupId" = NEW."groupId"
-- ...or it's a home guest link for a shared file
OR (
f."shared" = true
AND EXISTS (SELECT 1 FROM "user" u WHERE u."id" = NEW."groupId")
)
)
) THEN
RAISE EXCEPTION 'Cannot link file to group: group must own the file, or the file must be shared and linked into a user home group';
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;