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:
@@ -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"))));
|
||||
|
||||
Reference in New Issue
Block a user