Rename: activity07() -> activity()
This commit is contained in:
parent
15134eed60
commit
df005a28f8
@ -260,7 +260,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Handle the activity
|
// Handle the activity
|
||||||
match obj.activity07(ctx, actor, act_id) {
|
match obj.activity(ctx, actor, act_id) {
|
||||||
Ok(res) => Self::Handled(res.into()),
|
Ok(res) => Self::Handled(res.into()),
|
||||||
Err(e) => Self::Failed(e),
|
Err(e) => Self::Failed(e),
|
||||||
}
|
}
|
||||||
@ -540,7 +540,7 @@ where
|
|||||||
/// - `ctx`: the context passed to `Inbox::handle`
|
/// - `ctx`: the context passed to `Inbox::handle`
|
||||||
/// - `actor`: the actor who did this activity
|
/// - `actor`: the actor who did this activity
|
||||||
/// - `id`: the ID of 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)]
|
#[cfg(test)]
|
||||||
@ -650,12 +650,7 @@ mod tests {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn activity07(
|
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
|
||||||
self,
|
|
||||||
_: &(),
|
|
||||||
_actor: MyActor,
|
|
||||||
_id: &str,
|
|
||||||
) -> Result<Self::Output, Self::Error> {
|
|
||||||
println!("MyActor is creating a Note");
|
println!("MyActor is creating a Note");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -665,12 +660,7 @@ mod tests {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn activity07(
|
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
|
||||||
self,
|
|
||||||
_: &(),
|
|
||||||
_actor: MyActor,
|
|
||||||
_id: &str,
|
|
||||||
) -> Result<Self::Output, Self::Error> {
|
|
||||||
println!("MyActor is liking a Note");
|
println!("MyActor is liking a Note");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -680,12 +670,7 @@ mod tests {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn activity07(
|
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
|
||||||
self,
|
|
||||||
_: &(),
|
|
||||||
_actor: MyActor,
|
|
||||||
_id: &str,
|
|
||||||
) -> Result<Self::Output, Self::Error> {
|
|
||||||
println!("MyActor is deleting a Note");
|
println!("MyActor is deleting a Note");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -695,12 +680,7 @@ mod tests {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn activity07(
|
fn activity(self, _: &(), _actor: MyActor, _id: &str) -> Result<Self::Output, Self::Error> {
|
||||||
self,
|
|
||||||
_: &(),
|
|
||||||
_actor: MyActor,
|
|
||||||
_id: &str,
|
|
||||||
) -> Result<Self::Output, Self::Error> {
|
|
||||||
println!("MyActor is announcing a Note");
|
println!("MyActor is announcing a Note");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -802,7 +782,7 @@ mod tests {
|
|||||||
type Error = ();
|
type Error = ();
|
||||||
type Output = ();
|
type Output = ();
|
||||||
|
|
||||||
fn activity07(
|
fn activity(
|
||||||
self,
|
self,
|
||||||
_: &(),
|
_: &(),
|
||||||
_actor: FailingActor,
|
_actor: FailingActor,
|
||||||
|
@ -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());
|
let mut blog = ApActor::new(self.inbox_url.parse()?, Group::new());
|
||||||
blog.set_preferred_username(self.actor_id.clone());
|
blog.set_preferred_username(self.actor_id.clone());
|
||||||
blog.set_name(self.title.clone());
|
blog.set_name(self.title.clone());
|
||||||
@ -954,7 +954,7 @@ pub(crate) mod tests {
|
|||||||
.id,
|
.id,
|
||||||
);
|
);
|
||||||
let _: Blog = blogs[0].save_changes(&**conn).unwrap();
|
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();
|
blogs[0].delete(&conn).unwrap();
|
||||||
let blog = Blog::from_activity(&conn, ap_repr).unwrap();
|
let blog = Blog::from_activity(&conn, ap_repr).unwrap();
|
||||||
|
|
||||||
@ -976,12 +976,12 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = &db();
|
let conn = &db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (_users, blogs) = fill_database(&conn);
|
let (_users, blogs) = fill_database(&conn);
|
||||||
let blog = &blogs[0];
|
let blog = &blogs[0];
|
||||||
let act = blog.to_activity07(conn)?;
|
let act = blog.to_activity(conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"icon": {
|
"icon": {
|
||||||
|
@ -111,7 +111,7 @@ impl Comment {
|
|||||||
.unwrap_or(false)
|
.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 author = User::get(conn, self.author_id)?;
|
||||||
let (html, mentions, _hashtags) = utils::md_to_html(
|
let (html, mentions, _hashtags) = utils::md_to_html(
|
||||||
self.content.get().as_ref(),
|
self.content.get().as_ref(),
|
||||||
@ -142,17 +142,17 @@ impl Comment {
|
|||||||
note.set_attributed_to(author.into_id().parse::<IriString>()?);
|
note.set_attributed_to(author.into_id().parse::<IriString>()?);
|
||||||
note.set_many_tos(to);
|
note.set_many_tos(to);
|
||||||
note.set_many_tags(mentions.into_iter().filter_map(|m| {
|
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"))
|
.map(|mention| mention.into_any_base().expect("Can convert"))
|
||||||
.ok()
|
.ok()
|
||||||
}));
|
}));
|
||||||
Ok(note)
|
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 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 note_clone = note.clone();
|
||||||
|
|
||||||
let mut act = Create::new(
|
let mut act = Create::new(
|
||||||
@ -358,7 +358,7 @@ impl AsObject<User, Create, &DbConn> for Comment {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = Self;
|
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
|
// The actual creation takes place in the FromId impl
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ impl AsObject<User, Delete, &DbConn> for Comment {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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 {
|
if self.author_id != actor.id {
|
||||||
return Err(Error::Unauthorized);
|
return Err(Error::Unauthorized);
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ mod tests {
|
|||||||
let conn = &db();
|
let conn = &db();
|
||||||
conn.test_transaction::<_, (), _>(|| {
|
conn.test_transaction::<_, (), _>(|| {
|
||||||
let (original_comm, posts, users, _blogs) = prepare_activity(&conn);
|
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!({
|
assert_json_eq!(to_value(&act).unwrap(), json!({
|
||||||
"actor": "https://plu.me/@/admin/",
|
"actor": "https://plu.me/@/admin/",
|
||||||
@ -500,7 +500,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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!({
|
assert_json_eq!(to_value(&reply_act).unwrap(), json!({
|
||||||
"actor": "https://plu.me/@/user/",
|
"actor": "https://plu.me/@/user/",
|
||||||
@ -544,11 +544,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (comment, _posts, _users, _blogs) = prepare_activity(&conn);
|
let (comment, _posts, _users, _blogs) = prepare_activity(&conn);
|
||||||
let act = comment.to_activity07(&conn)?;
|
let act = comment.to_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"attributedTo": "https://plu.me/@/admin/",
|
"attributedTo": "https://plu.me/@/admin/",
|
||||||
|
@ -55,7 +55,7 @@ impl Follow {
|
|||||||
.map_err(Error::from)
|
.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 user = User::get(conn, self.follower_id)?;
|
||||||
let target = User::get(conn, self.following_id)?;
|
let target = User::get(conn, self.following_id)?;
|
||||||
let target_id = target.ap_url.parse::<IriString>()?;
|
let target_id = target.ap_url.parse::<IriString>()?;
|
||||||
@ -158,7 +158,7 @@ impl AsObject<User, FollowAct, &DbConn> for User {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = Follow;
|
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,
|
// Mastodon (at least) requires the full Follow object when accepting it,
|
||||||
// so we rebuilt it here
|
// so we rebuilt it here
|
||||||
let mut follow =
|
let mut follow =
|
||||||
@ -212,7 +212,7 @@ impl AsObject<User, Undo, &DbConn> for Follow {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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;
|
let conn = conn;
|
||||||
if self.follower_id == actor.id {
|
if self.follower_id == actor.id {
|
||||||
diesel::delete(&self).execute(&**conn)?;
|
diesel::delete(&self).execute(&**conn)?;
|
||||||
@ -297,11 +297,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (follow, _following, _follower, _users) = prepare_activity(&conn);
|
let (follow, _following, _follower, _users) = prepare_activity(&conn);
|
||||||
let act = follow.to_activity07(&conn)?;
|
let act = follow.to_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/other/",
|
"actor": "https://plu.me/@/other/",
|
||||||
@ -323,7 +323,7 @@ mod tests {
|
|||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (follow, following, follower, _users) = prepare_activity(&conn);
|
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!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/user/",
|
"actor": "https://plu.me/@/user/",
|
||||||
|
@ -39,7 +39,7 @@ impl Like {
|
|||||||
find_by!(likes, find_by_ap_url, ap_url as &str);
|
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);
|
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(
|
let mut act = LikeAct::new(
|
||||||
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
||||||
Post::get(conn, self.post_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> {
|
pub fn build_undo07(&self, conn: &Connection) -> Result<Undo> {
|
||||||
let mut act = Undo::new(
|
let mut act = Undo::new(
|
||||||
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
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_id(format!("{}#delete", self.ap_url).parse::<IriString>()?);
|
||||||
act.set_many_tos(vec![PUBLIC_VISIBILITY.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 Error = Error;
|
||||||
type Output = Like;
|
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(
|
let res = Like::insert(
|
||||||
conn,
|
conn,
|
||||||
NewLike {
|
NewLike {
|
||||||
@ -158,7 +158,7 @@ impl AsObject<User, Undo, &DbConn> for Like {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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 {
|
if actor.id == self.user_id {
|
||||||
diesel::delete(&self).execute(&**conn)?;
|
diesel::delete(&self).execute(&**conn)?;
|
||||||
|
|
||||||
@ -193,14 +193,14 @@ mod tests {
|
|||||||
use serde_json::{json, to_value};
|
use serde_json::{json, to_value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (posts, _users, _blogs) = fill_database(&conn);
|
let (posts, _users, _blogs) = fill_database(&conn);
|
||||||
let post = &posts[0];
|
let post = &posts[0];
|
||||||
let user = &post.get_authors(&conn)?[0];
|
let user = &post.get_authors(&conn)?[0];
|
||||||
let like = Like::insert(&*conn, NewLike::new(post, user))?;
|
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!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/admin/",
|
"actor": "https://plu.me/@/admin/",
|
||||||
|
@ -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 user = User::find_by_fqn(conn, ment)?;
|
||||||
let mut mention = link::Mention::new();
|
let mut mention = link::Mention::new();
|
||||||
mention.set_href(user.ap_url.parse::<IriString>()?);
|
mention.set_href(user.ap_url.parse::<IriString>()?);
|
||||||
@ -68,7 +68,7 @@ impl Mention {
|
|||||||
Ok(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 user = self.get_mentioned(conn)?;
|
||||||
let mut mention = link::Mention::new();
|
let mut mention = link::Mention::new();
|
||||||
mention.set_href(user.ap_url.parse::<IriString>()?);
|
mention.set_href(user.ap_url.parse::<IriString>()?);
|
||||||
@ -157,13 +157,13 @@ mod tests {
|
|||||||
use serde_json::{json, to_value};
|
use serde_json::{json, to_value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_activity07() {
|
fn build_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (_posts, users, _blogs) = fill_database(&conn);
|
let (_posts, users, _blogs) = fill_database(&conn);
|
||||||
let user = &users[0];
|
let user = &users[0];
|
||||||
let name = &user.username;
|
let name = &user.username;
|
||||||
let act = Mention::build_activity07(&conn, name)?;
|
let act = Mention::build_activity(&conn, name)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"href": "https://plu.me/@/admin/",
|
"href": "https://plu.me/@/admin/",
|
||||||
@ -178,7 +178,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (posts, users, _blogs) = fill_database(&conn);
|
let (posts, users, _blogs) = fill_database(&conn);
|
||||||
@ -192,7 +192,7 @@ mod tests {
|
|||||||
comment_id: None,
|
comment_id: None,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
let act = mention.to_activity07(&conn)?;
|
let act = mention.to_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"href": "https://plu.me/@/admin/",
|
"href": "https://plu.me/@/admin/",
|
||||||
|
@ -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 cc = self.get_receivers_urls(conn)?;
|
||||||
let to = vec![PUBLIC_VISIBILITY.to_string()];
|
let to = vec![PUBLIC_VISIBILITY.to_string()];
|
||||||
|
|
||||||
let mut mentions_json = Mention::list_for_post(conn, self.id)?
|
let mut mentions_json = Mention::list_for_post(conn, self.id)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|m| json!(m.to_activity07(conn).ok()))
|
.map(|m| json!(m.to_activity(conn).ok()))
|
||||||
.collect::<Vec<serde_json::Value>>();
|
.collect::<Vec<serde_json::Value>>();
|
||||||
let mut tags_json = Tag::for_post(conn, self.id)?
|
let mut tags_json = Tag::for_post(conn, self.id)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|t| json!(t.to_activity07().ok()))
|
.map(|t| json!(t.to_activity().ok()))
|
||||||
.collect::<Vec<serde_json::Value>>();
|
.collect::<Vec<serde_json::Value>>();
|
||||||
mentions_json.append(&mut tags_json);
|
mentions_json.append(&mut tags_json);
|
||||||
|
|
||||||
@ -415,8 +415,8 @@ impl Post {
|
|||||||
Ok(LicensedArticle::new(article, license, source))
|
Ok(LicensedArticle::new(article, license, source))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_activity07(&self, conn: &Connection) -> Result<Create> {
|
pub fn create_activity(&self, conn: &Connection) -> Result<Create> {
|
||||||
let article = self.to_activity07(conn)?;
|
let article = self.to_activity(conn)?;
|
||||||
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
|
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
|
||||||
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
|
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
|
||||||
let mut act = Create::new(
|
let mut act = Create::new(
|
||||||
@ -429,8 +429,8 @@ impl Post {
|
|||||||
Ok(act)
|
Ok(act)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_activity07(&self, conn: &Connection) -> Result<Update> {
|
pub fn update_activity(&self, conn: &Connection) -> Result<Update> {
|
||||||
let article = self.to_activity07(conn)?;
|
let article = self.to_activity(conn)?;
|
||||||
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
|
let to = article.to().ok_or(Error::MissingApProperty)?.clone();
|
||||||
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
|
let cc = article.cc().ok_or(Error::MissingApProperty)?.clone();
|
||||||
let mut act = Update::new(
|
let mut act = Update::new(
|
||||||
@ -811,7 +811,7 @@ impl AsObject<User, Create, &DbConn> for Post {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = Self;
|
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?
|
// TODO: check that _actor is actually one of the author?
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
@ -821,7 +821,7 @@ impl AsObject<User, Delete, &DbConn> for Post {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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
|
let can_delete = self
|
||||||
.get_authors(conn)?
|
.get_authors(conn)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -906,7 +906,7 @@ impl AsObject<User, Update, &DbConn> for PostUpdate {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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 =
|
let mut post =
|
||||||
Post::from_id(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?;
|
Post::from_id(conn, &self.ap_url, None, CONFIG.proxy()).map_err(|(_, e)| e)?;
|
||||||
|
|
||||||
@ -1062,7 +1062,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let create = post.create_activity07(&conn).unwrap();
|
let create = post.create_activity(&conn).unwrap();
|
||||||
post.delete(&conn).unwrap();
|
post.delete(&conn).unwrap();
|
||||||
|
|
||||||
match inbox(&conn, serde_json::to_value(create).unwrap()).unwrap() {
|
match inbox(&conn, serde_json::to_value(create).unwrap()).unwrap() {
|
||||||
@ -1081,11 +1081,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
||||||
let act = post.to_activity07(&conn)?;
|
let act = post.to_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"attributedTo": ["https://plu.me/@/admin/", "https://plu.me/~/BlogName/"],
|
"attributedTo": ["https://plu.me/@/admin/", "https://plu.me/~/BlogName/"],
|
||||||
@ -1119,11 +1119,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn create_activity07() {
|
fn create_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
||||||
let act = post.create_activity07(&conn)?;
|
let act = post.create_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/admin/",
|
"actor": "https://plu.me/@/admin/",
|
||||||
@ -1164,11 +1164,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn update_activity07() {
|
fn update_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
let (post, _mention, _posts, _users, _blogs) = prepare_activity(&conn);
|
||||||
let act = post.update_activity07(&conn)?;
|
let act = post.update_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/admin/",
|
"actor": "https://plu.me/@/admin/",
|
||||||
|
@ -65,7 +65,7 @@ impl Reshare {
|
|||||||
User::get(conn, self.user_id)
|
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(
|
let mut act = Announce::new(
|
||||||
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
||||||
Post::get(conn, self.post_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> {
|
pub fn build_undo07(&self, conn: &Connection) -> Result<Undo> {
|
||||||
let mut act = Undo::new(
|
let mut act = Undo::new(
|
||||||
User::get(conn, self.user_id)?.ap_url.parse::<IriString>()?,
|
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_id(format!("{}#delete", self.ap_url).parse::<IriString>()?);
|
||||||
act.set_many_tos(vec![PUBLIC_VISIBILITY.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 Error = Error;
|
||||||
type Output = Reshare;
|
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 conn = conn;
|
||||||
let reshare = Reshare::insert(
|
let reshare = Reshare::insert(
|
||||||
conn,
|
conn,
|
||||||
@ -187,7 +187,7 @@ impl AsObject<User, Undo, &DbConn> for Reshare {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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 {
|
if actor.id == self.user_id {
|
||||||
diesel::delete(&self).execute(&**conn)?;
|
diesel::delete(&self).execute(&**conn)?;
|
||||||
|
|
||||||
@ -223,14 +223,14 @@ mod test {
|
|||||||
use serde_json::{json, to_value};
|
use serde_json::{json, to_value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let (posts, _users, _blogs) = fill_database(&conn);
|
let (posts, _users, _blogs) = fill_database(&conn);
|
||||||
let post = &posts[0];
|
let post = &posts[0];
|
||||||
let user = &post.get_authors(&conn)?[0];
|
let user = &post.get_authors(&conn)?[0];
|
||||||
let reshare = Reshare::insert(&*conn, NewReshare::new(post, user))?;
|
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!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/admin/",
|
"actor": "https://plu.me/@/admin/",
|
||||||
|
@ -25,7 +25,7 @@ impl Tag {
|
|||||||
find_by!(tags, find_by_name, tag as &str);
|
find_by!(tags, find_by_name, tag as &str);
|
||||||
list_by!(tags, for_post, post_id as i32);
|
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();
|
let mut ht = Hashtag::new();
|
||||||
ht.set_href(
|
ht.set_href(
|
||||||
ap_url(&format!(
|
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();
|
let mut ht = Hashtag::new();
|
||||||
ht.set_href(
|
ht.set_href(
|
||||||
ap_url(&format!(
|
ap_url(&format!(
|
||||||
@ -104,7 +104,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = &db();
|
let conn = &db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
fill_database(conn);
|
fill_database(conn);
|
||||||
@ -114,7 +114,7 @@ mod tests {
|
|||||||
is_hashtag: false,
|
is_hashtag: false,
|
||||||
post_id: 0,
|
post_id: 0,
|
||||||
};
|
};
|
||||||
let act = tag.to_activity07()?;
|
let act = tag.to_activity()?;
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"href": "https://plu.me/tag/a_tag",
|
"href": "https://plu.me/tag/a_tag",
|
||||||
"name": "a_tag",
|
"name": "a_tag",
|
||||||
@ -128,11 +128,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn build_activity07() {
|
fn build_activity() {
|
||||||
let conn = &db();
|
let conn = &db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
fill_database(conn);
|
fill_database(conn);
|
||||||
let act = Tag::build_activity07("a_tag".into())?;
|
let act = Tag::build_activity("a_tag".into())?;
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"href": "https://plu.me/tag/a_tag",
|
"href": "https://plu.me/tag/a_tag",
|
||||||
"name": "a_tag",
|
"name": "a_tag",
|
||||||
|
@ -623,10 +623,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
gnu_post
|
gnu_post
|
||||||
.update_tags07(
|
.update_tags07(&conn, vec![Tag::build_activity("free".to_owned()).unwrap()])
|
||||||
&conn,
|
|
||||||
vec![Tag::build_activity07("free".to_owned()).unwrap()],
|
|
||||||
)
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
PostAuthor::insert(
|
PostAuthor::insert(
|
||||||
&conn,
|
&conn,
|
||||||
|
@ -611,7 +611,7 @@ impl User {
|
|||||||
Ok(posts
|
Ok(posts
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|p| {
|
.filter_map(|p| {
|
||||||
p.create_activity07(conn)
|
p.create_activity(conn)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|a| serde_json::to_value(a).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 mut actor = ApActor::new(self.inbox_url.parse()?, Person::new());
|
||||||
let ap_url = self.ap_url.parse::<IriString>()?;
|
let ap_url = self.ap_url.parse::<IriString>()?;
|
||||||
actor.set_id(ap_url.clone());
|
actor.set_id(ap_url.clone());
|
||||||
@ -813,7 +813,7 @@ impl User {
|
|||||||
Ok(CustomPerson::new(actor, ap_signature))
|
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();
|
let mut tombstone = Tombstone::new();
|
||||||
tombstone.set_id(self.ap_url.parse()?);
|
tombstone.set_id(self.ap_url.parse()?);
|
||||||
|
|
||||||
@ -1069,7 +1069,7 @@ impl AsObject<User, Delete, &DbConn> for User {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Output = ();
|
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 {
|
if self.id == actor.id {
|
||||||
self.delete(conn).map(|_| ())
|
self.delete(conn).map(|_| ())
|
||||||
} else {
|
} else {
|
||||||
@ -1426,7 +1426,7 @@ pub(crate) mod tests {
|
|||||||
conn.test_transaction::<_, (), _>(|| {
|
conn.test_transaction::<_, (), _>(|| {
|
||||||
let users = fill_database(&conn);
|
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();
|
users[0].delete(&conn).unwrap();
|
||||||
let user = User::from_activity(&conn, ap_repr).unwrap();
|
let user = User::from_activity(&conn, ap_repr).unwrap();
|
||||||
|
|
||||||
@ -1447,12 +1447,12 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn to_activity07() {
|
fn to_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let users = fill_database(&conn);
|
let users = fill_database(&conn);
|
||||||
let user = &users[0];
|
let user = &users[0];
|
||||||
let act = user.to_activity07(&conn)?;
|
let act = user.to_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
@ -1477,7 +1477,7 @@ pub(crate) mod tests {
|
|||||||
assert_json_eq!(to_value(act)?, expected);
|
assert_json_eq!(to_value(act)?, expected);
|
||||||
|
|
||||||
let other = &users[2];
|
let other = &users[2];
|
||||||
let other_act = other.to_activity07(&conn)?;
|
let other_act = other.to_activity(&conn)?;
|
||||||
let expected_other = json!({
|
let expected_other = json!({
|
||||||
"endpoints": {
|
"endpoints": {
|
||||||
"sharedInbox": "https://plu.me/inbox"
|
"sharedInbox": "https://plu.me/inbox"
|
||||||
@ -1509,12 +1509,12 @@ pub(crate) mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn delete_activity07() {
|
fn delete_activity() {
|
||||||
let conn = db();
|
let conn = db();
|
||||||
conn.test_transaction::<_, Error, _>(|| {
|
conn.test_transaction::<_, Error, _>(|| {
|
||||||
let users = fill_database(&conn);
|
let users = fill_database(&conn);
|
||||||
let user = &users[1];
|
let user = &users[1];
|
||||||
let act = user.delete_activity07(&conn)?;
|
let act = user.delete_activity(&conn)?;
|
||||||
|
|
||||||
let expected = json!({
|
let expected = json!({
|
||||||
"actor": "https://plu.me/@/user/",
|
"actor": "https://plu.me/@/user/",
|
||||||
|
@ -193,14 +193,14 @@ pub fn create(
|
|||||||
for m in mentions.into_iter() {
|
for m in mentions.into_iter() {
|
||||||
Mention::from_activity(
|
Mention::from_activity(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity07(&conn, &m)?,
|
&Mention::build_activity(&conn, &m)?,
|
||||||
post.id,
|
post.id,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let act = post.create_activity07(&conn)?;
|
let act = post.create_activity(&conn)?;
|
||||||
let dest = User::one_by_instance(&conn)?;
|
let dest = User::one_by_instance(&conn)?;
|
||||||
worker.execute(move || broadcast(&author, act, dest, CONFIG.proxy().cloned()));
|
worker.execute(move || broadcast(&author, act, dest, CONFIG.proxy().cloned()));
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ pub fn activity_details(
|
|||||||
_ap: ApRequest,
|
_ap: ApRequest,
|
||||||
) -> Option<ActivityStream<CustomGroup>> {
|
) -> Option<ActivityStream<CustomGroup>> {
|
||||||
let blog = Blog::find_by_fqn(&conn, &name).ok()?;
|
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")]
|
#[get("/blogs/new")]
|
||||||
|
@ -66,14 +66,14 @@ pub fn create(
|
|||||||
)
|
)
|
||||||
.expect("comments::create: insert error");
|
.expect("comments::create: insert error");
|
||||||
let new_comment = comm
|
let new_comment = comm
|
||||||
.create_activity07(&conn)
|
.create_activity(&conn)
|
||||||
.expect("comments::create: activity error");
|
.expect("comments::create: activity error");
|
||||||
|
|
||||||
// save mentions
|
// save mentions
|
||||||
for ment in mentions {
|
for ment in mentions {
|
||||||
Mention::from_activity(
|
Mention::from_activity(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity07(&conn, &ment)
|
&Mention::build_activity(&conn, &ment)
|
||||||
.expect("comments::create: build mention error"),
|
.expect("comments::create: build mention error"),
|
||||||
comm.id,
|
comm.id,
|
||||||
false,
|
false,
|
||||||
@ -187,7 +187,7 @@ pub fn activity_pub(
|
|||||||
conn: DbConn,
|
conn: DbConn,
|
||||||
) -> Option<ActivityStream<Note>> {
|
) -> Option<ActivityStream<Note>> {
|
||||||
Comment::get(&conn, id)
|
Comment::get(&conn, id)
|
||||||
.and_then(|c| c.to_activity07(&conn))
|
.and_then(|c| c.to_activity(&conn))
|
||||||
.ok()
|
.ok()
|
||||||
.map(ActivityStream::new)
|
.map(ActivityStream::new)
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ fn ban(id: i32, conn: &Connection, worker: &ScheduledThreadPool) -> Result<(), E
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let target = User::one_by_instance(&*conn)?;
|
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()));
|
worker.execute(move || broadcast(&u, delete_act, target, CONFIG.proxy().cloned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ pub fn create(
|
|||||||
Timeline::add_to_all_timelines(&conn, &post, Kind::Like(&user))?;
|
Timeline::add_to_all_timelines(&conn, &post, Kind::Like(&user))?;
|
||||||
|
|
||||||
let dest = User::one_by_instance(&*conn)?;
|
let dest = User::one_by_instance(&*conn)?;
|
||||||
let act = like.to_activity07(&*conn)?;
|
let act = like.to_activity(&*conn)?;
|
||||||
rockets
|
rockets
|
||||||
.worker
|
.worker
|
||||||
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
|
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
|
||||||
|
@ -113,7 +113,7 @@ pub fn activity_details(
|
|||||||
let post = Post::find_by_slug(&conn, &slug, blog.id).map_err(|_| None)?;
|
let post = Post::find_by_slug(&conn, &slug, blog.id).map_err(|_| None)?;
|
||||||
if post.published {
|
if post.published {
|
||||||
Ok(ActivityStream::new(
|
Ok(ActivityStream::new(
|
||||||
post.to_activity07(&conn)
|
post.to_activity(&conn)
|
||||||
.map_err(|_| String::from("Post serialization error"))?,
|
.map_err(|_| String::from("Post serialization error"))?,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
@ -312,7 +312,7 @@ pub fn update(
|
|||||||
&conn,
|
&conn,
|
||||||
mentions
|
mentions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|m| Mention::build_activity07(&conn, &m).ok())
|
.filter_map(|m| Mention::build_activity(&conn, &m).ok())
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
.expect("post::update: mentions error");
|
.expect("post::update: mentions error");
|
||||||
@ -325,7 +325,7 @@ pub fn update(
|
|||||||
.filter(|t| !t.is_empty())
|
.filter(|t| !t.is_empty())
|
||||||
.collect::<HashSet<_>>()
|
.collect::<HashSet<_>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|t| Tag::build_activity07(t.to_string()).ok())
|
.filter_map(|t| Tag::build_activity(t.to_string()).ok())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
post.update_tags07(&conn, tags)
|
post.update_tags07(&conn, tags)
|
||||||
.expect("post::update: tags error");
|
.expect("post::update: tags error");
|
||||||
@ -334,7 +334,7 @@ pub fn update(
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.collect::<HashSet<_>>()
|
.collect::<HashSet<_>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|t| Tag::build_activity07(t).ok())
|
.filter_map(|t| Tag::build_activity(t).ok())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
post.update_hashtags07(&conn, hashtags)
|
post.update_hashtags07(&conn, hashtags)
|
||||||
.expect("post::update: hashtags error");
|
.expect("post::update: hashtags error");
|
||||||
@ -342,7 +342,7 @@ pub fn update(
|
|||||||
if post.published {
|
if post.published {
|
||||||
if newly_published {
|
if newly_published {
|
||||||
let act = post
|
let act = post
|
||||||
.create_activity07(&conn)
|
.create_activity(&conn)
|
||||||
.expect("post::update: act error");
|
.expect("post::update: act error");
|
||||||
let dest = User::one_by_instance(&conn).expect("post::update: dest error");
|
let dest = User::one_by_instance(&conn).expect("post::update: dest error");
|
||||||
rockets
|
rockets
|
||||||
@ -352,7 +352,7 @@ pub fn update(
|
|||||||
Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok();
|
Timeline::add_to_all_timelines(&conn, &post, Kind::Original).ok();
|
||||||
} else {
|
} else {
|
||||||
let act = post
|
let act = post
|
||||||
.update_activity07(&conn)
|
.update_activity(&conn)
|
||||||
.expect("post::update: act error");
|
.expect("post::update: act error");
|
||||||
let dest = User::one_by_instance(&conn).expect("posts::update: dest error");
|
let dest = User::one_by_instance(&conn).expect("posts::update: dest error");
|
||||||
rockets
|
rockets
|
||||||
@ -532,8 +532,7 @@ pub fn create(
|
|||||||
for m in mentions {
|
for m in mentions {
|
||||||
Mention::from_activity(
|
Mention::from_activity(
|
||||||
&conn,
|
&conn,
|
||||||
&Mention::build_activity07(&conn, &m)
|
&Mention::build_activity(&conn, &m).expect("post::create: mention build error"),
|
||||||
.expect("post::create: mention build error"),
|
|
||||||
post.id,
|
post.id,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
@ -542,7 +541,7 @@ pub fn create(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let act = post
|
let act = post
|
||||||
.create_activity07(&conn)
|
.create_activity(&conn)
|
||||||
.expect("posts::create: activity error");
|
.expect("posts::create: activity error");
|
||||||
let dest = User::one_by_instance(&conn).expect("posts::create: dest error");
|
let dest = User::one_by_instance(&conn).expect("posts::create: dest error");
|
||||||
let worker = &rockets.worker;
|
let worker = &rockets.worker;
|
||||||
|
@ -27,7 +27,7 @@ pub fn create(
|
|||||||
Timeline::add_to_all_timelines(&conn, &post, Kind::Reshare(&user))?;
|
Timeline::add_to_all_timelines(&conn, &post, Kind::Reshare(&user))?;
|
||||||
|
|
||||||
let dest = User::one_by_instance(&conn)?;
|
let dest = User::one_by_instance(&conn)?;
|
||||||
let act = reshare.to_activity07(&conn)?;
|
let act = reshare.to_activity(&conn)?;
|
||||||
rockets
|
rockets
|
||||||
.worker
|
.worker
|
||||||
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
|
.execute(move || broadcast(&user, act, dest, CONFIG.proxy().cloned()));
|
||||||
|
@ -125,7 +125,7 @@ pub fn follow(
|
|||||||
)?;
|
)?;
|
||||||
f.notify(&conn)?;
|
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());
|
let msg = i18n!(rockets.intl.catalog, "You are now following {}."; target.name());
|
||||||
rockets
|
rockets
|
||||||
.worker
|
.worker
|
||||||
@ -271,7 +271,7 @@ pub fn activity_details(
|
|||||||
_ap: ApRequest,
|
_ap: ApRequest,
|
||||||
) -> Option<ActivityStream<CustomPerson>> {
|
) -> Option<ActivityStream<CustomPerson>> {
|
||||||
let user = User::find_by_fqn(&conn, &name).ok()?;
|
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")]
|
#[get("/users/new")]
|
||||||
@ -386,7 +386,7 @@ pub fn delete(
|
|||||||
account.delete(&conn)?;
|
account.delete(&conn)?;
|
||||||
|
|
||||||
let target = User::one_by_instance(&conn)?;
|
let target = User::one_by_instance(&conn)?;
|
||||||
let delete_act = account.delete_activity07(&conn)?;
|
let delete_act = account.delete_activity(&conn)?;
|
||||||
rockets
|
rockets
|
||||||
.worker
|
.worker
|
||||||
.execute(move || broadcast(&account, delete_act, target, CONFIG.proxy().cloned()));
|
.execute(move || broadcast(&account, delete_act, target, CONFIG.proxy().cloned()));
|
||||||
|
Loading…
Reference in New Issue
Block a user