Use more env vars for config
It will make it easier to test federation
This commit is contained in:
@@ -8,7 +8,6 @@ use schema::{instances, users};
|
||||
#[derive(Identifiable, Queryable)]
|
||||
pub struct Instance {
|
||||
pub id: i32,
|
||||
pub local_domain: String,
|
||||
pub public_domain: String,
|
||||
pub name: String,
|
||||
pub local: bool,
|
||||
@@ -19,7 +18,6 @@ pub struct Instance {
|
||||
#[derive(Insertable)]
|
||||
#[table_name = "instances"]
|
||||
pub struct NewInstance {
|
||||
pub local_domain: String,
|
||||
pub public_domain: String,
|
||||
pub name: String,
|
||||
pub local: bool
|
||||
@@ -44,10 +42,9 @@ impl Instance {
|
||||
Instance::get_local(conn).unwrap().id
|
||||
}
|
||||
|
||||
pub fn insert<'a>(conn: &PgConnection, loc_dom: String, pub_dom: String, name: String, local: bool) -> Instance {
|
||||
pub fn insert<'a>(conn: &PgConnection, pub_dom: String, name: String, local: bool) -> Instance {
|
||||
diesel::insert_into(instances::table)
|
||||
.values(NewInstance {
|
||||
local_domain: loc_dom,
|
||||
public_domain: pub_dom,
|
||||
name: name,
|
||||
local: local
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ use rocket::outcome::IntoOutcome;
|
||||
use serde_json;
|
||||
use url::Url;
|
||||
|
||||
use BASE_URL;
|
||||
use activity_pub::activity::Activity;
|
||||
use activity_pub::actor::{ActorType, Actor};
|
||||
use activity_pub::inbox::Inbox;
|
||||
@@ -138,7 +139,7 @@ impl User {
|
||||
let instance = match Instance::get_by_domain(conn, inst.clone()) {
|
||||
Some(instance) => instance,
|
||||
None => {
|
||||
Instance::insert(conn, String::from(""), inst.clone(), inst.clone(), false)
|
||||
Instance::insert(conn, inst.clone(), inst.clone(), false)
|
||||
}
|
||||
};
|
||||
User::insert(conn, NewUser {
|
||||
@@ -249,7 +250,7 @@ impl Actor for User {
|
||||
None => {
|
||||
// The requested user was not in the DB
|
||||
// We try to fetch it if it is remote
|
||||
if Url::parse(url.as_ref()).unwrap().host_str().unwrap() != Instance::get_local(conn).unwrap().public_domain {
|
||||
if Url::parse(url.as_ref()).unwrap().host_str().unwrap() != BASE_URL.as_str() {
|
||||
Some(User::fetch_from_url(conn, url).unwrap())
|
||||
} else {
|
||||
None
|
||||
|
||||
Reference in New Issue
Block a user