feat: add last message cache to gateway

This commit is contained in:
alyssa 2025-04-01 10:48:20 +00:00
parent 15c992c572
commit a8664665a6
10 changed files with 172 additions and 18 deletions

View file

@ -8,7 +8,7 @@ use axum::{
use libpk::runtime_config::RuntimeConfig;
use serde_json::{json, to_string};
use tracing::{error, info};
use twilight_model::id::Id;
use twilight_model::id::{marker::ChannelMarker, Id};
use crate::{
discord::{
@ -136,7 +136,10 @@ pub async fn run_server(cache: Arc<DiscordCache>, runtime_config: Arc<RuntimeCon
)
.route(
"/guilds/:guild_id/channels/:channel_id/last_message",
get(|| async { status_code(StatusCode::NOT_IMPLEMENTED, "".to_string()) }),
get(|State(cache): State<Arc<DiscordCache>>, Path((_guild_id, channel_id)): Path<(u64, Id<ChannelMarker>)>| async move {
let lm = cache.get_last_message(channel_id).await;
status_code(StatusCode::FOUND, to_string(&lm).unwrap())
}),
)
.route(