Use a more classical flow for creating comments

Don't locally federate them anymore

It allows us to have them fetched later too
This commit is contained in:
Bat
2018-09-09 16:08:53 +01:00
parent 642884034d
commit 54f6e7dfc6
4 changed files with 75 additions and 97 deletions
-14
View File
@@ -21,7 +21,6 @@ extern crate serde_json;
extern crate url;
extern crate webfinger;
use diesel::{PgConnection, RunQueryDsl, select};
use std::env;
macro_rules! find_by {
@@ -84,19 +83,6 @@ macro_rules! update {
};
}
sql_function!(nextval, nextval_t, (seq: ::diesel::sql_types::Text) -> ::diesel::sql_types::BigInt);
sql_function!(setval, setval_t, (seq: ::diesel::sql_types::Text, val: ::diesel::sql_types::BigInt) -> ::diesel::sql_types::BigInt);
fn get_next_id(conn: &PgConnection, seq: &str) -> i32 {
// We cant' use currval because it may fail if nextval have never been called before
let next = select(nextval(seq)).get_result::<i64>(conn).expect("Next ID fail");
if next > 1 {
select(setval(seq, next - 1)).get_result::<i64>(conn).expect("Reset ID fail");
}
next as i32
}
lazy_static! {
pub static ref BASE_URL: String = env::var("BASE_URL")
.unwrap_or(format!("127.0.0.1:{}", env::var("ROCKET_PORT").unwrap_or(String::from("8000"))));