Use USE_HTTPS to compute AP URLs
Instead of relying on cfg(debug_assertions)
This commit is contained in:
parent
f805ec1d53
commit
507d3e6183
@ -17,16 +17,6 @@ pub mod sign;
|
||||
pub const CONTEXT_URL: &'static str = "https://www.w3.org/ns/activitystreams";
|
||||
pub const PUBLIC_VISIBILTY: &'static str = "https://www.w3.org/ns/activitystreams#Public";
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
pub fn ap_url(url: String) -> String {
|
||||
format!("http://{}", url)
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
pub fn ap_url(url: String) -> String {
|
||||
format!("https://{}", url)
|
||||
}
|
||||
|
||||
pub fn context() -> serde_json::Value {
|
||||
json!([
|
||||
CONTEXT_URL,
|
||||
|
@ -8,11 +8,11 @@ use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, dsl::
|
||||
use serde_json;
|
||||
|
||||
use plume_common::activity_pub::{
|
||||
ap_url, Id, IntoId, PUBLIC_VISIBILTY,
|
||||
Id, IntoId, PUBLIC_VISIBILTY,
|
||||
inbox::{FromActivity, Notify}
|
||||
};
|
||||
use plume_common::utils;
|
||||
use get_next_id;
|
||||
use {get_next_id, ap_url};
|
||||
use instance::Instance;
|
||||
use mentions::Mention;
|
||||
use notifications::*;
|
||||
|
@ -2,7 +2,7 @@ use chrono::NaiveDateTime;
|
||||
use diesel::{self, QueryDsl, RunQueryDsl, ExpressionMethods, PgConnection};
|
||||
use std::iter::Iterator;
|
||||
|
||||
use plume_common::activity_pub::ap_url;
|
||||
use ap_url;
|
||||
use users::User;
|
||||
use schema::{instances, users};
|
||||
|
||||
|
@ -92,6 +92,15 @@ lazy_static! {
|
||||
pub static ref USE_HTTPS: bool = env::var("USE_HTTPS").map(|val| val == "1").unwrap_or(true);
|
||||
}
|
||||
|
||||
pub fn ap_url(url: &str) -> String {
|
||||
let scheme = if *USE_HTTPS {
|
||||
"https"
|
||||
} else {
|
||||
"http"
|
||||
};
|
||||
format!("{}://{}", scheme, url)
|
||||
}
|
||||
|
||||
pub mod blog_authors;
|
||||
pub mod blogs;
|
||||
pub mod comments;
|
||||
|
@ -8,11 +8,11 @@ use diesel::{self, PgConnection, RunQueryDsl, QueryDsl, ExpressionMethods, Belon
|
||||
use heck::KebabCase;
|
||||
use serde_json;
|
||||
|
||||
use BASE_URL;
|
||||
use plume_common::activity_pub::{
|
||||
PUBLIC_VISIBILTY, ap_url, Id, IntoId,
|
||||
PUBLIC_VISIBILTY, Id, IntoId,
|
||||
inbox::FromActivity
|
||||
};
|
||||
use {BASE_URL, ap_url};
|
||||
use blogs::Blog;
|
||||
use instance::Instance;
|
||||
use likes::Like;
|
||||
|
@ -13,7 +13,7 @@ use openssl::{
|
||||
sign
|
||||
};
|
||||
use plume_common::activity_pub::{
|
||||
ap_url, ActivityStream, Id, IntoId, ApSignature, PublicKey,
|
||||
ActivityStream, Id, IntoId, ApSignature, PublicKey,
|
||||
inbox::WithInbox,
|
||||
sign::{Signer, gen_keypair}
|
||||
};
|
||||
@ -30,7 +30,7 @@ use serde_json;
|
||||
use url::Url;
|
||||
use webfinger::*;
|
||||
|
||||
use {BASE_URL, USE_HTTPS};
|
||||
use {BASE_URL, USE_HTTPS, ap_url};
|
||||
use db_conn::DbConn;
|
||||
use blogs::Blog;
|
||||
use blog_authors::BlogAuthor;
|
||||
|
Loading…
Reference in New Issue
Block a user