From 41ccacc5d39c1385fbba427a74536ae0428f7a99 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Mon, 2 May 2022 23:47:36 +0900 Subject: [PATCH] Remove unused Mention::from_activity() --- plume-models/src/mentions.rs | 56 ++++-------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/plume-models/src/mentions.rs b/plume-models/src/mentions.rs index 691b92d5..0e9a8ba0 100644 --- a/plume-models/src/mentions.rs +++ b/plume-models/src/mentions.rs @@ -2,11 +2,10 @@ use crate::{ comments::Comment, db_conn::DbConn, notifications::*, posts::Post, schema::mentions, users::User, Connection, Error, Result, }; -use activitypub::link; use activitystreams::{ base::BaseExt, iri_string::types::IriString, - link::{self as link07, LinkExt}, + link::{self, LinkExt}, }; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use plume_common::activity_pub::inbox::AsActor; @@ -61,68 +60,25 @@ impl Mention { } } - pub fn build_activity07(conn: &DbConn, ment: &str) -> Result { + pub fn build_activity07(conn: &DbConn, ment: &str) -> Result { let user = User::find_by_fqn(conn, ment)?; - let mut mention = link07::Mention::new(); + let mut mention = link::Mention::new(); mention.set_href(user.ap_url.parse::()?); mention.set_name(format!("@{}", ment)); Ok(mention) } - pub fn to_activity07(&self, conn: &Connection) -> Result { + pub fn to_activity07(&self, conn: &Connection) -> Result { let user = self.get_mentioned(conn)?; - let mut mention = link07::Mention::new(); + let mut mention = link::Mention::new(); mention.set_href(user.ap_url.parse::()?); mention.set_name(format!("@{}", user.fqn)); Ok(mention) } - pub fn from_activity( - conn: &Connection, - ment: &link::Mention, - inside: i32, - in_post: bool, - notify: bool, - ) -> Result { - let ap_url = ment.link_props.href_string().or(Err(Error::NotFound))?; - let mentioned = User::find_by_ap_url(conn, &ap_url)?; - - if in_post { - Post::get(conn, inside).and_then(|post| { - let res = Mention::insert( - conn, - NewMention { - mentioned_id: mentioned.id, - post_id: Some(post.id), - comment_id: None, - }, - )?; - if notify { - res.notify(conn)?; - } - Ok(res) - }) - } else { - Comment::get(conn, inside).and_then(|comment| { - let res = Mention::insert( - conn, - NewMention { - mentioned_id: mentioned.id, - post_id: None, - comment_id: Some(comment.id), - }, - )?; - if notify { - res.notify(conn)?; - } - Ok(res) - }) - } - } - pub fn from_activity07( conn: &Connection, - ment: &link07::Mention, + ment: &link::Mention, inside: i32, in_post: bool, notify: bool,