fix: no node state set on channel creation (#653)

* fix: no node state set on channel creation

Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>

* Update "join_call" logic to handle issue of "user is already connected to a channel that cannot be found"

Fixes stoatchat/for-web#951

Signed-off-by: Chris Hultin <chris.hultin@gmail.com>

* feat: remove node key when channel is empty or deleted

---------

Signed-off-by: IAmTomahawkx <iamtomahawkx@gmail.com>
Signed-off-by: Chris Hultin <chris.hultin@gmail.com>
Co-authored-by: Chris Hultin <chris.hultin@gmail.com>
This commit is contained in:
Tom
2026-03-02 20:45:42 -08:00
committed by GitHub
parent f777e2863c
commit 24d0d2b726
3 changed files with 44 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ use revolt_database::{
util::{permissions::perms, reference::Reference},
voice::{
delete_voice_state, get_channel_node, get_user_voice_channels, get_voice_channel_members,
raise_if_in_voice, set_call_notification_recipients, VoiceClient,
raise_if_in_voice, set_call_notification_recipients, set_channel_node, VoiceClient,
},
Database, User,
};
@@ -60,6 +60,7 @@ pub async fn call(
}
let existing_node = get_channel_node(channel.id()).await?;
let has_existing_node = existing_node.is_some(); // we move existing_node in the next statement so this is the quickest way to know if we need to set it.
let node = existing_node
.or(node)
@@ -86,9 +87,11 @@ pub async fn call(
let channel = Reference::from_unchecked(&channel_id)
.as_channel(db)
.await?;
.await;
delete_voice_state(&channel_id, channel.server(), &user.id).await?;
if channel.is_ok() {
delete_voice_state(&channel_id, channel.unwrap().server(), &user.id).await?;
}
}
} else {
raise_if_in_voice(&user, channel.id()).await?;
@@ -100,6 +103,10 @@ pub async fn call(
let room = voice_client.create_room(&node, &channel).await?;
if !has_existing_node {
set_channel_node(channel.id(), &node).await?;
}
log::debug!("Created room {}", room.name);
if let Some(recipients) = recipients {