This commit is contained in:
2026-04-18 23:11:35 +02:00
commit f7cfd2a86e
196 changed files with 35538 additions and 0 deletions
@@ -0,0 +1,16 @@
-- ============================================================================
-- Allow the sender of a message to SELECT all its envelopes (needed so
-- ON CONFLICT UPDATE during message edit can detect the existing rows).
-- The existing envelopes_select_own_device policy only lets a device owner
-- read envelopes targeted at their own device, which is why sender-driven
-- upsert was failing for envelopes aimed at other users' devices.
-- ============================================================================
create policy envelopes_select_sender on public.message_envelopes
for select to authenticated
using (
exists (
select 1 from public.messages m
where m.id = message_id and m.sender_id = auth.uid()
)
);