In-app Chat and notifications
Opened this issue · 5 comments
itsalb3rt commented
Description
According to the Database, we need an In-app chat, the dynamic is simply, only the users can start a chat with the coworkers owners.
- Need to create a chats page
- Add Chat button in spaces
- Added the space owner information in space details
- Added bell to show notifications into the main header (desktop version)
- Added read properties
read_for_from_user
andread_for_to_user
to the chat entity - Add functionality to the notifications
- Add notifications of schedules
- Added read properties
- Mobile
- #54
Any others features are welcome.
itsalb3rt commented
@chakrihacker I have a request for you 😃 When you have time, please add properties to chat
entity to make chat read by users read_for_from_user
and read_for_to_user
itsalb3rt commented
itsalb3rt commented
I added a table notification
, function, and trigger on Supabase
Table
-- public.notification definition
-- Drop table
-- DROP TABLE public.notification;
CREATE TABLE public.notification (
id int8 NOT NULL GENERATED BY DEFAULT AS IDENTITY,
created_at timestamptz NULL DEFAULT now(),
"read" bool NOT NULL DEFAULT false,
"type" text NOT NULL,
meta json NULL DEFAULT '{}'::json,
to_user uuid NULL,
CONSTRAINT notification_pkey PRIMARY KEY (id),
CONSTRAINT notification_to_user_fkey FOREIGN KEY (to_user) REFERENCES auth.users(id)
);
Function
begin
insert into public.notification(type, to_user, meta)
values(
'message',
new.to_user,
format('{"chat_id":"%s", "from_user":"%s"}', new.chat_id, (select from_user from public.chats where id = new.chat_id))::jsonb
);
return new;
end;
Trigger
itsalb3rt commented
Created function and trigger to handle the notifications of the schedules
Function
begin
insert into public.notification(type, to_user, meta)
values(
'schedule',
(select space.userid
from public.spaces space
inner join public.users on public.users.id = space.userid
where space.id = new.space_id),
format('{"space_id":"%s", "schedule_id":"%s"}', new.space_id, new.id)::jsonb
);
return new;
end;
Trigger
itsalb3rt commented