mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-14 07:51:01 +00:00
Merge pull request #205 from lthms/recent_rocket
Update to a more recent rocket and rust toolchain
This commit is contained in:
commit
fe7f87c47f
17 changed files with 1096 additions and 736 deletions
1714
Cargo.lock
generated
1714
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
14
Cargo.toml
14
Cargo.toml
|
@ -3,10 +3,10 @@ authors = ["Bat' <baptiste@gelez.xyz>"]
|
|||
name = "plume"
|
||||
version = "0.1.0"
|
||||
[dependencies]
|
||||
activitypub = "0.1.1"
|
||||
activitypub = "0.1.3"
|
||||
atom_syndication = "0.6"
|
||||
colored = "1.6"
|
||||
dotenv = "*"
|
||||
dotenv = "0.13"
|
||||
failure = "0.1"
|
||||
gettext-rs = "0.4"
|
||||
guid-create = "0.1"
|
||||
|
@ -33,24 +33,24 @@ path = "plume-models"
|
|||
|
||||
[dependencies.rocket]
|
||||
git = "https://github.com/SergioBenitez/Rocket"
|
||||
rev = "df7111143e466c18d1f56377a8d9530a5a306aba"
|
||||
rev = "55459db7732b9a240826a5c120c650f87e3372ce"
|
||||
|
||||
[dependencies.rocket_codegen]
|
||||
git = "https://github.com/SergioBenitez/Rocket"
|
||||
rev = "df7111143e466c18d1f56377a8d9530a5a306aba"
|
||||
rev = "55459db7732b9a240826a5c120c650f87e3372ce"
|
||||
|
||||
[dependencies.rocket_contrib]
|
||||
features = ["tera_templates", "json"]
|
||||
git = "https://github.com/SergioBenitez/Rocket"
|
||||
rev = "df7111143e466c18d1f56377a8d9530a5a306aba"
|
||||
rev = "55459db7732b9a240826a5c120c650f87e3372ce"
|
||||
|
||||
[dependencies.rocket_csrf]
|
||||
git = "https://github.com/fdb-hiroshima/rocket_csrf"
|
||||
rev = "896fcaf14bd85b3f8266c0201e5f61937d05aec9"
|
||||
rev = "6fc55d26f91f057a20e89ece71d4443e797e7d21"
|
||||
|
||||
[dependencies.rocket_i18n]
|
||||
git = "https://github.com/BaptisteGelez/rocket_i18n"
|
||||
rev = "5b4225d5bed5769482dc926a7e6d6b79f1217be6"
|
||||
rev = "75a3bfd7b847324c078a355a7f101f8241a9f59b"
|
||||
|
||||
[workspace]
|
||||
members = ["plume-models", "plume-common"]
|
||||
|
|
|
@ -14,10 +14,10 @@ failure_derive = "0.1"
|
|||
gettext-rs = "0.4"
|
||||
heck = "0.3.0"
|
||||
hex = "0.3"
|
||||
hyper = "*"
|
||||
openssl = "0.10.6"
|
||||
hyper = "0.11.27"
|
||||
openssl = "0.10.11"
|
||||
reqwest = "0.8"
|
||||
serde = "*"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
|
||||
|
@ -31,4 +31,4 @@ version = "0.1.2"
|
|||
|
||||
[dependencies.rocket]
|
||||
git = "https://github.com/SergioBenitez/Rocket"
|
||||
rev = "df7111143e466c18d1f56377a8d9530a5a306aba"
|
||||
rev = "55459db7732b9a240826a5c120c650f87e3372ce"
|
||||
|
|
|
@ -17,7 +17,7 @@ pub fn make_actor_id(name: String) -> String {
|
|||
}
|
||||
|
||||
pub fn requires_login(message: &str, url: Uri) -> Flash<Redirect> {
|
||||
Flash::new(Redirect::to(Uri::new(format!("/login?m={}", gettext(message.to_string())))), "callback", url.as_str())
|
||||
Flash::new(Redirect::to(format!("/login?m={}", gettext(message.to_string()))), "callback", url.to_string())
|
||||
}
|
||||
|
||||
/// Returns (HTML, mentions)
|
||||
|
|
|
@ -5,13 +5,13 @@ authors = ["Baptiste Gelez <baptiste@gelez.xyz>"]
|
|||
|
||||
[dependencies]
|
||||
activitypub = "0.1.1"
|
||||
ammonia = "1.1.0"
|
||||
ammonia = "1.2.0"
|
||||
bcrypt = "0.2"
|
||||
heck = "0.3.0"
|
||||
lazy_static = "*"
|
||||
openssl = "0.10.6"
|
||||
openssl = "0.10.11"
|
||||
reqwest = "0.8"
|
||||
serde = "*"
|
||||
serde = "1.0"
|
||||
serde_derive = "1.0"
|
||||
serde_json = "1.0"
|
||||
url = "1.7"
|
||||
|
@ -23,11 +23,11 @@ version = "0.4"
|
|||
|
||||
[dependencies.diesel]
|
||||
features = ["postgres", "r2d2", "chrono"]
|
||||
version = "*"
|
||||
version = "1.3.2"
|
||||
|
||||
[dependencies.plume-common]
|
||||
path = "../plume-common"
|
||||
|
||||
[dependencies.rocket]
|
||||
git = "https://github.com/SergioBenitez/Rocket"
|
||||
rev = "df7111143e466c18d1f56377a8d9530a5a306aba"
|
||||
rev = "55459db7732b9a240826a5c120c650f87e3372ce"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![allow(proc_macro_derive_resolution_fallback)] // This can be removed after diesel-1.4
|
||||
|
||||
extern crate activitypub;
|
||||
extern crate ammonia;
|
||||
extern crate bcrypt;
|
||||
|
|
|
@ -1 +1 @@
|
|||
nightly-2018-05-31
|
||||
nightly-2018-07-17
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(custom_derive, decl_macro, plugin)]
|
||||
#![feature(custom_derive, plugin, decl_macro)]
|
||||
#![plugin(rocket_codegen)]
|
||||
|
||||
extern crate activitypub;
|
||||
|
@ -13,6 +13,7 @@ extern crate heck;
|
|||
extern crate multipart;
|
||||
extern crate plume_common;
|
||||
extern crate plume_models;
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
extern crate rocket_contrib;
|
||||
extern crate rocket_csrf;
|
||||
|
|
|
@ -65,7 +65,10 @@ fn new(user: User, conn: DbConn) -> Template {
|
|||
|
||||
#[get("/blogs/new", rank = 2)]
|
||||
fn new_auth() -> Flash<Redirect>{
|
||||
utils::requires_login("You need to be logged in order to create a new blog", uri!(new))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to create a new blog",
|
||||
uri!(new).into()
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(FromForm, Validate, Serialize)]
|
||||
|
|
|
@ -144,8 +144,8 @@ fn shared_inbox(conn: DbConn, data: String) -> String {
|
|||
match instance.received(&*conn, act) {
|
||||
Ok(_) => String::new(),
|
||||
Err(e) => {
|
||||
println!("Shared inbox error: {}\n{}", e.cause(), e.backtrace());
|
||||
format!("Error: {}", e.cause())
|
||||
println!("Shared inbox error: {}\n{}", e.as_fail(), e.backtrace());
|
||||
format!("Error: {}", e.as_fail())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,5 +40,8 @@ fn create(blog: String, slug: String, user: User, conn: DbConn, worker: State<Po
|
|||
|
||||
#[post("/~/<blog>/<slug>/like", rank = 2)]
|
||||
fn create_auth(blog: String, slug: String) -> Flash<Redirect>{
|
||||
utils::requires_login("You need to be logged in order to like a post", uri!(create: blog = blog, slug = slug))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to like a post",
|
||||
uri!(create: blog = blog, slug = slug).into()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -22,5 +22,8 @@ fn notifications(conn: DbConn, user: User) -> Template {
|
|||
|
||||
#[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))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to see your notifications",
|
||||
uri!(notifications).into()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -75,7 +75,10 @@ fn activity_details(blog: String, slug: String, conn: DbConn, _ap: ApRequest) ->
|
|||
|
||||
#[get("/~/<blog>/new", rank = 2)]
|
||||
fn new_auth(blog: String) -> Flash<Redirect> {
|
||||
utils::requires_login("You need to be logged in order to write a new post", uri!(new: blog = blog))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to write a new post",
|
||||
uri!(new: blog = blog).into()
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/~/<blog>/new", rank = 1)]
|
||||
|
|
|
@ -40,5 +40,8 @@ fn create(blog: String, slug: String, user: User, conn: DbConn, worker: State<Po
|
|||
|
||||
#[post("/~/<blog>/<slug>/reshare", rank=1)]
|
||||
fn create_auth(blog: String, slug: String) -> Flash<Redirect> {
|
||||
utils::requires_login("You need to be logged in order to reshare a post", uri!(create: blog = blog, slug = slug))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to reshare a post",
|
||||
uri!(create: blog = blog, slug = slug).into()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use rocket::{
|
|||
request::{LenientForm,FlashMessage}
|
||||
};
|
||||
use rocket_contrib::Template;
|
||||
use rocket::http::ext::IntoOwned;
|
||||
use std::borrow::Cow;
|
||||
use validator::{Validate, ValidationError, ValidationErrors};
|
||||
|
||||
|
@ -72,10 +73,26 @@ fn create(conn: DbConn, data: LenientForm<LoginForm>, flash: Option<FlashMessage
|
|||
|
||||
if errors.is_empty() {
|
||||
cookies.add_private(Cookie::new(AUTH_COOKIE, user.unwrap().id.to_string()));
|
||||
Ok(Redirect::to(Uri::new(flash
|
||||
.and_then(|f| if f.name() == "callback" { Some(f.msg().to_owned()) } else { None })
|
||||
.unwrap_or("/".to_owned()))
|
||||
))
|
||||
|
||||
let destination = flash
|
||||
.and_then(|f| if f.name() == "callback" {
|
||||
Some(f.msg().to_owned())
|
||||
} else {
|
||||
None
|
||||
})
|
||||
.unwrap_or("/".to_owned());
|
||||
|
||||
let uri = Uri::parse(&destination)
|
||||
.map(|x| x.into_owned())
|
||||
.map_err(|_| {
|
||||
Template::render("session/login", json!({
|
||||
"account": null,
|
||||
"errors": errors.inner(),
|
||||
"form": form
|
||||
}))
|
||||
})?;
|
||||
|
||||
Ok(Redirect::to(uri))
|
||||
} else {
|
||||
println!("{:?}", errors);
|
||||
Err(Template::render("session/login", json!({
|
||||
|
|
|
@ -36,7 +36,7 @@ use Worker;
|
|||
fn me(user: Option<User>) -> Result<Redirect, Flash<Redirect>> {
|
||||
match user {
|
||||
Some(user) => Ok(Redirect::to(uri!(details: name = user.username))),
|
||||
None => Err(utils::requires_login("", uri!(me)))
|
||||
None => Err(utils::requires_login("", uri!(me).into()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,10 @@ fn dashboard(user: User, conn: DbConn) -> Template {
|
|||
|
||||
#[get("/dashboard", rank = 2)]
|
||||
fn dashboard_auth() -> Flash<Redirect> {
|
||||
utils::requires_login("You need to be logged in order to access your dashboard", uri!(dashboard))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to access your dashboard",
|
||||
uri!(dashboard).into()
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/@/<name>/follow")]
|
||||
|
@ -136,7 +139,10 @@ fn follow(name: String, conn: DbConn, user: User, worker: Worker) -> Redirect {
|
|||
|
||||
#[get("/@/<name>/follow", rank = 2)]
|
||||
fn follow_auth(name: String) -> Flash<Redirect> {
|
||||
utils::requires_login("You need to be logged in order to follow someone", uri!(follow: name = name))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to follow someone",
|
||||
uri!(follow: name = name).into()
|
||||
)
|
||||
}
|
||||
|
||||
#[get("/@/<name>/followers?<page>")]
|
||||
|
@ -195,7 +201,10 @@ fn edit(name: String, user: User, conn: DbConn) -> Option<Template> {
|
|||
|
||||
#[get("/@/<name>/edit", rank = 2)]
|
||||
fn edit_auth(name: String) -> Flash<Redirect> {
|
||||
utils::requires_login("You need to be logged in order to edit your profile", uri!(edit: name = name))
|
||||
utils::requires_login(
|
||||
"You need to be logged in order to edit your profile",
|
||||
uri!(edit: name = name).into()
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(FromForm)]
|
||||
|
@ -276,8 +285,8 @@ fn inbox(name: String, conn: DbConn, data: String) -> String {
|
|||
match user.received(&*conn, act) {
|
||||
Ok(_) => String::new(),
|
||||
Err(e) => {
|
||||
println!("User inbox error: {}\n{}", e.cause(), e.backtrace());
|
||||
format!("Error: {}", e.cause())
|
||||
println!("User inbox error: {}\n{}", e.as_fail(), e.backtrace());
|
||||
format!("Error: {}", e.as_fail())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ fn quick_setup(conn: DbConn) {
|
|||
.output()
|
||||
.map(|o| String::from_utf8(o.stdout).expect("Invalid output from openssl"))
|
||||
.expect("Couldn't generate secret key.");
|
||||
write_to_dotenv("ROCKET_SECRET_KEY", key);
|
||||
write_to_dotenv("ROCKET_SECRET_KEY", key);
|
||||
|
||||
create_admin(instance, conn);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue