chat!#171
Conversation
|
forgot , sql script for supabase and needs to allow "anonymous auth" in settings, so anyone can send message |
|
oh wait , no. |
|
holy peak |
|
wait real time chat?? peak |
|
sorry, i dont know shi about databases and stuff |
|
can you tell me how it works |
|
I'll explain the SQl snippet first create table if not exists public.discussion_posts (
id bigint generated always as identity primary key,
message text not null check (char_length(message) between 1 and 100),
created_at timestamptz not null default now()
);
alter table public.discussion_posts enable row level security;
create policy "read posts"
on public.discussion_posts
for select
to authenticated
using (true);
create policy "anon insert"
on public.discussion_posts
for insert
to authenticated
with check (
coalesce((auth.jwt() ->> 'is_anonymous'), 'false') = 'true'
and char_length(message) between 1 and 100
);The first bit checks if a table exists called public_discussion_posts, and if it doesn't it makes one. |
|
the rest of it is just stuff for sending and receiving messages, so assuming you control the supabase server and don't do something malicious, it should be fine. To change it you'd just edit the line |
|
whos controlling the supa server :O |
|
If you choose to merge, you should control it- letting anyone else do so allows them to display anything they want on the website |
Currently it's mine, but it's better if you setup your own. It's not hard, i can send step-by-step tutorial on what to do, if needed. How OttersMeep said, i can control what messages appears and for example just do thousands lines of glitchy text, that will make site crash for everyone(i won't , but it's still better if site functions won't depend on another person) |
|
thats, great |
little updated SQL script, to prevent any more than 100 messages (will show only 100 latest messages) |
|
so step by step instruction :
it's should work after that |
|
i dont see authentication |




Used supabase. But , just incase, i can see user-agents in logs.

So it's better to change my projectURL and publishableKey to your one (supabase is free)