Start development sprint 3.
This commit is contained in:
16
src/routes/channels/fetch_channel.rs
Normal file
16
src/routes/channels/fetch_channel.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use rocket_contrib::json::JsonValue;
|
||||
|
||||
#[get("/<target>")]
|
||||
pub async fn req(user: User, target: Ref) -> Result<JsonValue> {
|
||||
let target = target.fetch_channel().await?;
|
||||
|
||||
let perm = permissions::channel::calculate(&user, &target).await;
|
||||
if !perm.get_view() {
|
||||
Err(Error::LabelMe)?
|
||||
}
|
||||
|
||||
Ok(json!(target))
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
use rocket::Route;
|
||||
|
||||
mod fetch_channel;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![]
|
||||
routes![
|
||||
fetch_channel::req
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user