Files
stoatchat/src/routes/channels/channel_ack.rs
2022-02-19 19:49:10 +00:00

20 lines
515 B
Rust

use revolt_quark::{models::User, perms, Db, EmptyResponse, Error, Ref, Result};
#[put("/<target>/ack/<message>")]
pub async fn req(db: &Db, user: User, target: Ref, message: Ref) -> Result<EmptyResponse> {
let channel = target.as_channel(db).await?;
if !perms(&user)
.channel(&channel)
.calc_channel(db)
.await
.get_view()
{
return Err(Error::NotFound);
}
channel
.ack(db, &user.id, &message.id)
.await
.map(|_| EmptyResponse)
}