blob: ba4dcdeac3347fcc1c11e0074dd1ba84ee84a962 [file]
use crate::binary::sender::Sender;
use crate::state::command::EntryCommand;
use crate::streaming::session::Session;
use crate::streaming::systems::system::SharedSystem;
use anyhow::Result;
use iggy::error::IggyError;
use iggy::topics::purge_topic::PurgeTopic;
use tracing::debug;
pub async fn handle(
command: PurgeTopic,
sender: &mut dyn Sender,
session: &Session,
system: &SharedSystem,
) -> Result<(), IggyError> {
debug!("session: {session}, command: {command}");
let system = system.read().await;
system
.purge_topic(session, &command.stream_id, &command.topic_id)
.await?;
system
.state
.apply(session.get_user_id(), EntryCommand::PurgeTopic(command))
.await?;
sender.send_empty_ok_response().await?;
Ok(())
}