Merge pull request #18462 from gustavotrott/graphql-new-reactions
(graphql-server): Provides data for Reactions
This commit is contained in:
commit
c2f7d01a4a
@ -0,0 +1,43 @@
|
||||
package org.bigbluebutton.core.db
|
||||
|
||||
import slick.jdbc.PostgresProfile.api._
|
||||
import slick.lifted.{ ProvenShape }
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.util.{ Failure, Success }
|
||||
|
||||
case class UserReactionDbModel(
|
||||
userId: String,
|
||||
reactionEmoji: String,
|
||||
duration: Int,
|
||||
createdAt: java.sql.Timestamp
|
||||
)
|
||||
|
||||
class UserReactionDbTableDef(tag: Tag) extends Table[UserReactionDbModel](tag, "user_reaction") {
|
||||
val userId = column[String]("userId")
|
||||
val reactionEmoji = column[String]("reactionEmoji")
|
||||
val duration = column[Int]("duration")
|
||||
val createdAt = column[java.sql.Timestamp]("createdAt")
|
||||
|
||||
override def * : ProvenShape[UserReactionDbModel] = (userId, reactionEmoji, duration, createdAt) <> (UserReactionDbModel.tupled, UserReactionDbModel.unapply)
|
||||
}
|
||||
|
||||
object UserReactionDAO {
|
||||
def insert(userId: String, reactionEmoji: String) = {
|
||||
DatabaseConnection.db.run(
|
||||
TableQuery[UserReactionDbTableDef].forceInsert(
|
||||
UserReactionDbModel(
|
||||
userId = userId,
|
||||
reactionEmoji = reactionEmoji,
|
||||
duration = 60,
|
||||
createdAt = new java.sql.Timestamp(System.currentTimeMillis())
|
||||
)
|
||||
)
|
||||
).onComplete {
|
||||
case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) inserted on UserReaction table!")
|
||||
case Failure(e) => DatabaseConnection.logger.debug(s"Error inserting UserReaction: $e")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.bigbluebutton.core.models
|
||||
|
||||
import com.softwaremill.quicklens._
|
||||
import org.bigbluebutton.core.db.{ UserDAO, UserStateDAO }
|
||||
import org.bigbluebutton.core.db.{ UserDAO, UserReactionDAO, UserStateDAO }
|
||||
import org.bigbluebutton.core.util.TimeUtil
|
||||
import org.bigbluebutton.core2.message.senders.MsgBuilder
|
||||
|
||||
@ -203,6 +203,7 @@ object Users2x {
|
||||
.modify(_.reactionChangedOn).setTo(System.currentTimeMillis())
|
||||
|
||||
users.save(newUser)
|
||||
UserReactionDAO.insert(intId, reactionEmoji)
|
||||
newUser
|
||||
}
|
||||
}
|
||||
@ -211,8 +212,9 @@ object Users2x {
|
||||
for {
|
||||
u <- findWithIntId(users, intId)
|
||||
} yield {
|
||||
val newUserState = u.modify(_.away).setTo(raiseHand)
|
||||
val newUserState = u.modify(_.raiseHand).setTo(raiseHand)
|
||||
users.save(newUserState)
|
||||
UserStateDAO.update(newUserState)
|
||||
newUserState
|
||||
}
|
||||
}
|
||||
@ -223,6 +225,7 @@ object Users2x {
|
||||
} yield {
|
||||
val newUserState = u.modify(_.away).setTo(away)
|
||||
users.save(newUserState)
|
||||
UserStateDAO.update(newUserState)
|
||||
newUserState
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ DROP VIEW IF EXISTS "v_user_guest";
|
||||
DROP VIEW IF EXISTS "v_user_ref";
|
||||
DROP VIEW IF EXISTS "v_user_customParameter";
|
||||
DROP VIEW IF EXISTS "v_user_welcomeMsgs";
|
||||
DROP VIEW IF EXISTS "v_user_reaction";
|
||||
DROP VIEW IF EXISTS "v_user_reaction_current";
|
||||
DROP TABLE IF EXISTS "user_camera";
|
||||
DROP TABLE IF EXISTS "user_voice";
|
||||
--DROP TABLE IF EXISTS "user_whiteboard";
|
||||
@ -62,6 +64,7 @@ DROP TABLE IF EXISTS "user_connectionStatus";
|
||||
DROP TABLE IF EXISTS "user_connectionStatusMetrics";
|
||||
DROP TABLE IF EXISTS "user_customParameter";
|
||||
DROP TABLE IF EXISTS "user_localSettings";
|
||||
DROP TABLE IF EXISTS "user_reaction";
|
||||
DROP TABLE IF EXISTS "user";
|
||||
|
||||
DROP VIEW IF EXISTS "v_meeting_lockSettings";
|
||||
@ -729,6 +732,28 @@ CREATE TABLE "user_localSettings"(
|
||||
CREATE INDEX "idx_user_local_settings_meetingId" ON "user_localSettings"("meetingId");
|
||||
|
||||
|
||||
CREATE TABLE "user_reaction" (
|
||||
"userId" varchar(50) REFERENCES "user"("userId") ON DELETE CASCADE,
|
||||
"reactionEmoji" varchar(25),
|
||||
"duration" integer,
|
||||
"createdAt" timestamp
|
||||
);
|
||||
|
||||
ALTER TABLE "user_reaction" ADD COLUMN "expiresAt" timestamp GENERATED ALWAYS AS
|
||||
("createdAt" + '1 seconds'::INTERVAL * "duration") STORED;
|
||||
|
||||
CREATE INDEX "idx_user_reaction_userId_createdAt" ON "user_reaction"("userId", "expiresAt");
|
||||
|
||||
CREATE VIEW v_user_reaction AS
|
||||
SELECT u."meetingId", ur."userId", ur."reactionEmoji", ur."createdAt", ur."expiresAt"
|
||||
FROM "user" u
|
||||
JOIN "user_reaction" ur ON u."userId" = ur."userId" AND "expiresAt" > current_timestamp;
|
||||
|
||||
CREATE VIEW v_user_reaction_current AS
|
||||
SELECT u."meetingId", ur."userId", (array_agg(ur."reactionEmoji" ORDER BY ur."expiresAt" DESC))[1] as "reactionEmoji"
|
||||
FROM "user" u
|
||||
JOIN "user_reaction" ur ON u."userId" = ur."userId" AND "expiresAt" > current_timestamp
|
||||
GROUP BY u."meetingId", ur."userId";
|
||||
|
||||
|
||||
-- ===================== CHAT TABLES
|
||||
|
@ -34,6 +34,15 @@ object_relationships:
|
||||
remote_table:
|
||||
name: meeting
|
||||
schema: public
|
||||
- name: reaction
|
||||
using:
|
||||
manual_configuration:
|
||||
column_mapping:
|
||||
userId: userId
|
||||
insertion_order: null
|
||||
remote_table:
|
||||
name: v_user_reaction_current
|
||||
schema: public
|
||||
- name: voice
|
||||
using:
|
||||
manual_configuration:
|
||||
|
@ -70,6 +70,15 @@ object_relationships:
|
||||
remote_table:
|
||||
name: meeting
|
||||
schema: public
|
||||
- name: reaction
|
||||
using:
|
||||
manual_configuration:
|
||||
column_mapping:
|
||||
userId: userId
|
||||
insertion_order: null
|
||||
remote_table:
|
||||
name: v_user_reaction
|
||||
schema: public
|
||||
- name: voice
|
||||
using:
|
||||
manual_configuration:
|
||||
|
@ -0,0 +1,29 @@
|
||||
table:
|
||||
name: v_user_reaction
|
||||
schema: public
|
||||
configuration:
|
||||
column_config: {}
|
||||
custom_column_names: {}
|
||||
custom_name: user_reaction
|
||||
custom_root_fields: {}
|
||||
object_relationships:
|
||||
- name: user
|
||||
using:
|
||||
manual_configuration:
|
||||
column_mapping:
|
||||
userId: userId
|
||||
insertion_order: null
|
||||
remote_table:
|
||||
name: v_user_ref
|
||||
schema: public
|
||||
select_permissions:
|
||||
- role: bbb_client
|
||||
permission:
|
||||
columns:
|
||||
- createdAt
|
||||
- expiresAt
|
||||
- reactionEmoji
|
||||
- userId
|
||||
filter:
|
||||
meetingId:
|
||||
_eq: X-Hasura-MeetingId
|
@ -0,0 +1,27 @@
|
||||
table:
|
||||
name: v_user_reaction_current
|
||||
schema: public
|
||||
configuration:
|
||||
column_config: {}
|
||||
custom_column_names: {}
|
||||
custom_name: user_reaction_current
|
||||
custom_root_fields: {}
|
||||
object_relationships:
|
||||
- name: user
|
||||
using:
|
||||
manual_configuration:
|
||||
column_mapping:
|
||||
userId: userId
|
||||
insertion_order: null
|
||||
remote_table:
|
||||
name: v_user_ref
|
||||
schema: public
|
||||
select_permissions:
|
||||
- role: bbb_client
|
||||
permission:
|
||||
columns:
|
||||
- reactionEmoji
|
||||
- userId
|
||||
filter:
|
||||
meetingId:
|
||||
_eq: X-Hasura-MeetingId
|
@ -38,6 +38,8 @@
|
||||
- "!include public_v_user_current.yaml"
|
||||
- "!include public_v_user_customParameter.yaml"
|
||||
- "!include public_v_user_guest.yaml"
|
||||
- "!include public_v_user_reaction.yaml"
|
||||
- "!include public_v_user_reaction_current.yaml"
|
||||
- "!include public_v_user_ref.yaml"
|
||||
- "!include public_v_user_typing_private.yaml"
|
||||
- "!include public_v_user_typing_public.yaml"
|
||||
|
Loading…
Reference in New Issue
Block a user