Compare commits

...
5 Commits
8 changed files with 19 additions and 9 deletions

No files matched your search

Generated
+1
View File
@@ -6905,6 +6905,7 @@ dependencies = [
"revolt_rocket_okapi", "revolt_rocket_okapi",
"rocket", "rocket",
"schemars 0.8.22", "schemars 0.8.22",
"sentry",
"serde", "serde",
"serde_json", "serde_json",
"utoipa", "utoipa",
+3 -1
View File
@@ -295,7 +295,9 @@ pub enum EventV1 {
}, },
UserMoveVoiceChannel { UserMoveVoiceChannel {
node: String, node: String,
token: String from: String,
to: String,
token: String,
} }
} }
+1 -1
View File
@@ -16,7 +16,7 @@ mod voice_client;
pub use voice_client::VoiceClient; pub use voice_client::VoiceClient;
async fn get_connection() -> Result<Conn> { async fn get_connection() -> Result<Conn> {
_get_connection().await.to_internal_error() _get_connection().await.map_err(|_| create_error!(InternalError))
} }
pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> { pub async fn raise_if_in_voice(user: &User, channel_id: &str) -> Result<()> {
+4 -1
View File
@@ -15,8 +15,9 @@ utoipa = ["dep:utoipa"]
rocket = ["dep:rocket", "dep:serde_json"] rocket = ["dep:rocket", "dep:serde_json"]
axum = ["dep:axum", "dep:serde_json"] axum = ["dep:axum", "dep:serde_json"]
okapi = ["dep:revolt_rocket_okapi", "dep:revolt_okapi", "schemas"] okapi = ["dep:revolt_rocket_okapi", "dep:revolt_okapi", "schemas"]
sentry = ["dep:sentry"]
default = ["serde"] default = ["serde", "sentry"]
[dependencies] [dependencies]
# Serialisation # Serialisation
@@ -36,3 +37,5 @@ revolt_okapi = { version = "0.9.1", optional = true }
log = "0.4" log = "0.4"
# Axum # Axum
axum = { version = "0.7.5", optional = true } axum = { version = "0.7.5", optional = true }
sentry = { version = "0.31.5", optional = true }
+3 -1
View File
@@ -226,7 +226,7 @@ pub trait ToRevoltError<T> {
fn to_internal_error(self) -> Result<T, Error>; fn to_internal_error(self) -> Result<T, Error>;
} }
impl<T, E: std::fmt::Debug> ToRevoltError<T> for Result<T, E> { impl<T, E: std::fmt::Debug + std::error::Error> ToRevoltError<T> for Result<T, E> {
#[track_caller] #[track_caller]
fn to_internal_error(self) -> Result<T, Error> { fn to_internal_error(self) -> Result<T, Error> {
let loc = Location::caller(); let loc = Location::caller();
@@ -234,6 +234,8 @@ impl<T, E: std::fmt::Debug> ToRevoltError<T> for Result<T, E> {
self self
.map_err(|e| { .map_err(|e| {
log::error!("{e:?}"); log::error!("{e:?}");
#[cfg(feature = "sentry")]
sentry::capture_error(&e);
Error { Error {
error_type: ErrorType::InternalError, error_type: ErrorType::InternalError,
+3 -3
View File
@@ -199,8 +199,8 @@ pub async fn ingress(
}; };
} }
} }
// Audio/video track was started/stopped // Audio/video track was started/stopped/unmuted/muted
"track_published" | "track_unpublished" => { "track_published" | "track_unpublished" | "track_unmuted" | "track_muted" => {
let channel_id = channel_id.to_internal_error()?; let channel_id = channel_id.to_internal_error()?;
let user_id = user_id.to_internal_error()?; let user_id = user_id.to_internal_error()?;
let track = event.track.as_ref().to_internal_error()?; let track = event.track.as_ref().to_internal_error()?;
@@ -255,7 +255,7 @@ pub async fn ingress(
channel_id, channel_id,
channel.server(), channel.server(),
user_id, user_id,
event.event == "track_published", // to avoid duplicating this entire case twice event.event == "track_published" || event.event == "track_unmuted", // to avoid duplicating this entire case twice
track.source, track.source,
) )
.await?; .await?;
@@ -103,7 +103,7 @@ pub async fn call(
log::debug!("Created room {}", room.name); log::debug!("Created room {}", room.name);
if let Some(recipients) = recipients { if let Some(recipients) = recipients {
if room.num_participants == 0 { if room.num_participants == 0 && !recipients.is_empty() {
set_call_notification_recipients(channel.id(), &user.id, &recipients).await?; set_call_notification_recipients(channel.id(), &user.id, &recipients).await?;
} }
} }
@@ -217,9 +217,11 @@ pub async fn edit(
EventV1::UserMoveVoiceChannel { EventV1::UserMoveVoiceChannel {
node: new_node, node: new_node,
from: channel,
to: new_voice_channel.id().to_string(),
token, token,
} }
.p_user(target_user.id.clone(), db) .private(target_user.id.clone())
.await; .await;
}; };
} else if can_publish.is_some() || can_receive.is_some() || remove_contains_voice { } else if can_publish.is_some() || can_receive.is_some() || remove_contains_voice {