Use Mention::build_activity07() instead of build_activity()
This commit is contained in:
parent
01dca62ce5
commit
5d08ff6c3b
@ -61,14 +61,6 @@ 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))?;
|
|
||||||
Ok(mention)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build_activity07(conn: &DbConn, ment: &str) -> Result<link07::Mention> {
|
pub fn build_activity07(conn: &DbConn, ment: &str) -> Result<link07::Mention> {
|
||||||
let user = User::find_by_fqn(conn, ment)?;
|
let user = User::find_by_fqn(conn, ment)?;
|
||||||
let mut mention = link07::Mention::new();
|
let mut mention = link07::Mention::new();
|
||||||
@ -218,27 +210,6 @@ mod tests {
|
|||||||
use diesel::Connection;
|
use diesel::Connection;
|
||||||
use serde_json::{json, to_value};
|
use serde_json::{json, to_value};
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn build_activity() {
|
|
||||||
let conn = db();
|
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
|
||||||
let (_posts, users, _blogs) = fill_database(&conn);
|
|
||||||
let user = &users[0];
|
|
||||||
let name = &user.username;
|
|
||||||
let act = Mention::build_activity(&conn, name)?;
|
|
||||||
|
|
||||||
let expected = json!({
|
|
||||||
"href": "https://plu.me/@/admin/",
|
|
||||||
"name": "@admin",
|
|
||||||
"type": "Mention",
|
|
||||||
});
|
|
||||||
|
|
||||||
assert_json_eq!(to_value(act)?, expected);
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_activity07() {
|
fn build_activity07() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
|
@ -191,9 +191,9 @@ pub fn create(
|
|||||||
|
|
||||||
if post.published {
|
if post.published {
|
||||||
for m in mentions.into_iter() {
|
for m in mentions.into_iter() {
|
||||||
Mention::from_activity(
|
Mention::from_activity07(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity(&conn, &m)?,
|
&Mention::build_activity07(&conn, &m)?,
|
||||||
post.id,
|
post.id,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
@ -71,9 +71,9 @@ pub fn create(
|
|||||||
|
|
||||||
// save mentions
|
// save mentions
|
||||||
for ment in mentions {
|
for ment in mentions {
|
||||||
Mention::from_activity(
|
Mention::from_activity07(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity(&conn, &ment)
|
&Mention::build_activity07(&conn, &ment)
|
||||||
.expect("comments::create: build mention error"),
|
.expect("comments::create: build mention error"),
|
||||||
comm.id,
|
comm.id,
|
||||||
false,
|
false,
|
||||||
|
@ -530,9 +530,10 @@ pub fn create(
|
|||||||
|
|
||||||
if post.published {
|
if post.published {
|
||||||
for m in mentions {
|
for m in mentions {
|
||||||
Mention::from_activity(
|
Mention::from_activity07(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity(&conn, &m).expect("post::create: mention build error"),
|
&Mention::build_activity07(&conn, &m)
|
||||||
|
.expect("post::create: mention build error"),
|
||||||
post.id,
|
post.id,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
|
Loading…
Reference in New Issue
Block a user