mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-02 13:39:21 +00:00
462c4a2954
* A first attempt at using deser-hjson. Fixes #1270 * Trying to fix tests, try 1 * Trying to fix tests, try 2 * A few fixes to deser_hjson - Removing unwrap_or_defaults, using impl functions. - Reorganized settings * Make clippy happy * hjson list strings must be quoted. * Adding support for env vars. * Moving to structs and defaults file. * Moving settings default and struct.
25 lines
616 B
Rust
25 lines
616 B
Rust
use lemmy_utils::settings::structs::Settings;
|
|
use url::{ParseError, Url};
|
|
use uuid::Uuid;
|
|
|
|
pub(crate) mod comment;
|
|
pub(crate) mod community;
|
|
pub(crate) mod post;
|
|
pub(crate) mod private_message;
|
|
pub(crate) mod user;
|
|
|
|
/// Generate a unique ID for an activity, in the format:
|
|
/// `http(s)://example.com/receive/create/202daf0a-1489-45df-8d2e-c8a3173fed36`
|
|
fn generate_activity_id<T>(kind: T) -> Result<Url, ParseError>
|
|
where
|
|
T: ToString,
|
|
{
|
|
let id = format!(
|
|
"{}/activities/{}/{}",
|
|
Settings::get().get_protocol_and_hostname(),
|
|
kind.to_string().to_lowercase(),
|
|
Uuid::new_v4()
|
|
);
|
|
Url::parse(&id)
|
|
}
|