Rename: activity07() -> activity()

This commit is contained in:
Kitaiti Makoto 2022-05-03 01:26:15 +09:00
parent 15134eed60
commit df005a28f8
19 changed files with 99 additions and 123 deletions

View file

@ -260,7 +260,7 @@ where
};
// Handle the activity
match obj.activity07(ctx, actor, act_id) {
match obj.activity(ctx, actor, act_id) {
Ok(res) => Self::Handled(res.into()),
Err(e) => Self::Failed(e),
}
@ -540,7 +540,7 @@ where
/// - `ctx`: the context passed to `Inbox::handle`
/// - `actor`: the actor who did this activity
/// - `id`: the ID of this activity
fn activity07(self, ctx: C, actor: A, id: &str) -> Result<Self::Output, Self::Error>;
fn activity(self, ctx: C, actor: A, id: &str) -> Result<Self::Output, Self::Error>;
}
#[cfg(test)]
@ -650,12 +650,7 @@ mod tests {
type Error = ();
type Output = ();
fn activity07(
self,
_: &(),
_actor: MyActor,
_id: &str,
) -> Result<Self::Output, Self::Error> {
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
println!("MyActor is creating a Note");
Ok(())
}
@ -665,12 +660,7 @@ mod tests {
type Error = ();
type Output = ();
fn activity07(
self,
_: &(),
_actor: MyActor,
_id: &str,
) -> Result<Self::Output, Self::Error> {
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
println!("MyActor is liking a Note");
Ok(())
}
@ -680,12 +670,7 @@ mod tests {
type Error = ();
type Output = ();
fn activity07(
self,
_: &(),
_actor: MyActor,
_id: &str,
) -> Result<Self::Output, Self::Error> {
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
println!("MyActor is deleting a Note");
Ok(())
}
@ -695,12 +680,7 @@ mod tests {
type Error = ();
type Output = ();
fn activity07(
self,
_: &(),
_actor: MyActor,
_id: &str,
) -> Result<Self::Output, Self::Error> {
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
println!("MyActor is announcing a Note");
Ok(())
}
@ -802,7 +782,7 @@ mod tests {
type Error = ();
type Output = ();
fn activity07(
fn activity(
self,
_: &(),
_actor: FailingActor,

View file

@ -160,7 +160,7 @@ impl Blog {
})
}
pub fn to_activity07(&self, conn: &Connection) -> Result<CustomGroup> {
pub fn to_activity(&self, conn: &Connection) -> Result<CustomGroup> {
let mut blog = ApActor::new(self.inbox_url.parse()?, Group::new());
blog.set_preferred_username(self.actor_id.clone());
blog.set_name(self.title.clone());
@ -954,7 +954,7 @@ pub(crate) mod tests {
.id,
);
let _: Blog = blogs[0].save_changes(&**conn).unwrap();
let ap_repr = blogs[0].to_activity07(&conn).unwrap();
let ap_repr = blogs[0].to_activity(&conn).unwrap();
blogs[0].delete(&conn).unwrap();
let blog = Blog::from_activity(&conn, ap_repr).unwrap();
@ -976,12 +976,12 @@ pub(crate) mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = &db();
conn.test_transaction::<_, Error, _>(|| {
let (_users, blogs) = fill_database(&conn);
let blog = &blogs[0];
let act = blog.to_activity07(conn)?;
let act = blog.to_activity(conn)?;
let expected = json!({
"icon": {

View file

@ -111,7 +111,7 @@ impl Comment {
.unwrap_or(false)
}
pub fn to_activity07(&self, conn: &DbConn) -> Result<Note> {
pub fn to_activity(&self, conn: &DbConn) -> Result<Note> {
let author = User::get(conn, self.author_id)?;
let (html, mentions, _hashtags) = utils::md_to_html(
self.content.get().as_ref(),
@ -142,17 +142,17 @@ impl Comment {
note.set_attributed_to(author.into_id().parse::<IriString>()?);
note.set_many_tos(to);
note.set_many_tags(mentions.into_iter().filter_map(|m| {
Mention::build_activity07(conn, &m)
Mention::build_activity(conn, &m)
.map(|mention| mention.into_any_base().expect("Can convert"))
.ok()
}));
Ok(note)
}
pub fn create_activity07(&self, conn: &DbConn) -> Result<Create> {
pub fn create_activity(&self, conn: &DbConn) -> Result<Create> {
let author = User::get(conn, self.author_id)?;
let note = self.to_activity07(conn)?;
let note = self.to_activity(conn)?;
let note_clone = note.clone();
let mut act = Create::new(
@ -358,7 +358,7 @@ impl AsObject<User, Create, &DbConn> for Comment {
type Error = Error;
type Output = Self;
fn activity07(self, _conn: &DbConn, _actor: User, _id: &str) -> Result<Self> {
fn activity(self, _conn: &DbConn, _actor: User, _id: &str) -> Result<Self> {
// The actual creation takes place in the FromId impl
Ok(self)
}
@ -368,7 +368,7 @@ impl AsObject<User, Delete, &DbConn> for Comment {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
if self.author_id != actor.id {
return Err(Error::Unauthorized);
}
@ -458,7 +458,7 @@ mod tests {
let conn = &db();
conn.test_transaction::<_, (), _>(|| {
let (original_comm, posts, users, _blogs) = prepare_activity(&conn);
let act = original_comm.create_activity07(&conn).unwrap();
let act = original_comm.create_activity(&conn).unwrap();
assert_json_eq!(to_value(&act).unwrap(), json!({
"actor": "https://plu.me/@/admin/",
@ -500,7 +500,7 @@ mod tests {
},
)
.unwrap();
let reply_act = reply.create_activity07(&conn).unwrap();
let reply_act = reply.create_activity(&conn).unwrap();
assert_json_eq!(to_value(&reply_act).unwrap(), json!({
"actor": "https://plu.me/@/user/",
@ -544,11 +544,11 @@ mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (comment, _posts, _users, _blogs) = prepare_activity(&conn);
let act = comment.to_activity07(&conn)?;
let act = comment.to_activity(&conn)?;
let expected = json!({
"attributedTo": "https://plu.me/@/admin/",

View file

@ -55,7 +55,7 @@ impl Follow {
.map_err(Error::from)
}
pub fn to_activity07(&self, conn: &Connection) -> Result<FollowAct> {
pub fn to_activity(&self, conn: &Connection) -> Result<FollowAct> {
let user = User::get(conn, self.follower_id)?;
let target = User::get(conn, self.following_id)?;
let target_id = target.ap_url.parse::<IriString>()?;
@ -158,7 +158,7 @@ impl AsObject<User, FollowAct, &DbConn> for User {
type Error = Error;
type Output = Follow;
fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result<Follow> {
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Follow> {
// Mastodon (at least) requires the full Follow object when accepting it,
// so we rebuilt it here
let mut follow =
@ -212,7 +212,7 @@ impl AsObject<User, Undo, &DbConn> for Follow {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
let conn = conn;
if self.follower_id == actor.id {
diesel::delete(&self).execute(&**conn)?;
@ -297,11 +297,11 @@ mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (follow, _following, _follower, _users) = prepare_activity(&conn);
let act = follow.to_activity07(&conn)?;
let act = follow.to_activity(&conn)?;
let expected = json!({
"actor": "https://plu.me/@/other/",
@ -323,7 +323,7 @@ mod tests {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (follow, following, follower, _users) = prepare_activity(&conn);
let act = follow.build_accept07(&follower, &following, follow.to_activity07(&conn)?)?;
let act = follow.build_accept07(&follower, &following, follow.to_activity(&conn)?)?;
let expected = json!({
"actor": "https://plu.me/@/user/",

View file

@ -39,7 +39,7 @@ impl Like {
find_by!(likes, find_by_ap_url, ap_url as &str);
find_by!(likes, find_by_user_on_post, user_id as i32, post_id as i32);
pub fn to_activity07(&self, conn: &Connection) -> Result<LikeAct> {
pub fn to_activity(&self, conn: &Connection) -> Result<LikeAct> {
let mut act = LikeAct::new(
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
Post::get(conn, self.post_id)?.ap_url.parse::<IriString>()?,
@ -73,7 +73,7 @@ impl Like {
pub fn build_undo07(&self, conn: &Connection) -> Result<Undo> {
let mut act = Undo::new(
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
AnyBase::from_extended(self.to_activity07(conn)?)?,
AnyBase::from_extended(self.to_activity(conn)?)?,
);
act.set_id(format!("{}#delete", self.ap_url).parse::<IriString>()?);
act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::<IriString>()?]);
@ -89,7 +89,7 @@ impl AsObject<User, LikeAct, &DbConn> for Post {
type Error = Error;
type Output = Like;
fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result<Like> {
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Like> {
let res = Like::insert(
conn,
NewLike {
@ -158,7 +158,7 @@ impl AsObject<User, Undo, &DbConn> for Like {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
if actor.id == self.user_id {
diesel::delete(&self).execute(&**conn)?;
@ -193,14 +193,14 @@ mod tests {
use serde_json::{json, to_value};
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (posts, _users, _blogs) = fill_database(&conn);
let post = &posts[0];
let user = &post.get_authors(&conn)?[0];
let like = Like::insert(&*conn, NewLike::new(post, user))?;
let act = like.to_activity07(&conn).unwrap();
let act = like.to_activity(&conn).unwrap();
let expected = json!({
"actor": "https://plu.me/@/admin/",

View file

@ -60,7 +60,7 @@ impl Mention {
}
}
pub fn build_activity07(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 mut mention = link::Mention::new();
mention.set_href(user.ap_url.parse::<IriString>()?);
@ -68,7 +68,7 @@ impl Mention {
Ok(mention)
}
pub fn to_activity07(&self, conn: &Connection) -> Result<link::Mention> {
pub fn to_activity(&self, conn: &Connection) -> Result<link::Mention> {
let user = self.get_mentioned(conn)?;
let mut mention = link::Mention::new();
mention.set_href(user.ap_url.parse::<IriString>()?);
@ -157,13 +157,13 @@ mod tests {
use serde_json::{json, to_value};
#[test]
fn build_activity07() {
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_activity07(&conn, name)?;
let act = Mention::build_activity(&conn, name)?;
let expected = json!({
"href": "https://plu.me/@/admin/",
@ -178,7 +178,7 @@ mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (posts, users, _blogs) = fill_database(&conn);
@ -192,7 +192,7 @@ mod tests {
comment_id: None,
},
)?;
let act = mention.to_activity07(&conn)?;
let act = mention.to_activity(&conn)?;
let expected = json!({
"href": "https://plu.me/@/admin/",

View file

@ -341,17 +341,17 @@ impl Post {
}))
}
pub fn to_activity07(&self, conn: &Connection) -> Result<LicensedArticle> {
pub fn to_activity(&self, conn: &Connection) -> Result<LicensedArticle> {
let cc = self.get_receivers_urls(conn)?;
let to = vec![PUBLIC_VISIBILITY.to_string()];
let mut mentions_json = Mention::list_for_post(conn, self.id)?
.into_iter()
.map(|m| json!(m.to_activity07(conn).ok()))
.map(|m| json!(m.to_activity(conn).ok()))
.collect::<Vec<serde_json::Value>>();
let mut tags_json = Tag::for_post(conn, self.id)?
.into_iter()
.map(|t| json!(t.to_activity07().ok()))
.map(|t| json!(t.to_activity().ok()))
.collect::<Vec<serde_json::Value>>();
mentions_json.append(&mut tags_json);
@ -415,8 +415,8 @@ impl Post {
Ok(LicensedArticle::new(article, license, source))
}
pub fn create_activity07(&self, conn: &Connection) -> Result<Create> {
let article = self.to_activity07(conn)?;
pub fn create_activity(&self, conn: &Connection) -> Result<Create> {
let article = self.to_activity(conn)?;
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
let mut act = Create::new(
@ -429,8 +429,8 @@ impl Post {
Ok(act)
}
pub fn update_activity07(&self, conn: &Connection) -> Result<Update> {
let article = self.to_activity07(conn)?;
pub fn update_activity(&self, conn: &Connection) -> Result<Update> {
let article = self.to_activity(conn)?;
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
let mut act = Update::new(
@ -811,7 +811,7 @@ impl AsObject<User, Create, &DbConn> for Post {
type Error = Error;
type Output = Self;
fn activity07(self, _conn: &DbConn, _actor: User, _id: &str) -> Result<Self::Output> {
fn activity(self, _conn: &DbConn, _actor: User, _id: &str) -> Result<Self::Output> {
// TODO: check that _actor is actually one of the author?
Ok(self)
}
@ -821,7 +821,7 @@ impl AsObject<User, Delete, &DbConn> for Post {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<Self::Output> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<Self::Output> {
let can_delete = self
.get_authors(conn)?
.into_iter()
@ -906,7 +906,7 @@ impl AsObject<User, Update, &DbConn> for PostUpdate {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
let mut post =
Post::from_id(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?;
@ -1062,7 +1062,7 @@ mod tests {
},
)
.unwrap();
let create = post.create_activity07(&conn).unwrap();
let create = post.create_activity(&conn).unwrap();
post.delete(&conn).unwrap();
match inbox(&conn, serde_json::to_value(create).unwrap()).unwrap() {
@ -1081,11 +1081,11 @@ mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
let act = post.to_activity07(&conn)?;
let act = post.to_activity(&conn)?;
let expected = json!({
"attributedTo": ["https://plu.me/@/admin/", "https://plu.me/~/BlogName/"],
@ -1119,11 +1119,11 @@ mod tests {
}
#[test]
fn create_activity07() {
fn create_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
let act = post.create_activity07(&conn)?;
let act = post.create_activity(&conn)?;
let expected = json!({
"actor": "https://plu.me/@/admin/",
@ -1164,11 +1164,11 @@ mod tests {
}
#[test]
fn update_activity07() {
fn update_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
let act = post.update_activity07(&conn)?;
let act = post.update_activity(&conn)?;
let expected = json!({
"actor": "https://plu.me/@/admin/",

View file

@ -65,7 +65,7 @@ impl Reshare {
User::get(conn, self.user_id)
}
pub fn to_activity07(&self, conn: &Connection) -> Result<Announce> {
pub fn to_activity(&self, conn: &Connection) -> Result<Announce> {
let mut act = Announce::new(
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
Post::get(conn, self.post_id)?.ap_url.parse::<IriString>()?,
@ -100,7 +100,7 @@ impl Reshare {
pub fn build_undo07(&self, conn: &Connection) -> Result<Undo> {
let mut act = Undo::new(
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
AnyBase::from_extended(self.to_activity07(conn)?)?,
AnyBase::from_extended(self.to_activity(conn)?)?,
);
act.set_id(format!("{}#delete", self.ap_url).parse::<IriString>()?);
act.set_many_tos(vec![PUBLIC_VISIBILITY.parse::<IriString>()?]);
@ -117,7 +117,7 @@ impl AsObject<User, Announce, &DbConn> for Post {
type Error = Error;
type Output = Reshare;
fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result<Reshare> {
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Reshare> {
let conn = conn;
let reshare = Reshare::insert(
conn,
@ -187,7 +187,7 @@ impl AsObject<User, Undo, &DbConn> for Reshare {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
if actor.id == self.user_id {
diesel::delete(&self).execute(&**conn)?;
@ -223,14 +223,14 @@ mod test {
use serde_json::{json, to_value};
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let (posts, _users, _blogs) = fill_database(&conn);
let post = &posts[0];
let user = &post.get_authors(&conn)?[0];
let reshare = Reshare::insert(&*conn, NewReshare::new(post, user))?;
let act = reshare.to_activity07(&conn).unwrap();
let act = reshare.to_activity(&conn).unwrap();
let expected = json!({
"actor": "https://plu.me/@/admin/",

View file

@ -25,7 +25,7 @@ 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<Hashtag> {
pub fn to_activity(&self) -> Result<Hashtag> {
let mut ht = Hashtag::new();
ht.set_href(
ap_url(&format!(
@ -55,7 +55,7 @@ impl Tag {
)
}
pub fn build_activity07(tag: String) -> Result<Hashtag> {
pub fn build_activity(tag: String) -> Result<Hashtag> {
let mut ht = Hashtag::new();
ht.set_href(
ap_url(&format!(
@ -104,7 +104,7 @@ mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = &db();
conn.test_transaction::<_, Error, _>(|| {
fill_database(conn);
@ -114,7 +114,7 @@ mod tests {
is_hashtag: false,
post_id: 0,
};
let act = tag.to_activity07()?;
let act = tag.to_activity()?;
let expected = json!({
"href": "https://plu.me/tag/a_tag",
"name": "a_tag",
@ -128,11 +128,11 @@ mod tests {
}
#[test]
fn build_activity07() {
fn build_activity() {
let conn = &db();
conn.test_transaction::<_, Error, _>(|| {
fill_database(conn);
let act = Tag::build_activity07("a_tag".into())?;
let act = Tag::build_activity("a_tag".into())?;
let expected = json!({
"href": "https://plu.me/tag/a_tag",
"name": "a_tag",

View file

@ -623,10 +623,7 @@ mod tests {
)
.unwrap();
gnu_post
.update_tags07(
&conn,
vec![Tag::build_activity07("free".to_owned()).unwrap()],
)
.update_tags07(&conn, vec![Tag::build_activity("free".to_owned()).unwrap()])
.unwrap();
PostAuthor::insert(
&conn,

View file

@ -611,7 +611,7 @@ impl User {
Ok(posts
.into_iter()
.filter_map(|p| {
p.create_activity07(conn)
p.create_activity(conn)
.ok()
.and_then(|a| serde_json::to_value(a).ok())
})
@ -775,7 +775,7 @@ impl User {
}
}
pub fn to_activity07(&self, conn: &Connection) -> Result<CustomPerson> {
pub fn to_activity(&self, conn: &Connection) -> Result<CustomPerson> {
let mut actor = ApActor::new(self.inbox_url.parse()?, Person::new());
let ap_url = self.ap_url.parse::<IriString>()?;
actor.set_id(ap_url.clone());
@ -813,7 +813,7 @@ impl User {
Ok(CustomPerson::new(actor, ap_signature))
}
pub fn delete_activity07(&self, conn: &Connection) -> Result<Delete> {
pub fn delete_activity(&self, conn: &Connection) -> Result<Delete> {
let mut tombstone = Tombstone::new();
tombstone.set_id(self.ap_url.parse()?);
@ -1069,7 +1069,7 @@ impl AsObject<User, Delete, &DbConn> for User {
type Error = Error;
type Output = ();
fn activity07(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
fn activity(self, conn: &DbConn, actor: User, _id: &str) -> Result<()> {
if self.id == actor.id {
self.delete(conn).map(|_| ())
} else {
@ -1426,7 +1426,7 @@ pub(crate) mod tests {
conn.test_transaction::<_, (), _>(|| {
let users = fill_database(&conn);
let ap_repr = users[0].to_activity07(&conn).unwrap();
let ap_repr = users[0].to_activity(&conn).unwrap();
users[0].delete(&conn).unwrap();
let user = User::from_activity(&conn, ap_repr).unwrap();
@ -1447,12 +1447,12 @@ pub(crate) mod tests {
}
#[test]
fn to_activity07() {
fn to_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let users = fill_database(&conn);
let user = &users[0];
let act = user.to_activity07(&conn)?;
let act = user.to_activity(&conn)?;
let expected = json!({
"endpoints": {
@ -1477,7 +1477,7 @@ pub(crate) mod tests {
assert_json_eq!(to_value(act)?, expected);
let other = &users[2];
let other_act = other.to_activity07(&conn)?;
let other_act = other.to_activity(&conn)?;
let expected_other = json!({
"endpoints": {
"sharedInbox": "https://plu.me/inbox"
@ -1509,12 +1509,12 @@ pub(crate) mod tests {
}
#[test]
fn delete_activity07() {
fn delete_activity() {
let conn = db();
conn.test_transaction::<_, Error, _>(|| {
let users = fill_database(&conn);
let user = &users[1];
let act = user.delete_activity07(&conn)?;
let act = user.delete_activity(&conn)?;
let expected = json!({
"actor": "https://plu.me/@/user/",

View file

@ -193,14 +193,14 @@ pub fn create(
for m in mentions.into_iter() {
Mention::from_activity(
&conn,
&Mention::build_activity07(&conn, &m)?,
&Mention::build_activity(&conn, &m)?,
post.id,
true,
true,
)?;
}
let act = post.create_activity07(&conn)?;
let act = post.create_activity(&conn)?;
let dest = User::one_by_instance(&conn)?;
worker.execute(move || broadcast(&author, act, dest, CONFIG.proxy().cloned()));
}

View file

@ -49,7 +49,7 @@ pub fn activity_details(
_ap: ApRequest,
) -> Option<ActivityStream<CustomGroup>> {
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
Some(ActivityStream::new(blog.to_activity07(&conn).ok()?))
Some(ActivityStream::new(blog.to_activity(&conn).ok()?))
}
#[get("/blogs/new")]

View file

@ -66,14 +66,14 @@ pub fn create(
)
.expect("comments::create: insert error");
let new_comment = comm
.create_activity07(&conn)
.create_activity(&conn)
.expect("comments::create: activity error");
// save mentions
for ment in mentions {
Mention::from_activity(
&conn,
&Mention::build_activity07(&conn, &ment)
&Mention::build_activity(&conn, &ment)
.expect("comments::create: build mention error"),
comm.id,
false,
@ -187,7 +187,7 @@ pub fn activity_pub(
conn: DbConn,
) -> Option<ActivityStream<Note>> {
Comment::get(&conn, id)
.and_then(|c| c.to_activity07(&conn))
.and_then(|c| c.to_activity(&conn))
.ok()
.map(ActivityStream::new)
}

View file

@ -382,7 +382,7 @@ fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), E
)
.unwrap();
let target = User::one_by_instance(&*conn)?;
let delete_act = u.delete_activity07(&*conn)?;
let delete_act = u.delete_activity(&*conn)?;
worker.execute(move || broadcast(&u, delete_act, target, CONFIG.proxy().cloned()));
}

View file

@ -27,7 +27,7 @@ pub fn create(
Timeline::add_to_all_timelines(&conn, &post, Kind::Like(&user))?;
let dest = User::one_by_instance(&*conn)?;
let act = like.to_activity07(&*conn)?;
let act = like.to_activity(&*conn)?;
rockets
.worker
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));

View file

@ -113,7 +113,7 @@ pub fn activity_details(
let post = Post::find_by_slug(&conn, &slug, blog.id).map_err(|_| None)?;
if post.published {
Ok(ActivityStream::new(
post.to_activity07(&conn)
post.to_activity(&conn)
.map_err(|_| String::from("Post serialization error"))?,
))
} else {
@ -312,7 +312,7 @@ pub fn update(
&conn,
mentions
.into_iter()
.filter_map(|m| Mention::build_activity07(&conn, &m).ok())
.filter_map(|m| Mention::build_activity(&conn, &m).ok())
.collect(),
)
.expect("post::update: mentions error");
@ -325,7 +325,7 @@ pub fn update(
.filter(|t| !t.is_empty())
.collect::<HashSet<_>>()
.into_iter()
.filter_map(|t| Tag::build_activity07(t.to_string()).ok())
.filter_map(|t| Tag::build_activity(t.to_string()).ok())
.collect::<Vec<_>>();
post.update_tags07(&conn, tags)
.expect("post::update: tags error");
@ -334,7 +334,7 @@ pub fn update(
.into_iter()
.collect::<HashSet<_>>()
.into_iter()
.filter_map(|t| Tag::build_activity07(t).ok())
.filter_map(|t| Tag::build_activity(t).ok())
.collect::<Vec<_>>();
post.update_hashtags07(&conn, hashtags)
.expect("post::update: hashtags error");
@ -342,7 +342,7 @@ pub fn update(
if post.published {
if newly_published {
let act = post
.create_activity07(&conn)
.create_activity(&conn)
.expect("post::update: act error");
let dest = User::one_by_instance(&conn).expect("post::update: dest error");
rockets
@ -352,7 +352,7 @@ pub fn update(
Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok();
} else {
let act = post
.update_activity07(&conn)
.update_activity(&conn)
.expect("post::update: act error");
let dest = User::one_by_instance(&conn).expect("posts::update: dest error");
rockets
@ -532,8 +532,7 @@ pub fn create(
for m in mentions {
Mention::from_activity(
&conn,
&Mention::build_activity07(&conn, &m)
.expect("post::create: mention build error"),
&Mention::build_activity(&conn, &m).expect("post::create: mention build error"),
post.id,
true,
true,
@ -542,7 +541,7 @@ pub fn create(
}
let act = post
.create_activity07(&conn)
.create_activity(&conn)
.expect("posts::create: activity error");
let dest = User::one_by_instance(&conn).expect("posts::create: dest error");
let worker = &rockets.worker;

View file

@ -27,7 +27,7 @@ pub fn create(
Timeline::add_to_all_timelines(&conn, &post, Kind::Reshare(&user))?;
let dest = User::one_by_instance(&conn)?;
let act = reshare.to_activity07(&conn)?;
let act = reshare.to_activity(&conn)?;
rockets
.worker
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));

View file

@ -125,7 +125,7 @@ pub fn follow(
)?;
f.notify(&conn)?;
let act = f.to_activity07(&conn)?;
let act = f.to_activity(&conn)?;
let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name());
rockets
.worker
@ -271,7 +271,7 @@ pub fn activity_details(
_ap: ApRequest,
) -> Option<ActivityStream<CustomPerson>> {
let user = User::find_by_fqn(&conn, &name).ok()?;
Some(ActivityStream::new(user.to_activity07(&conn).ok()?))
Some(ActivityStream::new(user.to_activity(&conn).ok()?))
}
#[get("/users/new")]
@ -386,7 +386,7 @@ pub fn delete(
account.delete(&conn)?;
let target = User::one_by_instance(&conn)?;
let delete_act = account.delete_activity07(&conn)?;
let delete_act = account.delete_activity(&conn)?;
rockets
.worker
.execute(move || broadcast(&account, delete_act, target, CONFIG.proxy().cloned()));