mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
21 lines
549 B
Rust
21 lines
549 B
Rust
use crate::database::*;
|
|
use crate::util::result::{Error, Result};
|
|
|
|
use rocket_contrib::json::JsonValue;
|
|
|
|
#[get("/<target>/messages/<msg>")]
|
|
pub async fn req(user: User, target: Ref, msg: Ref) -> Result<JsonValue> {
|
|
let channel = target.fetch_channel().await?;
|
|
|
|
let perm = permissions::PermissionCalculator::new(&user)
|
|
.with_channel(&channel)
|
|
.for_channel()
|
|
.await?;
|
|
if !perm.get_view() {
|
|
Err(Error::MissingPermission)?
|
|
}
|
|
|
|
let message = msg.fetch_message(&channel).await?;
|
|
Ok(json!(message))
|
|
}
|