Make Mention follow activitystreams 0.7
This commit is contained in:
parent
f6e8b4de1b
commit
ab199e626b
@ -2,7 +2,7 @@ use crate::{
|
||||
comments::Comment, db_conn::DbConn, notifications::*, posts::Post, schema::mentions,
|
||||
users::User, Connection, Error, Result,
|
||||
};
|
||||
use activitypub::link;
|
||||
use activitystreams::{link, prelude::*};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use plume_common::activity_pub::inbox::AsActor;
|
||||
|
||||
@ -58,19 +58,17 @@ impl Mention {
|
||||
|
||||
pub fn build_activity(conn: &DbConn, ment: &str) -> Result<link::Mention> {
|
||||
let user = User::find_by_fqn(conn, ment)?;
|
||||
let mut mention = link::Mention::default();
|
||||
mention.link_props.set_href_string(user.ap_url)?;
|
||||
mention.link_props.set_name_string(format!("@{}", ment))?;
|
||||
let mut mention = link::Mention::new();
|
||||
mention.set_href(user.ap_url.parse()?);
|
||||
mention.set_name(format!("@{}", ment));
|
||||
Ok(mention)
|
||||
}
|
||||
|
||||
pub fn to_activity(&self, conn: &Connection) -> Result<link::Mention> {
|
||||
let user = self.get_mentioned(conn)?;
|
||||
let mut mention = link::Mention::default();
|
||||
mention.link_props.set_href_string(user.ap_url.clone())?;
|
||||
mention
|
||||
.link_props
|
||||
.set_name_string(format!("@{}", user.fqn))?;
|
||||
let mention = link::Mention::new();
|
||||
mention.set_href(user.ap_url.parse()?);
|
||||
mention.set_name(format!("@{}", user.fqn));
|
||||
Ok(mention)
|
||||
}
|
||||
|
||||
@ -81,7 +79,7 @@ impl Mention {
|
||||
in_post: bool,
|
||||
notify: bool,
|
||||
) -> Result<Self> {
|
||||
let ap_url = ment.link_props.href_string().or(Err(Error::NotFound))?;
|
||||
let ap_url = ment.href().ok_or(Error::NotFound)?.to_string();
|
||||
let mentioned = User::find_by_ap_url(conn, &ap_url)?;
|
||||
|
||||
if in_post {
|
||||
|
Loading…
x
Reference in New Issue
Block a user