Allow users to update other statuses. Add column in statutes for that

This commit is contained in:
Gabriel Brown 2025-03-18 10:07:06 -05:00
parent dc43d3b20c
commit 35e340eed2
2 changed files with 5 additions and 4 deletions

View File

@ -6,7 +6,6 @@ import AppleSignInButton from '@/components/auth/AppleSignIniOS';
import AzureSignIn from './AzureSignIn';
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';
import type { updateUser } from '@/constants/Types';
// Tells Supabase Auth to continuously refresh the session automatically if
// the app is in the foreground. When this is added, you will continue to receive

View File

@ -63,6 +63,7 @@ create policy "Anyone can upload an avatar." on storage.objects
CREATE TABLE statuses (
id uuid DEFAULT gen_random_uuid() PRIMARY KEY,
user_id uuid REFERENCES auth.users ON DELETE CASCADE NOT NULL,
updated_by_id uuid REFERENCES auth.users ON DELETE SET NULL DEFAULT auth.uid(),
created_at timestamp with time zone DEFAULT now() NOT NULL,
status text NOT NULL,
CONSTRAINT status_length CHECK (char_length(status) >= 3 AND char_length(status) <= 80),
@ -77,8 +78,8 @@ ALTER TABLE statuses
CREATE POLICY "Public statuses are viewable by everyone." ON statuses
FOR SELECT USING (true);
CREATE POLICY "Users can insert their own statuses." ON statuses
FOR INSERT WITH CHECK ((SELECT auth.uid()) = user_id);
CREATE POLICY "Users can insert statuses for any user." ON statuses
FOR INSERT WITH CHECK (auth.role() = 'authenticated');
-- Function to add first status
CREATE FUNCTION public.handle_first_status()
@ -86,8 +87,9 @@ RETURNS TRIGGER
SET search_path = ''
AS $$
BEGIN
INSERT INTO public.statuses (user_id, status)
INSERT INTO public.statuses (user_id, updated_by_id, status)
VALUES (
NEW.id,
NEW.id,
'Just joined!'
);