Expire calls where one of both parties doesn't talk for 10 minutes.

This commit is contained in:
2025-08-25 18:24:16 -03:00
parent a75fd9f092
commit 6d8217ed81
10 changed files with 252 additions and 26 deletions
+16 -7
View File
@@ -1,6 +1,7 @@
use std::{error::Error, sync::Arc};
use async_trait::async_trait;
use deadpool_redis::redis::AsyncTypedCommands;
use itertools::Itertools;
use time::{Duration, UtcDateTime};
use twilight_http::{api_error::ApiError, error::ErrorType};
@@ -353,15 +354,13 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
.icon_url(ImageSource::url(avatar_url).unwrap())
.url(message_link),
)
.color(
if replying_to.data.author_mask.is_some() {
COLOR_WHITE
} else {
replying_to_user
.color(if replying_to.data.author_mask.is_some() {
COLOR_WHITE
} else {
replying_to_user
.and_then(|i| i.color.map(|c| c as u32))
.unwrap_or(COLOR_WHITE)
}
)
})
.description(ellipse(replying_to.data.content, 100))
.build(),
);
@@ -393,6 +392,16 @@ impl OnMessageHandler<State, Extras> for CallMessageHandler {
}
}
let mut redis = rt.state.redis.get().await?;
redis
.zadd(
"active-calls",
format!("{}:{}", call.id, channel.id),
UtcDateTime::now().unix_timestamp(),
)
.await?;
let message_sent = match rt
.http
.execute_webhook(Id::new(webhook_id), &webhook_token)