mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 05:26:59 +00:00
24 lines
596 B
Rust
24 lines
596 B
Rust
use revolt_quark::{models::{User, Message}, perms, Db, Error, Ref, Result};
|
|
|
|
use rocket::serde::json::Json;
|
|
|
|
#[get("/<target>/messages/<msg>")]
|
|
pub async fn req(db: &Db, user: User, target: Ref, msg: Ref) -> Result<Json<Message>> {
|
|
let channel = target.as_channel(db).await?;
|
|
if !perms(&user)
|
|
.channel(&channel)
|
|
.calc_channel(db)
|
|
.await
|
|
.get_view()
|
|
{
|
|
return Err(Error::NotFound);
|
|
}
|
|
|
|
let message = msg.as_message(db).await?;
|
|
if message.channel != channel.as_id() {
|
|
return Err(Error::NotFound);
|
|
}
|
|
|
|
Ok(Json(message))
|
|
}
|