Plume/src/routes/notifications.rs

19 lines
603 B
Rust
Raw Normal View History

2018-06-04 21:57:03 +02:00
use rocket::response::{Redirect, Flash};
2018-05-13 15:35:55 +02:00
use rocket_contrib::Template;
use plume_common::utils;
use plume_models::{db_conn::DbConn, notifications::Notification, users::User};
2018-06-04 21:57:03 +02:00
2018-05-13 15:35:55 +02:00
#[get("/notifications")]
fn notifications(conn: DbConn, user: User) -> Template {
Template::render("notifications/index", json!({
"account": user,
"notifications": Notification::find_for_user(&*conn, &user)
}))
}
2018-06-04 21:57:03 +02:00
#[get("/notifications", rank = 2)]
fn notifications_auth() -> Flash<Redirect>{
utils::requires_login("You need to be logged in order to see your notifications", uri!(notifications))
2018-06-04 21:57:03 +02:00
}