-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## [1.4.0] - 2024-11-21 #### [@rickypid](https://github.com/rickypid)⚠️ ⚠️ **Need schema migration**⚠️ ⚠️ ### Improvements * Now when we get the rooms the `rooms_l` view is used so that we can get all the information without having to do multiple queries ### Fixed * Fixed #20 Chat creator role is null instead of admin * Fixed online user status realtime subscription
- Loading branch information
Showing
12 changed files
with
223 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,59 @@ | ||
DROP VIEW IF EXISTS chats.messages_l; | ||
DROP VIEW IF EXISTS chats.rooms_l; | ||
create view chats.rooms_l | ||
WITH (security_invoker='on') as | ||
select | ||
r.id, | ||
r."imageUrl", | ||
r.metadata, | ||
case | ||
when r.type = 'direct' and auth.uid() is not null then | ||
(select coalesce(u."firstName", '') || ' ' || coalesce(u."lastName", '') | ||
from chats.users u | ||
where u.id = any(r."userIds") and u.id <> auth.uid() | ||
limit 1) | ||
else | ||
r.name | ||
end as name, | ||
r.type, | ||
r."userIds", | ||
r."lastMessages", | ||
r."userRoles", | ||
r."createdAt", | ||
r."updatedAt" | ||
from chats.rooms r; | ||
|
||
create or replace view chats.rooms_l | ||
with (security_invoker='on') as | ||
select r.id, | ||
r."imageUrl", | ||
r.metadata, | ||
case | ||
when r.type = 'direct' and auth.uid() is not null then | ||
(select coalesce(u."firstName", '') || ' ' || coalesce(u."lastName", '') | ||
from chats.users u | ||
where u.id = any (r."userIds") | ||
and u.id <> auth.uid() | ||
limit 1) | ||
else | ||
r.name | ||
end as name, | ||
r.type, | ||
r."userIds", | ||
r."lastMessages", | ||
r."userRoles", | ||
r."createdAt", | ||
r."updatedAt", | ||
(select jsonb_agg(to_jsonb(u)) | ||
from chats.users u | ||
where u.id = any (r."userIds")) as users | ||
from chats.rooms r; | ||
|
||
|
||
create or replace view chats.messages_l | ||
with (security_invoker='on') as | ||
select m.id, | ||
m."createdAt", | ||
m.metadata, | ||
m.duration, | ||
m."mimeType", | ||
m.name, | ||
m."remoteId", | ||
m."repliedMessage", | ||
m."roomId", | ||
m."showStatus", | ||
m.size, | ||
m.status, | ||
m.type, | ||
m."updatedAt", | ||
m.uri, | ||
m."waveForm", | ||
m."isLoading", | ||
m.height, | ||
m.width, | ||
m."previewData", | ||
m."authorId", | ||
m.text, | ||
to_jsonb(u) as author, | ||
to_jsonb(r) as room | ||
from chats.messages m | ||
left join chats.users u on u.id = m."authorId" | ||
left join chats.rooms_l r on r.id = m."roomId"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.