From ba00e368844bb36912cf977234deb526668cf186 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 15 Jan 2023 07:42:16 +0900 Subject: [PATCH] use Fqn::make_local() instead of make_fqn() --- plume-models/src/blogs.rs | 9 ++++----- plume-models/src/search/actor.rs | 4 ++-- src/routes/blogs.rs | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 0c8e2aa8..dd9c8e86 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -25,7 +25,7 @@ use plume_common::{ sign, ActivityStream, ApSignature, CustomGroup, Id, IntoId, PublicKey, Source, SourceProperty, ToAsString, ToAsUri, }, - utils::{iri_percent_encode_seg, make_fqn}, + utils::iri_percent_encode_seg, }; use webfinger::*; @@ -89,11 +89,10 @@ impl Blog { if inserted.fqn.to_string().is_empty() { // This might not enough for some titles such as all-Japanese title, // but better than doing nothing. - let username = make_fqn(&inserted.title); if instance.local { - inserted.fqn = Fqn::new_local(username)?; + inserted.fqn = Fqn::make_local(&inserted.title)?; } else { - inserted.fqn = Fqn::new_remote(username, instance.public_domain)?; + inserted.fqn = Fqn::make_remote(&inserted.title, instance.public_domain)?; } } @@ -555,7 +554,7 @@ impl NewBlog { let (pub_key, priv_key) = sign::gen_keypair(); Ok(NewBlog { actor_id, - fqn: Fqn::new_local(make_fqn(&title))?, + fqn: Fqn::make_local(&title)?, title, summary, instance_id, diff --git a/plume-models/src/search/actor.rs b/plume-models/src/search/actor.rs index 597ef924..266b53eb 100644 --- a/plume-models/src/search/actor.rs +++ b/plume-models/src/search/actor.rs @@ -91,7 +91,7 @@ mod tests { Connection as Conn, CONFIG, }; use diesel::r2d2::ConnectionManager; - use plume_common::utils::{make_fqn, random_hex}; + use plume_common::utils::random_hex; use std::str::FromStr; use std::sync::Arc; use std::thread::sleep; @@ -198,7 +198,7 @@ mod tests { ap_url: random_hex(), inbox_url: random_hex(), outbox_url: random_hex(), - fqn: Fqn::new_local(make_fqn(&title)).unwrap(), + fqn: Fqn::make_local(&title).unwrap(), title, summary: Default::default(), summary_html: Default::default(), diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index c7c3e588..288bcf54 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -387,7 +387,7 @@ mod tests { use super::valid_slug; use crate::init_rocket; use diesel::Connection; - use plume_common::utils::{make_fqn, random_hex}; + use plume_common::utils::random_hex; use plume_models::{ blog_authors::{BlogAuthor, NewBlogAuthor}, blogs::{Blog, NewBlog}, @@ -527,7 +527,7 @@ mod tests { let title = random_hex(); let blog = NewBlog { instance_id: instance.id, - fqn: Fqn::new_local(make_fqn(&title)).unwrap(), + fqn: Fqn::make_local(&title).unwrap(), title, actor_id: random_hex(), ap_url: random_hex(),