Appearance
RPC Functions ​
Grouped reference of commonly used Postgres functions exposed via Supabase RPC.
User Management ​
sql
-- Get current user's role
get_current_user_role() RETURNS text
-- Switch between buyer/seller roles
switch_role(p_role text) RETURNS void
-- Get user's subscription level
get_user_subscription_level(p_user_id uuid) RETURNS text
-- Check if user can send messages (subscription limits)
can_send_message(p_user_id uuid) RETURNS boolean
-- Get daily message count
get_user_daily_message_count(p_user_id uuid) RETURNS integerOffer Management ​
sql
-- Seller accepts an offer (creates transaction)
seller_accept_offer(p_offer_id uuid, p_response_message text) RETURNS uuid
-- Seller rejects an offer
seller_reject_offer(p_offer_id uuid, p_response_message text) RETURNS void
-- Seller sends message on offer
seller_send_message(p_offer_id uuid, p_message text) RETURNS voidTransaction Management ​
sql
-- Create new transaction
create_transaction(p_listing_id uuid, p_buyer_id uuid, p_amount numeric) RETURNS uuid
-- Buyer confirms receipt of assets
buyer_confirm_received(p_deal uuid) RETURNS void
-- Seller marks assets as delivered
seller_deliver_assets(p_deal uuid) RETURNS void
-- Check if user is party to deal
is_deal_party(p_deal uuid) RETURNS boolean
-- Populate deal timeline events
populate_deal_timeline_events(p_deal_id uuid) RETURNS voidMessaging System ​
sql
-- Create or find conversation
initiate_conversation(p_listing_id uuid, p_buyer_id uuid, p_seller_id uuid) RETURNS uuid
-- Mark messages as read
mark_messages_as_read(p_conversation_id uuid, p_user_id uuid, p_last_read_message_id uuid) RETURNS void
-- Get user conversations with unread counts
get_user_conversations(p_user_id uuid) RETURNS TABLE(...)
-- Check if user participates in conversation
check_conversation_participant(conv_id uuid, u_id uuid) RETURNS booleanAdmin Functions ​
sql
-- Check if current user is admin
is_admin_user() RETURNS boolean
-- Get listing comments for admin/seller
get_admin_listing_comments(p_listing_id uuid) RETURNS TABLE(...)
-- Get all unresolved comments (admin only)
get_admin_all_unresolved_comments() RETURNS TABLE(...)
-- Count unresolved comments for listing
get_unresolved_comments_count(p_listing_id uuid) RETURNS integer
-- Send admin comments notification to seller
send_admin_comments_to_user(p_listing_id uuid) RETURNS void
-- Toggle field blur settings
admin_toggle_blurred_field(p_id uuid, p_plan text, p_enabled boolean) RETURNS void
-- Reports management (admin only)
admin_set_report_status(p_report_id uuid, p_status text) RETURNS SETOF public.reports
admin_update_report_status(p_report_id uuid, p_status public.report_status) RETURNS SETOF public.reports
-- Get all subscriptions (admin only)
get_all_subscriptions_admin() RETURNS TABLE(...)Visibility & Security ​
sql
-- Check if user can view specific field
can_view_field(p_listing uuid, p_field_key text, p_user uuid) RETURNS boolean
-- Check access to sensitive data
can_access_sensitive_data() RETURNS boolean
can_access_sensitive_listing_data() RETURNS boolean
-- Secure listings with field visibility applied
secure_listings_for_user(p_user_id uuid) RETURNS TABLE(...)Commission & Billing ​
sql
-- Calculate platform commission
calculate_commission(p_amount numeric, p_seller_id uuid) RETURNS numeric
-- Increment feature usage
increment_feature_usage(p_user_id uuid, p_feature_key text, p_reset_date text) RETURNS void
-- Debug subscription data
debug_subscription_update() RETURNS text
fix_subscription_dates() RETURNS voidUtility ​
sql
-- Get public profile info
get_public_profile(p_user_id uuid) RETURNS TABLE(...)
-- Update listings view counts
update_listings_views_count() RETURNS void
-- Generic updated_at triggers
update_updated_at_column() RETURNS trigger
set_updated_at() RETURNS trigger