Guest roles (#3140)
Release Notes: - Added a "guest" role to channels, and made that the default when a new user joins a public channel.
This commit is contained in:
commit
cc9e92857b
33 changed files with 2320 additions and 1711 deletions
|
@ -410,10 +410,10 @@ async fn test_channel_buffer_disconnect(
|
|||
server.disconnect_client(client_a.peer_id().unwrap());
|
||||
deterministic.advance_clock(RECEIVE_TIMEOUT + RECONNECT_TIMEOUT);
|
||||
|
||||
channel_buffer_a.update(cx_a, |buffer, _| {
|
||||
channel_buffer_a.update(cx_a, |buffer, cx| {
|
||||
assert_eq!(
|
||||
buffer.channel().as_ref(),
|
||||
&channel(channel_id, "the-channel")
|
||||
buffer.channel(cx).unwrap().as_ref(),
|
||||
&channel(channel_id, "the-channel", proto::ChannelRole::Admin)
|
||||
);
|
||||
assert!(!buffer.is_connected());
|
||||
});
|
||||
|
@ -435,18 +435,16 @@ async fn test_channel_buffer_disconnect(
|
|||
deterministic.run_until_parked();
|
||||
|
||||
// Channel buffer observed the deletion
|
||||
channel_buffer_b.update(cx_b, |buffer, _| {
|
||||
assert_eq!(
|
||||
buffer.channel().as_ref(),
|
||||
&channel(channel_id, "the-channel")
|
||||
);
|
||||
channel_buffer_b.update(cx_b, |buffer, cx| {
|
||||
assert!(buffer.channel(cx).is_none());
|
||||
assert!(!buffer.is_connected());
|
||||
});
|
||||
}
|
||||
|
||||
fn channel(id: u64, name: &'static str) -> Channel {
|
||||
fn channel(id: u64, name: &'static str, role: proto::ChannelRole) -> Channel {
|
||||
Channel {
|
||||
id,
|
||||
role,
|
||||
name: name.to_string(),
|
||||
visibility: proto::ChannelVisibility::Members,
|
||||
unseen_note_version: None,
|
||||
|
@ -698,7 +696,7 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
|||
.await
|
||||
.unwrap();
|
||||
channel_view_1_a.update(cx_a, |notes, cx| {
|
||||
assert_eq!(notes.channel(cx).name, "channel-1");
|
||||
assert_eq!(notes.channel(cx).unwrap().name, "channel-1");
|
||||
notes.editor.update(cx, |editor, cx| {
|
||||
editor.insert("Hello from A.", cx);
|
||||
editor.change_selections(None, cx, |selections| {
|
||||
|
@ -730,7 +728,7 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
|||
.expect("active item is not a channel view")
|
||||
});
|
||||
channel_view_1_b.read_with(cx_b, |notes, cx| {
|
||||
assert_eq!(notes.channel(cx).name, "channel-1");
|
||||
assert_eq!(notes.channel(cx).unwrap().name, "channel-1");
|
||||
let editor = notes.editor.read(cx);
|
||||
assert_eq!(editor.text(cx), "Hello from A.");
|
||||
assert_eq!(editor.selections.ranges::<usize>(cx), &[3..4]);
|
||||
|
@ -742,7 +740,7 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
|||
.await
|
||||
.unwrap();
|
||||
channel_view_2_a.read_with(cx_a, |notes, cx| {
|
||||
assert_eq!(notes.channel(cx).name, "channel-2");
|
||||
assert_eq!(notes.channel(cx).unwrap().name, "channel-2");
|
||||
});
|
||||
|
||||
// Client B is taken to the notes for channel 2.
|
||||
|
@ -759,7 +757,7 @@ async fn test_following_to_channel_notes_without_a_shared_project(
|
|||
.expect("active item is not a channel view")
|
||||
});
|
||||
channel_view_2_b.read_with(cx_b, |notes, cx| {
|
||||
assert_eq!(notes.channel(cx).name, "channel-2");
|
||||
assert_eq!(notes.channel(cx).unwrap().name, "channel-2");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,7 +48,7 @@ impl RandomizedTest for RandomChannelBufferTest {
|
|||
let db = &server.app_state.db;
|
||||
for ix in 0..CHANNEL_COUNT {
|
||||
let id = db
|
||||
.create_channel(&format!("channel-{ix}"), None, users[0].user_id)
|
||||
.create_root_channel(&format!("channel-{ix}"), users[0].user_id)
|
||||
.await
|
||||
.unwrap();
|
||||
for user in &users[1..] {
|
||||
|
@ -98,15 +98,16 @@ impl RandomizedTest for RandomChannelBufferTest {
|
|||
|
||||
30..=40 => {
|
||||
if let Some(buffer) = channel_buffers.iter().choose(rng) {
|
||||
let channel_name = buffer.read_with(cx, |b, _| b.channel().name.clone());
|
||||
let channel_name =
|
||||
buffer.read_with(cx, |b, cx| b.channel(cx).unwrap().name.clone());
|
||||
break ChannelBufferOperation::LeaveChannelNotes { channel_name };
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
if let Some(buffer) = channel_buffers.iter().choose(rng) {
|
||||
break buffer.read_with(cx, |b, _| {
|
||||
let channel_name = b.channel().name.clone();
|
||||
break buffer.read_with(cx, |b, cx| {
|
||||
let channel_name = b.channel(cx).unwrap().name.clone();
|
||||
let edits = b
|
||||
.buffer()
|
||||
.read_with(cx, |buffer, _| buffer.get_random_edits(rng, 3));
|
||||
|
@ -153,7 +154,7 @@ impl RandomizedTest for RandomChannelBufferTest {
|
|||
let buffer = cx.update(|cx| {
|
||||
let mut left_buffer = Err(TestError::Inapplicable);
|
||||
client.channel_buffers().retain(|buffer| {
|
||||
if buffer.read(cx).channel().name == channel_name {
|
||||
if buffer.read(cx).channel(cx).unwrap().name == channel_name {
|
||||
left_buffer = Ok(buffer.clone());
|
||||
false
|
||||
} else {
|
||||
|
@ -179,7 +180,9 @@ impl RandomizedTest for RandomChannelBufferTest {
|
|||
client
|
||||
.channel_buffers()
|
||||
.iter()
|
||||
.find(|buffer| buffer.read(cx).channel().name == channel_name)
|
||||
.find(|buffer| {
|
||||
buffer.read(cx).channel(cx).unwrap().name == channel_name
|
||||
})
|
||||
.cloned()
|
||||
})
|
||||
.ok_or_else(|| TestError::Inapplicable)?;
|
||||
|
@ -250,7 +253,7 @@ impl RandomizedTest for RandomChannelBufferTest {
|
|||
if let Some(channel_buffer) = client
|
||||
.channel_buffers()
|
||||
.iter()
|
||||
.find(|b| b.read(cx).channel().id == channel_id.to_proto())
|
||||
.find(|b| b.read(cx).channel_id == channel_id.to_proto())
|
||||
{
|
||||
let channel_buffer = channel_buffer.read(cx);
|
||||
|
||||
|
|
|
@ -611,38 +611,6 @@ impl TestClient {
|
|||
) -> WindowHandle<Workspace> {
|
||||
cx.add_window(|cx| Workspace::new(0, project.clone(), self.app_state.clone(), cx))
|
||||
}
|
||||
|
||||
pub async fn add_admin_to_channel(
|
||||
&self,
|
||||
user: (&TestClient, &mut TestAppContext),
|
||||
channel: u64,
|
||||
cx_self: &mut TestAppContext,
|
||||
) {
|
||||
let (other_client, other_cx) = user;
|
||||
|
||||
cx_self
|
||||
.read(ChannelStore::global)
|
||||
.update(cx_self, |channel_store, cx| {
|
||||
channel_store.invite_member(
|
||||
channel,
|
||||
other_client.user_id().unwrap(),
|
||||
ChannelRole::Admin,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
cx_self.foreground().run_until_parked();
|
||||
|
||||
other_cx
|
||||
.read(ChannelStore::global)
|
||||
.update(other_cx, |channel_store, cx| {
|
||||
channel_store.respond_to_channel_invite(channel, true, cx)
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TestClient {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue