From 28440271bb752b38a29dbd0fdeecec49ff1ead6c Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 2 May 2022 19:24:36 +0900 Subject: [PATCH] Rename: FromId::from_id07 -> from_id --- plume-common/src/activity_pub/inbox.rs | 6 +++--- plume-models/src/blogs.rs | 6 +++--- plume-models/src/comments.rs | 4 ++-- plume-models/src/follows.rs | 4 ++-- plume-models/src/likes.rs | 4 ++-- plume-models/src/medias.rs | 4 ++-- plume-models/src/posts.rs | 6 +++--- plume-models/src/remote_fetch_actor.rs | 2 +- plume-models/src/reshares.rs | 4 ++-- plume-models/src/users.rs | 2 +- src/inbox.rs | 2 +- src/routes/instance.rs | 4 ++-- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/plume-common/src/activity_pub/inbox.rs b/plume-common/src/activity_pub/inbox.rs index 4751588f..1bc886c3 100644 --- a/plume-common/src/activity_pub/inbox.rs +++ b/plume-common/src/activity_pub/inbox.rs @@ -223,7 +223,7 @@ where } // Transform this actor to a model (see FromId for details about the from_id function) - let actor = match A::from_id07( + let actor = match A::from_id( ctx, &actor_id, serde_json::from_value(act["actor"].clone()).ok(), @@ -244,7 +244,7 @@ where Some(x) => x, None => return Self::NotHandled(ctx, act, InboxError::InvalidObject(None)), }; - let obj = match M::from_id07( + let obj = match M::from_id( ctx, &obj_id, serde_json::from_value(act["object"].clone()).ok(), @@ -343,7 +343,7 @@ pub trait FromId: Sized { /// - `id`: the ActivityPub ID of the object to find /// - `object`: optional object that will be used if the object was not found in the database /// If absent, the ID will be dereferenced. - fn from_id07( + fn from_id( ctx: &C, id: &str, object: Option, diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index a48e9fbf..17f0eadb 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -160,7 +160,7 @@ impl Blog { .find(|l| l.mime_type == Some(String::from("application/activity+json"))) .ok_or(Error::Webfinger) .and_then(|l| { - Blog::from_id07( + Blog::from_id( conn, &l.href.ok_or(Error::MissingApProperty)?, None, @@ -526,7 +526,7 @@ impl FromId for Blog { Media::save_remote( conn, icon.url()?.to_as_uri()?, - &User::from_id07(conn, &owner, None, CONFIG.proxy()).ok()?, + &User::from_id(conn, &owner, None, CONFIG.proxy()).ok()?, ) .ok() }) @@ -543,7 +543,7 @@ impl FromId for Blog { Media::save_remote( conn, banner.url()?.to_as_uri()?, - &User::from_id07(conn, &owner, None, CONFIG.proxy()).ok()?, + &User::from_id(conn, &owner, None, CONFIG.proxy()).ok()?, ) .ok() }) diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index e37273c4..d4a9bd61 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -349,7 +349,7 @@ impl FromId for Comment { post_id: previous_comment.map(|c| c.post_id).or_else(|_| { Ok(Post::find_by_ap_url(conn, previous_url.as_str())?.id) as Result })?, - author_id: User::from_id07( + author_id: User::from_id( conn, ¬e .attributed_to() @@ -402,7 +402,7 @@ impl FromId for Comment { let receivers_ap_url = receiver_ids .into_iter() .flat_map(|v| { - if let Ok(user) = User::from_id07(conn, v.as_ref(), None, CONFIG.proxy()) { + if let Ok(user) = User::from_id(conn, v.as_ref(), None, CONFIG.proxy()) { vec![user] } else { vec![] // TODO try to fetch collection diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index 6876328a..9bc2d93f 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -265,7 +265,7 @@ impl FromId for Follow { } fn from_activity07(conn: &DbConn, follow: FollowAct07) -> Result { - let actor = User::from_id07( + let actor = User::from_id( conn, follow .actor_field_ref() @@ -277,7 +277,7 @@ impl FromId for Follow { ) .map_err(|(_, e)| e)?; - let target = User::from_id07( + let target = User::from_id( conn, follow .object_field_ref() diff --git a/plume-models/src/likes.rs b/plume-models/src/likes.rs index 59a0d6bf..0be2164b 100644 --- a/plume-models/src/likes.rs +++ b/plume-models/src/likes.rs @@ -150,7 +150,7 @@ impl FromId for Like { let res = Like::insert( conn, NewLike { - post_id: Post::from_id07( + post_id: Post::from_id( conn, act.object_field_ref() .as_single_id() @@ -161,7 +161,7 @@ impl FromId for Like { ) .map_err(|(_, e)| e)? .id, - user_id: User::from_id07( + user_id: User::from_id( conn, act.actor_field_ref() .as_single_id() diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index 2837a69f..6796170c 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -275,7 +275,7 @@ impl Media { remote_url: None, sensitive: image.object_props.summary_string().is_ok(), content_warning: image.object_props.summary_string().ok(), - owner_id: User::from_id07( + owner_id: User::from_id( conn, image .object_props @@ -362,7 +362,7 @@ impl Media { remote_url: None, sensitive: summary.is_some(), content_warning: summary, - owner_id: User::from_id07( + owner_id: User::from_id( conn, &image .attributed_to() diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 267fa925..7a58c328 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -883,14 +883,14 @@ impl FromId for Post { .iter() .fold((None, vec![]), |(blog, mut authors), link| { if let Some(url) = link.id() { - match User::from_id07(conn, url.as_str(), None, CONFIG.proxy()) { + match User::from_id(conn, url.as_str(), None, CONFIG.proxy()) { Ok(u) => { authors.push(u); (blog, authors) } Err(_) => ( blog.or_else(|| { - Blog::from_id07(conn, url.as_str(), None, CONFIG.proxy()).ok() + Blog::from_id(conn, url.as_str(), None, CONFIG.proxy()).ok() }), authors, ), @@ -1155,7 +1155,7 @@ impl AsObject for PostUpdate { fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> { let mut post = - Post::from_id07(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?; + Post::from_id(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?; if !post.is_author(conn, actor.id)? { // TODO: maybe the author was added in the meantime diff --git a/plume-models/src/remote_fetch_actor.rs b/plume-models/src/remote_fetch_actor.rs index b91be1bf..83d87b85 100644 --- a/plume-models/src/remote_fetch_actor.rs +++ b/plume-models/src/remote_fetch_actor.rs @@ -99,7 +99,7 @@ fn fetch_and_cache_followers(user: &Arc, conn: &DbConn) { match follower_ids { Ok(user_ids) => { for user_id in user_ids { - let follower = User::from_id07(conn, &user_id, None, CONFIG.proxy()); + let follower = User::from_id(conn, &user_id, None, CONFIG.proxy()); match follower { Ok(follower) => { let inserted = follows::Follow::insert( diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index 1e023cd4..05973f89 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -177,7 +177,7 @@ impl FromId for Reshare { let res = Reshare::insert( conn, NewReshare { - post_id: Post::from_id07( + post_id: Post::from_id( conn, act.object_field_ref() .as_single_id() @@ -188,7 +188,7 @@ impl FromId for Reshare { ) .map_err(|(_, e)| e)? .id, - user_id: User::from_id07( + user_id: User::from_id( conn, act.actor_field_ref() .as_single_id() diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index e224b553..69eb1dd0 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -237,7 +237,7 @@ impl User { .into_iter() .find(|l| l.mime_type == Some(String::from("application/activity+json"))) .ok_or(Error::Webfinger)?; - User::from_id07( + User::from_id( conn, link.href.as_ref().ok_or(Error::Webfinger)?, None, diff --git a/src/inbox.rs b/src/inbox.rs index d9498db8..78069b69 100644 --- a/src/inbox.rs +++ b/src/inbox.rs @@ -26,7 +26,7 @@ pub fn handle_incoming( .or_else(|| activity["actor"]["id"].as_str()) .ok_or(status::BadRequest(Some("Missing actor id for activity")))?; - let actor = User::from_id07(&conn, actor_id, None, CONFIG.proxy()) + let actor = User::from_id(&conn, actor_id, None, CONFIG.proxy()) .expect("instance::shared_inbox: user error"); if !verify_http_headers(&actor, &headers.0, &sig).is_secure() && !act.clone().verify(&actor) { // maybe we just know an old key? diff --git a/src/routes/instance.rs b/src/routes/instance.rs index 5c980ea9..cedaa900 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -404,7 +404,7 @@ pub fn interact(conn: DbConn, user: Option, target: String) -> Option, target: String) -> Option