diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 755d4e17..bdfa26ef 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -372,10 +372,10 @@ where pub type CustomPerson = Ext1, ApSignature07>; pub type CustomGroup = Ext2, ApSignature07, SourceProperty>; -kind!(HashtagType07, Hashtag); +kind!(HashtagType, Hashtag); #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] -pub struct Hashtag07 { +pub struct Hashtag { #[serde(skip_serializing_if = "Option::is_none")] pub href: Option, @@ -383,10 +383,10 @@ pub struct Hashtag07 { pub name: Option, #[serde(flatten)] - inner: Object07, + inner: Object07, } -impl Hashtag07 { +impl Hashtag { pub fn new() -> Self { Self { href: None, @@ -395,14 +395,14 @@ impl Hashtag07 { } } - pub fn extending(mut inner: Object07) -> Result { + pub fn extending(mut inner: Object07) -> Result { let href = inner.remove("href")?; let name = inner.remove("name")?; Ok(Self { href, name, inner }) } - pub fn retracting(self) -> Result, serde_json::Error> { + pub fn retracting(self) -> Result, serde_json::Error> { let Self { href, name, @@ -416,9 +416,9 @@ impl Hashtag07 { } pub trait AsHashtag: markers::Object { - fn hashtag_ref(&self) -> &Hashtag07; + fn hashtag_ref(&self) -> &Hashtag; - fn hashtag_mut(&mut self) -> &mut Hashtag07; + fn hashtag_mut(&mut self) -> &mut Hashtag; } pub trait HashtagExt: AsHashtag { @@ -465,13 +465,13 @@ pub trait HashtagExt: AsHashtag { } } -impl Default for Hashtag07 { +impl Default for Hashtag { fn default() -> Self { Self::new() } } -impl AsHashtag for Hashtag07 { +impl AsHashtag for Hashtag { fn hashtag_ref(&self) -> &Self { self } @@ -481,22 +481,22 @@ impl AsHashtag for Hashtag07 { } } -impl Extends for Hashtag07 { +impl Extends for Hashtag { type Error = serde_json::Error; - fn extends(base: Base) -> Result { + fn extends(base: Base) -> Result { let inner = Object07::extends(base)?; Self::extending(inner) } - fn retracts(self) -> Result, Self::Error> { + fn retracts(self) -> Result, Self::Error> { let inner = self.retracting()?; inner.retracts() } } -impl markers::Base for Hashtag07 {} -impl markers::Object for Hashtag07 {} +impl markers::Base for Hashtag {} +impl markers::Object for Hashtag {} impl HashtagExt for T where T: AsHashtag {} #[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)] diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index 2977a661..c6206e65 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -23,7 +23,7 @@ use plume_common::{ activity_pub::{ inbox::{AsActor, AsObject, FromId}, sign::Signer, - Hashtag07, HashtagType07, Id, IntoId, Licensed, Licensed07, + Hashtag, HashtagType, Id, IntoId, Licensed, Licensed07, LicensedArticle as LicensedArticle07, Source, SourceProperty, ToAsString, ToAsUri, PUBLIC_VISIBILITY, }, @@ -494,7 +494,7 @@ impl Post { Ok(()) } - pub fn update_tags07(&self, conn: &Connection, tags: Vec) -> Result<()> { + pub fn update_tags07(&self, conn: &Connection, tags: Vec) -> Result<()> { let tags_name = tags .iter() .filter_map(|t| t.name.as_ref().map(|name| name.as_str().to_string())) @@ -531,7 +531,7 @@ impl Post { Ok(()) } - pub fn update_hashtags07(&self, conn: &Connection, tags: Vec) -> Result<()> { + pub fn update_hashtags07(&self, conn: &Connection, tags: Vec) -> Result<()> { let tags_name = tags .iter() .filter_map(|t| t.name.as_ref().map(|name| name.as_str().to_string())) @@ -797,7 +797,7 @@ impl FromId for Post { .ok(); tag.clone() - .extend::() // FIXME: Don't clone + .extend::() // FIXME: Don't clone .map(|hashtag| { hashtag.and_then(|t| { let tag_name = t.name.clone()?.as_str().to_string(); @@ -962,7 +962,7 @@ impl AsObject for PostUpdate { .map(|m| mentions.push(m)) .ok(); - serde_json::from_value::(tag.clone()) + serde_json::from_value::(tag.clone()) .map_err(Error::from) .and_then(|t| { let tag_name = t.name.as_ref().ok_or(Error::MissingApProperty)?; diff --git a/plume-models/src/tags.rs b/plume-models/src/tags.rs index 2657b184..eb24f0c0 100644 --- a/plume-models/src/tags.rs +++ b/plume-models/src/tags.rs @@ -1,7 +1,7 @@ use crate::{ap_url, instance::Instance, schema::tags, Connection, Error, Result}; use activitystreams::iri_string::types::IriString; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use plume_common::activity_pub::{Hashtag07, HashtagExt}; +use plume_common::activity_pub::{Hashtag, HashtagExt}; #[derive(Clone, Identifiable, Queryable)] pub struct Tag { @@ -25,8 +25,8 @@ impl Tag { find_by!(tags, find_by_name, tag as &str); list_by!(tags, for_post, post_id as i32); - pub fn to_activity07(&self) -> Result { - let mut ht = Hashtag07::new(); + pub fn to_activity07(&self) -> Result { + let mut ht = Hashtag::new(); ht.set_href( ap_url(&format!( "{}/tag/{}", @@ -41,7 +41,7 @@ impl Tag { pub fn from_activity07( conn: &Connection, - tag: &Hashtag07, + tag: &Hashtag, post: i32, is_hashtag: bool, ) -> Result { @@ -55,8 +55,8 @@ impl Tag { ) } - pub fn build_activity07(tag: String) -> Result { - let mut ht = Hashtag07::new(); + pub fn build_activity07(tag: String) -> Result { + let mut ht = Hashtag::new(); ht.set_href( ap_url(&format!( "{}/tag/{}", @@ -91,7 +91,7 @@ mod tests { conn.test_transaction::<_, Error, _>(|| { let (posts, _users, _blogs) = fill_database(conn); let post_id = posts[0].id; - let mut ht = Hashtag07::new(); + let mut ht = Hashtag::new(); ht.set_href(ap_url(&format!("https://plu.me/tag/a_tag")).parse::()?); ht.set_name("a_tag".to_string()); let tag = Tag::from_activity07(conn, &ht, post_id, true)?;