mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2025-05-23 02:38:52 +00:00
fix
This commit is contained in:
parent
bff0567c27
commit
b6e461a51b
2 changed files with 6 additions and 3 deletions
|
@ -19,7 +19,7 @@ pub struct DbPost {
|
|||
|
||||
impl DbPost {
|
||||
pub fn new(text: String, creator: ObjectId<DbUser>) -> Result<DbPost, Error> {
|
||||
let ap_id = generate_object_id(creator.inner().domain())?.try_into()?;
|
||||
let ap_id = generate_object_id(creator.inner().domain())?.into();
|
||||
Ok(DbPost {
|
||||
text,
|
||||
ap_id,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use activitypub_federation::url::Url;
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use url::{ParseError, Url};
|
||||
use url::ParseError;
|
||||
|
||||
/// Just generate random url as object id. In a real project, you probably want to use
|
||||
/// an url which contains the database id for easy retrieval (or store the random id in db).
|
||||
|
@ -9,5 +12,5 @@ pub fn generate_object_id(domain: &str) -> Result<Url, ParseError> {
|
|||
.take(7)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
Url::parse(&format!("http://{}/objects/{}", domain, id))
|
||||
Url::from_str(&format!("http://{}/objects/{}", domain, id))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue