cargo fmt + clippy fixes, remove unused voice_membership.rs

This commit is contained in:
loki5512344 2026-07-09 13:07:38 +02:00
parent 9821814240
commit c34ed2a192
Signed by: boba
GPG key ID: 253067914055423B
13 changed files with 108 additions and 245 deletions

View file

@ -99,6 +99,7 @@ pub async fn handle_channel_create(
let created = channels::create(&state.channels, &channel_id, &channel_name, kind.clone()).await;
// Persist to DB (best-effort, log and continue on failure).
#[allow(clippy::collapsible_if)]
if created {
if let Err(e) = state
.storage
@ -204,6 +205,7 @@ pub async fn handle_channel_delete(
let existed = channels::delete(&state.channels, &req.channel_id).await;
// Remove from DB (best-effort).
#[allow(clippy::collapsible_if)]
if existed {
if let Err(e) = state.storage.delete_channel(&req.channel_id).await {
warn!("failed to remove channel from storage: {e}");

View file

@ -110,16 +110,16 @@ pub async fn join(
});
}
if let Some(tx) = &state.voice_member_tx {
if let Some(sess) = session::get(&state.sessions, session_id).await {
let event = serde_json::json!({
"type": "joined",
"channel_id": channel_id,
"session_id": session_id,
"user_id": sess.user_id,
});
let _ = tx.send(event.to_string());
}
if let Some(tx) = &state.voice_member_tx
&& let Some(sess) = session::get(&state.sessions, session_id).await
{
let event = serde_json::json!({
"type": "joined",
"channel_id": channel_id,
"session_id": session_id,
"user_id": sess.user_id,
});
let _ = tx.send(event.to_string());
}
info!("session {} joined {channel_id}", &session_id[..8]);

View file

@ -2,7 +2,11 @@ use anyhow::Result;
use tokio::io::{AsyncRead, AsyncWrite};
use tracing::info;
use crate::{domain::{channels, session}, net::state::State, proto::SessionCrypto};
use crate::{
domain::{channels, session},
net::state::State,
proto::SessionCrypto,
};
use super::{broadcast_leave, set_channel};
@ -22,16 +26,16 @@ pub async fn leave(
set_channel(state, session_id, None).await;
broadcast_leave(state, channel_id, session_id).await;
if let Some(tx) = &state.voice_member_tx {
if let Some(ref uid) = user_id {
let event = serde_json::json!({
"type": "left",
"channel_id": channel_id,
"session_id": session_id,
"user_id": uid,
});
let _ = tx.send(event.to_string());
}
if let Some(tx) = &state.voice_member_tx
&& let Some(ref uid) = user_id
{
let event = serde_json::json!({
"type": "left",
"channel_id": channel_id,
"session_id": session_id,
"user_id": uid,
});
let _ = tx.send(event.to_string());
}
info!("session {} left {channel_id}", &session_id[..8]);