@@ -19,10 +19,7 @@ impl Database {
#[cfg(test)]
pub async fn create_root_channel(&self, name: &str, creator_id: UserId) -> Result<ChannelId> {
- Ok(self
- .create_channel(name, None, creator_id)
- .await?
- .id)
+ Ok(self.create_channel(name, None, creator_id).await?.id)
}
#[cfg(test)]
@@ -18,13 +18,9 @@ async fn test_channel_message_retrieval(db: &Arc<Database>) {
let channel = db.create_channel("channel", None, user).await.unwrap();
let owner_id = db.create_server("test").await.unwrap().0 as u32;
- db.join_channel_chat(
- channel.id,
- rpc::ConnectionId { owner_id, id: 0 },
- user,
- )
- .await
- .unwrap();
+ db.join_channel_chat(channel.id, rpc::ConnectionId { owner_id, id: 0 }, user)
+ .await
+ .unwrap();
let mut all_messages = Vec::new();
for i in 0..10 {
@@ -366,11 +362,7 @@ async fn test_channel_message_mentions(db: &Arc<Database>) {
let user_b = new_test_user(db, "user_b@example.com").await;
let user_c = new_test_user(db, "user_c@example.com").await;
- let channel = db
- .create_channel("channel", None, user_a)
- .await
- .unwrap()
- .id;
+ let channel = db.create_channel("channel", None, user_a).await.unwrap().id;
db.invite_channel_member(channel, user_b, user_a, ChannelRole::Member)
.await
.unwrap();
@@ -3,11 +3,10 @@ mod connection_pool;
use crate::{
auth::{self, Impersonator},
db::{
- self, BufferId, ChannelId, ChannelRole, ChannelsForUser,
- CreatedChannelMessage, Database, InviteMemberResult, MembershipUpdated, MessageId,
- NotificationId, ProjectId, RemoveChannelMemberResult,
- RenameChannelResult, RespondToChannelInvite, RoomId, ServerId, SetChannelVisibilityResult,
- User, UserId,
+ self, BufferId, ChannelId, ChannelRole, ChannelsForUser, CreatedChannelMessage, Database,
+ InviteMemberResult, MembershipUpdated, MessageId, NotificationId, ProjectId,
+ RemoveChannelMemberResult, RenameChannelResult, RespondToChannelInvite, RoomId, ServerId,
+ SetChannelVisibilityResult, User, UserId,
},
executor::Executor,
AppState, Error, Result,
@@ -2570,53 +2569,57 @@ async fn move_channel(
let channel_id = ChannelId::from_proto(request.channel_id);
let to = request.to.map(ChannelId::from_proto);
- let result = session.db().await.move_channel(channel_id, to, session.user_id).await?;
+ let result = session
+ .db()
+ .await
+ .move_channel(channel_id, to, session.user_id)
+ .await?;
if let Some(result) = result {
- let participants_to_update: HashMap<_, _> = session.db().await
- .new_participants_to_notify(
- to.unwrap_or(channel_id)
- )
- .await?
- .into_iter()
- .collect();
+ let participants_to_update: HashMap<_, _> = session
+ .db()
+ .await
+ .new_participants_to_notify(to.unwrap_or(channel_id))
+ .await?
+ .into_iter()
+ .collect();
- let mut moved_channels: HashSet<ChannelId> = HashSet::default();
- for id in result.descendent_ids {
- moved_channels.insert(id);
- }
- moved_channels.insert(channel_id);
+ let mut moved_channels: HashSet<ChannelId> = HashSet::default();
+ for id in result.descendent_ids {
+ moved_channels.insert(id);
+ }
+ moved_channels.insert(channel_id);
- let mut participants_to_remove: HashSet<UserId> = HashSet::default();
- for participant in result.previous_participants {
- if participant.kind == proto::channel_member::Kind::AncestorMember {
- if !participants_to_update.contains_key(&participant.user_id) {
- participants_to_remove.insert(participant.user_id);
- }
- }
+ let mut participants_to_remove: HashSet<UserId> = HashSet::default();
+ for participant in result.previous_participants {
+ if participant.kind == proto::channel_member::Kind::AncestorMember {
+ if !participants_to_update.contains_key(&participant.user_id) {
+ participants_to_remove.insert(participant.user_id);
}
+ }
+ }
- let moved_channels: Vec<u64> = moved_channels.iter().map(|id| id.to_proto()).collect();
+ let moved_channels: Vec<u64> = moved_channels.iter().map(|id| id.to_proto()).collect();
- let connection_pool = session.connection_pool().await;
- for (user_id, channels) in participants_to_update {
- let mut update = build_channels_update(channels, vec![]);
- update.delete_channels = moved_channels.clone();
- for connection_id in connection_pool.user_connection_ids(user_id) {
- session.peer.send(connection_id, update.clone())?;
- }
- }
+ let connection_pool = session.connection_pool().await;
+ for (user_id, channels) in participants_to_update {
+ let mut update = build_channels_update(channels, vec![]);
+ update.delete_channels = moved_channels.clone();
+ for connection_id in connection_pool.user_connection_ids(user_id) {
+ session.peer.send(connection_id, update.clone())?;
+ }
+ }
- for user_id in participants_to_remove {
- let update = proto::UpdateChannels {
- delete_channels: moved_channels.clone(),
- ..Default::default()
- };
- for connection_id in connection_pool.user_connection_ids(user_id) {
- session.peer.send(connection_id, update.clone())?;
- }
- }
+ for user_id in participants_to_remove {
+ let update = proto::UpdateChannels {
+ delete_channels: moved_channels.clone(),
+ ..Default::default()
+ };
+ for connection_id in connection_pool.user_connection_ids(user_id) {
+ session.peer.send(connection_id, update.clone())?;
+ }
}
+ }
response.send(Ack {})?;
Ok(())