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