mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2024-11-22 19:41:03 +00:00
Remove trailing 07 from Hashtag
This commit is contained in:
parent
2fe2505a01
commit
f8870af9fe
3 changed files with 27 additions and 27 deletions
|
@ -372,10 +372,10 @@ where
|
|||
pub type CustomPerson = Ext1<ApActor<Person>, ApSignature07>;
|
||||
pub type CustomGroup = Ext2<ApActor<Group>, 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<IriString>,
|
||||
|
||||
|
@ -383,10 +383,10 @@ pub struct Hashtag07 {
|
|||
pub name: Option<AnyString>,
|
||||
|
||||
#[serde(flatten)]
|
||||
inner: Object07<HashtagType07>,
|
||||
inner: Object07<HashtagType>,
|
||||
}
|
||||
|
||||
impl Hashtag07 {
|
||||
impl Hashtag {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
href: None,
|
||||
|
@ -395,14 +395,14 @@ impl Hashtag07 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn extending(mut inner: Object07<HashtagType07>) -> Result<Self, serde_json::Error> {
|
||||
pub fn extending(mut inner: Object07<HashtagType>) -> Result<Self, serde_json::Error> {
|
||||
let href = inner.remove("href")?;
|
||||
let name = inner.remove("name")?;
|
||||
|
||||
Ok(Self { href, name, inner })
|
||||
}
|
||||
|
||||
pub fn retracting(self) -> Result<Object07<HashtagType07>, serde_json::Error> {
|
||||
pub fn retracting(self) -> Result<Object07<HashtagType>, 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<HashtagType07> for Hashtag07 {
|
||||
impl Extends<HashtagType> for Hashtag {
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn extends(base: Base<HashtagType07>) -> Result<Self, Self::Error> {
|
||||
fn extends(base: Base<HashtagType>) -> Result<Self, Self::Error> {
|
||||
let inner = Object07::extends(base)?;
|
||||
Self::extending(inner)
|
||||
}
|
||||
|
||||
fn retracts(self) -> Result<Base<HashtagType07>, Self::Error> {
|
||||
fn retracts(self) -> Result<Base<HashtagType>, 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<T> HashtagExt for T where T: AsHashtag {}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
|
|
|
@ -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<Hashtag07>) -> Result<()> {
|
||||
pub fn update_tags07(&self, conn: &Connection, tags: Vec<Hashtag>) -> 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<Hashtag07>) -> Result<()> {
|
||||
pub fn update_hashtags07(&self, conn: &Connection, tags: Vec<Hashtag>) -> 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<DbConn> for Post {
|
|||
.ok();
|
||||
|
||||
tag.clone()
|
||||
.extend::<Hashtag07, HashtagType07>() // FIXME: Don't clone
|
||||
.extend::<Hashtag, HashtagType>() // 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<User, Update07, &DbConn> for PostUpdate {
|
|||
.map(|m| mentions.push(m))
|
||||
.ok();
|
||||
|
||||
serde_json::from_value::<Hashtag07>(tag.clone())
|
||||
serde_json::from_value::<Hashtag>(tag.clone())
|
||||
.map_err(Error::from)
|
||||
.and_then(|t| {
|
||||
let tag_name = t.name.as_ref().ok_or(Error::MissingApProperty)?;
|
||||
|
|
|
@ -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<Hashtag07> {
|
||||
let mut ht = Hashtag07::new();
|
||||
pub fn to_activity07(&self) -> Result<Hashtag> {
|
||||
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<Tag> {
|
||||
|
@ -55,8 +55,8 @@ impl Tag {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn build_activity07(tag: String) -> Result<Hashtag07> {
|
||||
let mut ht = Hashtag07::new();
|
||||
pub fn build_activity07(tag: String) -> Result<Hashtag> {
|
||||
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::<IriString>()?);
|
||||
ht.set_name("a_tag".to_string());
|
||||
let tag = Tag::from_activity07(conn, &ht, post_id, true)?;
|
||||
|
|
Loading…
Reference in a new issue