Merge pull request #21457 from gustavotrott/gql-list-of-users-have-connected

feat (gql-server): Introduces graphql Type `user_presenceLog` to indicate users that have joined
This commit is contained in:
Tiago Jacobs 2024-10-16 12:05:44 -03:00 committed by GitHub
commit 51c763dfc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 0 deletions

View File

@ -272,6 +272,7 @@ CREATE TABLE "user" (
"authToken" varchar(16),
"authed" bool,
"joined" bool,
"firstJoinedAt" timestamp with time zone,
"joinErrorCode" varchar(50),
"joinErrorMessage" varchar(400),
"banned" bool,
@ -329,6 +330,28 @@ ALTER TABLE "user" ADD COLUMN "isDenied" boolean GENERATED ALWAYS AS ("guestStat
ALTER TABLE "user" ADD COLUMN "registeredAt" timestamp with time zone GENERATED ALWAYS AS (to_timestamp("registeredOn"::double precision / 1000)) STORED;
--Populate column `firstJoinedAt` to register if the user has joined in the meeting (once column `joined` turn false when user leaves)
CREATE OR REPLACE FUNCTION "set_user_firstJoinedAt_trigger_func"()
RETURNS TRIGGER AS $$
BEGIN
IF NEW."joined" is true AND NEW."firstJoinedAt" IS NULL THEN
NEW."firstJoinedAt" := NOW();
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_user_firstJoinedAt_ins_trigger"
BEFORE INSERT ON "user"
FOR EACH ROW
EXECUTE FUNCTION "set_user_firstJoinedAt_trigger_func"();
CREATE TRIGGER "set_user_firstJoinedAt_upd_trigger"
BEFORE UPDATE ON "user"
FOR EACH ROW
WHEN (OLD."joined" IS DISTINCT FROM NEW."joined")
EXECUTE FUNCTION "set_user_firstJoinedAt_trigger_func"();
--Used to sort the Userlist
ALTER TABLE "user" ADD COLUMN "nameSortable" varchar(255) GENERATED ALWAYS AS (trim(remove_emojis(immutable_lower_unaccent("name")))) STORED;
@ -506,6 +529,17 @@ AS SELECT
"user"."currentlyInMeeting"
FROM "user";
--Provide users that have joined in the meeting, either who is currently in meeting or has left
CREATE OR REPLACE VIEW "v_user_presenceLog"
AS SELECT
"user"."meetingId",
"user"."userId",
"user"."extId",
CASE WHEN "user"."role" = 'MODERATOR' THEN true ELSE false END "isModerator",
"user"."currentlyInMeeting"
FROM "user"
where "firstJoinedAt" is not null;
create table "user_metadata"(
"meetingId" varchar(100),
"userId" varchar(50),

View File

@ -0,0 +1,26 @@
table:
name: v_user_presenceLog
schema: public
configuration:
column_config: {}
custom_column_names: {}
custom_name: user_presenceLog
custom_root_fields: {}
select_permissions:
- role: bbb_client
permission:
columns:
- currentlyInMeeting
- extId
- isModerator
- userId
filter:
_and:
- meetingId:
_eq: X-Hasura-MeetingId
- _or:
- isModerator:
_eq: true
- meetingId:
_eq: X-Hasura-UserListNotLockedInMeeting
comment: ""

View File

@ -56,6 +56,7 @@
- "!include public_v_user_guest.yaml"
- "!include public_v_user_lockSettings.yaml"
- "!include public_v_user_metadata.yaml"
- "!include public_v_user_presenceLog.yaml"
- "!include public_v_user_reaction.yaml"
- "!include public_v_user_ref.yaml"
- "!include public_v_user_transcriptionError.yaml"