Use Mention::build_activity07() instead of build_activity()

This commit is contained in:
Kitaiti Makoto 2022-05-02 23:43:24 +09:00
parent 01dca62ce5
commit 5d08ff6c3b
4 changed files with 7 additions and 35 deletions

View file

@ -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> {
let user = User::find_by_fqn(conn, ment)?;
let mut mention = link07::Mention::new();
@ -218,27 +210,6 @@ mod tests {
use diesel::Connection;
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]
fn build_activity07() {
let conn = db();

View file

@ -191,9 +191,9 @@ pub fn create(
if post.published {
for m in mentions.into_iter() {
Mention::from_activity(
Mention::from_activity07(
&conn,
&Mention::build_activity(&conn, &m)?,
&Mention::build_activity07(&conn, &m)?,
post.id,
true,
true,

View file

@ -71,9 +71,9 @@ pub fn create(
// save mentions
for ment in mentions {
Mention::from_activity(
Mention::from_activity07(
&conn,
&Mention::build_activity(&conn, &ment)
&Mention::build_activity07(&conn, &ment)
.expect("comments::create: build mention error"),
comm.id,
false,

View file

@ -530,9 +530,10 @@ pub fn create(
if post.published {
for m in mentions {
Mention::from_activity(
Mention::from_activity07(
&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,
true,
true,