2020-10-12 14:10:09 +00:00
|
|
|
use lemmy_utils::settings::Settings;
|
|
|
|
use url::{ParseError, Url};
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2020-11-16 15:44:04 +00:00
|
|
|
pub(crate) mod comment;
|
|
|
|
pub(crate) mod community;
|
|
|
|
pub(crate) mod post;
|
|
|
|
pub(crate) mod private_message;
|
|
|
|
pub(crate) mod user;
|
2020-10-12 14:10:09 +00:00
|
|
|
|
2020-10-19 14:29:35 +00:00
|
|
|
/// Generate a unique ID for an activity, in the format:
|
|
|
|
/// `http(s)://example.com/receive/create/202daf0a-1489-45df-8d2e-c8a3173fed36`
|
2020-10-12 14:10:09 +00:00
|
|
|
fn generate_activity_id<T>(kind: T) -> Result<Url, ParseError>
|
|
|
|
where
|
|
|
|
T: ToString,
|
|
|
|
{
|
|
|
|
let id = format!(
|
2020-10-23 13:02:45 +00:00
|
|
|
"{}/activities/{}/{}",
|
2020-10-12 14:10:09 +00:00
|
|
|
Settings::get().get_protocol_and_hostname(),
|
|
|
|
kind.to_string().to_lowercase(),
|
|
|
|
Uuid::new_v4()
|
|
|
|
);
|
|
|
|
Url::parse(&id)
|
|
|
|
}
|