Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
create or replace view public.chat_threads_with_participants
with (security_invoker = on) as
select
chat_threads.id,
chat_threads.created_at,
chat_threads.listing_id,
chat_threads.initiator_id,
chat_threads.owner_id,
initiator.first_name as initiator_first_name,
owner.first_name as owner_first_name,
listings.slug as listing_slug,
listings.avatar as listing_avatar,
listings.name as listing_name,
listings.type as listing_type,
listings.area_name as listing_area_name,
owner.avatar as owner_avatar,
initiator.avatar as initiator_avatar,
(
select count(*) >= 2
from public.listings as owner_listings
where owner_listings.owner_id = chat_threads.owner_id
and owner_listings.type in ('community', 'business')
) as owner_has_multiple_non_residential_listings
from public.chat_threads
join public.profiles as initiator on chat_threads.initiator_id = initiator.id
join public.profiles as owner on chat_threads.owner_id = owner.id
join public.listings on chat_threads.listing_id = listings.id;

alter view public.chat_threads_with_participants owner to postgres;

revoke all on table public.chat_threads_with_participants
from anon, authenticated, service_role;

grant select on table public.chat_threads_with_participants
to authenticated, service_role;

alter view public.listings_public_data
set (security_invoker = on);

alter view public.listings_private_data
set (security_invoker = on);

revoke all on table public.listings_public_data
from anon, authenticated, service_role;

revoke all on table public.listings_private_data
from anon, authenticated, service_role;

grant select on table public.listings_public_data
to anon, authenticated, service_role;

grant select on table public.listings_private_data
to authenticated, service_role;
Comment on lines +37 to +53
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration also changes public.listings_public_data / public.listings_private_data (sets security_invoker=on and rewrites grants), but the PR description only calls out hardening chat_threads_with_participants. Please update the PR description (or add an in-file comment) to explicitly mention these additional view hardening changes so reviewers understand the full scope and can evaluate any access-impact on listing reads.

Copilot uses AI. Check for mistakes.
Loading