Rename: FromId::from_id07 -> from_id

This commit is contained in:
Kitaiti Makoto
2022-05-02 19:24:36 +09:00
parent 0ab7774e29
commit 28440271bb
12 changed files with 24 additions and 24 deletions
+3 -3
View File
@@ -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<DbConn> 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<DbConn> 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()
})
+2 -2
View File
@@ -349,7 +349,7 @@ impl FromId<DbConn> 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<i32>
})?,
author_id: User::from_id07(
author_id: User::from_id(
conn,
&note
.attributed_to()
@@ -402,7 +402,7 @@ impl FromId<DbConn> 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
+2 -2
View File
@@ -265,7 +265,7 @@ impl FromId<DbConn> for Follow {
}
fn from_activity07(conn: &DbConn, follow: FollowAct07) -> Result<Self> {
let actor = User::from_id07(
let actor = User::from_id(
conn,
follow
.actor_field_ref()
@@ -277,7 +277,7 @@ impl FromId<DbConn> for Follow {
)
.map_err(|(_, e)| e)?;
let target = User::from_id07(
let target = User::from_id(
conn,
follow
.object_field_ref()
+2 -2
View File
@@ -150,7 +150,7 @@ impl FromId<DbConn> 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<DbConn> 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()
+2 -2
View File
@@ -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()
+3 -3
View File
@@ -883,14 +883,14 @@ impl FromId<DbConn> 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<User, Update07, &DbConn> 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
+1 -1
View File
@@ -99,7 +99,7 @@ fn fetch_and_cache_followers(user: &Arc<User>, 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(
+2 -2
View File
@@ -177,7 +177,7 @@ impl FromId<DbConn> 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<DbConn> 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()
+1 -1
View File
@@ -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,