Remove trailing 07 from Hashtag
This commit is contained in:
@@ -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)?;
|
||||
|
||||
Reference in New Issue
Block a user