From 88ed5f7290c19c10c18143e988289ac262307a94 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 2 Jan 2024 20:14:30 -0700 Subject: [PATCH] Plumbing to pass `role` for room participants --- crates/collab/migrations.sqlite/20221109000000_test_schema.sql | 3 ++- .../20240103025509_add_role_to_room_participants.sql | 1 + crates/collab/src/db/queries/rooms.rs | 2 ++ crates/collab/src/db/tables/room_participant.rs | 3 ++- crates/collab/src/rpc.rs | 2 +- crates/project/src/project.rs | 3 ++- crates/rpc/proto/zed.proto | 1 + 7 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 crates/collab/migrations/20240103025509_add_role_to_room_participants.sql diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index 775a4c1bbe23be4ca05043d06567889a3a8c87cb..9bbbf88dac9879bf12dee3c99c35c8b18ca8d527 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -161,7 +161,8 @@ CREATE TABLE "room_participants" ( "calling_user_id" INTEGER NOT NULL REFERENCES users (id), "calling_connection_id" INTEGER NOT NULL, "calling_connection_server_id" INTEGER REFERENCES servers (id) ON DELETE SET NULL, - "participant_index" INTEGER + "participant_index" INTEGER, + "role" TEXT ); CREATE UNIQUE INDEX "index_room_participants_on_user_id" ON "room_participants" ("user_id"); CREATE INDEX "index_room_participants_on_room_id" ON "room_participants" ("room_id"); diff --git a/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql b/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql new file mode 100644 index 0000000000000000000000000000000000000000..2748e00ebaa18ec375111c648a7accafe90c5dbb --- /dev/null +++ b/crates/collab/migrations/20240103025509_add_role_to_room_participants.sql @@ -0,0 +1 @@ +ALTER TABLE room_participants ADD COLUMN role TEXT; diff --git a/crates/collab/src/db/queries/rooms.rs b/crates/collab/src/db/queries/rooms.rs index 40fdf5d58f184a0444f0c82938ab8fcd2a7bbb69..12d8940d7c3179e0f7c19881dbfea970a64b910f 100644 --- a/crates/collab/src/db/queries/rooms.rs +++ b/crates/collab/src/db/queries/rooms.rs @@ -1126,6 +1126,7 @@ impl Database { projects: Default::default(), location: Some(proto::ParticipantLocation { variant: location }), participant_index: participant_index as u32, + role: db_participant.role.unwrap_or(ChannelRole::Member).into(), }, ); } else { @@ -1137,6 +1138,7 @@ impl Database { } } drop(db_participants); + dbg!(&participants); let mut db_projects = db_room .find_related(project::Entity) diff --git a/crates/collab/src/db/tables/room_participant.rs b/crates/collab/src/db/tables/room_participant.rs index 4c5b8cc11c7a23532de3e7d0ea61f55fe3a4077f..c562111e96957c2457e421f8d7d2a95b9c6c2385 100644 --- a/crates/collab/src/db/tables/room_participant.rs +++ b/crates/collab/src/db/tables/room_participant.rs @@ -1,4 +1,4 @@ -use crate::db::{ProjectId, RoomId, RoomParticipantId, ServerId, UserId}; +use crate::db::{ChannelRole, ProjectId, RoomId, RoomParticipantId, ServerId, UserId}; use rpc::ConnectionId; use sea_orm::entity::prelude::*; @@ -19,6 +19,7 @@ pub struct Model { pub calling_connection_id: i32, pub calling_connection_server_id: Option, pub participant_index: Option, + pub role: Option, } impl Model { diff --git a/crates/collab/src/rpc.rs b/crates/collab/src/rpc.rs index 835b48809da94dc60cd872d473e564a7456da81e..8bb33cae296016dc241c03304154e14266c02f23 100644 --- a/crates/collab/src/rpc.rs +++ b/crates/collab/src/rpc.rs @@ -1504,7 +1504,7 @@ async fn join_project( // First, we send the metadata associated with each worktree. response.send(proto::JoinProjectResponse { worktrees: worktrees.clone(), - replica_id: replica_id.0 as u32, + replica_id: Some(replica_id.0 as u32), collaborators: collaborators.clone(), language_servers: project.language_servers.clone(), })?; diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index a58a7b804f1120c07c4cabc5c8a5b7e3126acbf9..8b3abff0538f970c72555915d831f090c664f82a 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -713,7 +713,8 @@ impl Project { }) .await?; let this = cx.new_model(|cx| { - let replica_id = response.payload.replica_id as ReplicaId; + // todo!() + let replica_id = response.payload.replica_id.unwrap() as ReplicaId; let mut worktrees = Vec::new(); for worktree in response.payload.worktrees { diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index 21fe81ca1b16cf32061ffa6b5e88593bf79fc25d..84d03727c0c59f61d54c59c4f688aeb71e392e87 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -269,6 +269,7 @@ message Participant { repeated ParticipantProject projects = 3; ParticipantLocation location = 4; uint32 participant_index = 5; + ChannelRole role = 6; } message PendingParticipant {