WIP: improve move and link handling around 'root paths', currently very incorrect and in need of a deeper rework
This commit is contained in:
parent
cda54b8b5f
commit
7fa68a9aa4
6 changed files with 362 additions and 167 deletions
|
@ -2435,22 +2435,23 @@ async fn unlink_channel(
|
|||
let db = session.db().await;
|
||||
let channel_id = ChannelId::from_proto(request.channel_id);
|
||||
let from = request.from.map(ChannelId::from_proto);
|
||||
|
||||
// Get the members before we remove it, so we know who to notify
|
||||
let members = db.get_channel_members(channel_id).await?;
|
||||
|
||||
db.unlink_channel(session.user_id, channel_id, from).await?;
|
||||
|
||||
if let Some(from_parent) = from {
|
||||
let members = db.get_channel_members(from_parent).await?;
|
||||
let update = proto::UpdateChannels {
|
||||
delete_channel_edge: vec![proto::ChannelEdge {
|
||||
channel_id: channel_id.to_proto(),
|
||||
parent_id: from_parent.to_proto(),
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
let connection_pool = session.connection_pool().await;
|
||||
for member_id in members {
|
||||
for connection_id in connection_pool.user_connection_ids(member_id) {
|
||||
session.peer.send(connection_id, update.clone())?;
|
||||
}
|
||||
let update = proto::UpdateChannels {
|
||||
delete_channel_edge: vec![proto::ChannelEdge {
|
||||
channel_id: channel_id.to_proto(),
|
||||
parent_id: from.map(ChannelId::to_proto),
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
let connection_pool = session.connection_pool().await;
|
||||
for member_id in members {
|
||||
for connection_id in connection_pool.user_connection_ids(member_id) {
|
||||
session.peer.send(connection_id, update.clone())?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2468,16 +2469,24 @@ async fn move_channel(
|
|||
let channel_id = ChannelId::from_proto(request.channel_id);
|
||||
let from_parent = request.from.map(ChannelId::from_proto);
|
||||
let to = ChannelId::from_proto(request.to);
|
||||
|
||||
let mut members = db.get_channel_members(channel_id).await?;
|
||||
|
||||
let channels_to_send: Vec<Channel> = db
|
||||
.move_channel(session.user_id, channel_id, from_parent, to)
|
||||
.await?;
|
||||
|
||||
let members_after = db.get_channel_members(channel_id).await?;
|
||||
|
||||
members.extend(members_after);
|
||||
members.sort();
|
||||
members.dedup();
|
||||
|
||||
if let Some(from_parent) = from_parent {
|
||||
let members = db.get_channel_members(from_parent).await?;
|
||||
let update = proto::UpdateChannels {
|
||||
delete_channel_edge: vec![proto::ChannelEdge {
|
||||
channel_id: channel_id.to_proto(),
|
||||
parent_id: from_parent.to_proto(),
|
||||
parent_id: Some(from_parent.to_proto()),
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -2489,7 +2498,6 @@ async fn move_channel(
|
|||
}
|
||||
}
|
||||
|
||||
let members = db.get_channel_members(to).await?;
|
||||
let connection_pool = session.connection_pool().await;
|
||||
let update = proto::UpdateChannels {
|
||||
channels: channels_to_send
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue