summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-06-07 09:12:15 -0400
committerDessalines <tyhou13@gmx.com>2020-06-07 09:12:15 -0400
commit5c6601cb2a819d20b0f0d17f3575aff006a47fd2 (patch)
tree2f2adf2c8fff0a40700a47b1f2c8fd9c7c6a6da8 /server/src
parentf40f74b20d736b72152ffdf3823026b9bce6f920 (diff)
parentc1ef766125179c752ef43fb89a538058f54e9c9f (diff)
Merge branch 'activitystreams-new' into federation
Diffstat (limited to 'server/src')
-rw-r--r--server/src/apub/comment.rs3
-rw-r--r--server/src/apub/community.rs11
-rw-r--r--server/src/apub/community_inbox.rs15
-rw-r--r--server/src/apub/mod.rs14
-rw-r--r--server/src/apub/post.rs3
-rw-r--r--server/src/apub/private_message.rs3
-rw-r--r--server/src/apub/user.rs47
7 files changed, 33 insertions, 63 deletions
diff --git a/server/src/apub/comment.rs b/server/src/apub/comment.rs
index 7c77a1c7..d18908d0 100644
--- a/server/src/apub/comment.rs
+++ b/server/src/apub/comment.rs
@@ -28,8 +28,9 @@ use activitystreams::{
activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
context,
link::Mention,
- object::{kind::NoteType, properties::ObjectProperties, Note, Tombstone},
+ object::{kind::NoteType, properties::ObjectProperties, Note},
};
+use activitystreams_new::object::Tombstone;
use actix_web::{body::Body, web::Path, HttpResponse, Result};
use diesel::PgConnection;
use failure::Error;
diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs
index a81e21cf..3752798f 100644
--- a/server/src/apub/community.rs
+++ b/server/src/apub/community.rs
@@ -23,17 +23,18 @@ use crate::{
routes::DbPoolParam,
};
use activitystreams::{
- activity::{Accept, Announce, Delete, Follow, Remove, Undo},
+ activity::{Accept, Announce, Delete, Remove, Undo},
actor::{kind::GroupType, properties::ApActorProperties, Group},
collection::UnorderedCollection,
context,
endpoint::EndpointProperties,
- object::{properties::ObjectProperties, Tombstone},
+ object::properties::ObjectProperties,
Activity,
Base,
BaseBox,
};
use activitystreams_ext::Ext3;
+use activitystreams_new::{activity::Follow, object::Tombstone};
use actix_web::{body::Body, web::Path, HttpResponse, Result};
use diesel::PgConnection;
use failure::{Error, _core::fmt::Debug};
@@ -125,11 +126,7 @@ impl ActorType for Community {
/// As a local community, accept the follow request from a remote user.
fn send_accept_follow(&self, follow: &Follow, conn: &PgConnection) -> Result<(), Error> {
- let actor_uri = follow
- .follow_props
- .get_actor_xsd_any_uri()
- .unwrap()
- .to_string();
+ let actor_uri = follow.actor.as_single_xsd_any_uri().unwrap().to_string();
let id = format!("{}/accept/{}", self.actor_id, uuid::Uuid::new_v4());
let mut accept = Accept::new();
diff --git a/server/src/apub/community_inbox.rs b/server/src/apub/community_inbox.rs
index 5220dddd..975f2687 100644
--- a/server/src/apub/community_inbox.rs
+++ b/server/src/apub/community_inbox.rs
@@ -12,7 +12,8 @@ use crate::{
},
routes::{ChatServerParam, DbPoolParam},
};
-use activitystreams::activity::{Follow, Undo};
+use activitystreams::activity::Undo;
+use activitystreams_new::activity::Follow;
use actix_web::{web, HttpRequest, HttpResponse, Result};
use diesel::PgConnection;
use failure::{Error, _core::fmt::Debug};
@@ -64,16 +65,8 @@ pub async fn community_inbox(
&community.name, &input
);
let follow = input.follow()?;
- let user_uri = follow
- .follow_props
- .get_actor_xsd_any_uri()
- .unwrap()
- .to_string();
- let community_uri = follow
- .follow_props
- .get_object_xsd_any_uri()
- .unwrap()
- .to_string();
+ let user_uri = follow.actor.as_single_xsd_any_uri().unwrap().to_string();
+ let community_uri = follow.object.as_single_xsd_any_uri().unwrap().to_string();
let conn = db.get()?;
diff --git a/server/src/apub/mod.rs b/server/src/apub/mod.rs
index 805e6a0c..93f50754 100644
--- a/server/src/apub/mod.rs
+++ b/server/src/apub/mod.rs
@@ -23,11 +23,11 @@ use crate::{
Settings,
};
use activitystreams::{
- activity::Follow,
actor::{properties::ApActorProperties, Group, Person},
- object::{Page, Tombstone},
+ object::Page,
};
use activitystreams_ext::{Ext1, Ext2, Ext3};
+use activitystreams_new::{activity::Follow, object::Tombstone, prelude::*};
use actix_web::{body::Body, HttpResponse, Result};
use chrono::NaiveDateTime;
use diesel::PgConnection;
@@ -132,12 +132,10 @@ fn create_tombstone(
) -> Result<Tombstone, Error> {
if deleted {
if let Some(updated) = updated {
- let mut tombstone = Tombstone::default();
- tombstone.object_props.set_id(object_id)?;
- tombstone
- .tombstone_props
- .set_former_type_xsd_string(former_type)?
- .set_deleted(convert_datetime(updated))?;
+ let mut tombstone = Tombstone::new();
+ tombstone.set_id(object_id.parse()?);
+ tombstone.set_former_type(former_type);
+ tombstone.set_deleted(convert_datetime(updated).into());
Ok(tombstone)
} else {
Err(format_err!(
diff --git a/server/src/apub/post.rs b/server/src/apub/post.rs
index f53af309..3f86d34d 100644
--- a/server/src/apub/post.rs
+++ b/server/src/apub/post.rs
@@ -27,10 +27,11 @@ use crate::{
use activitystreams::{
activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
context,
- object::{kind::PageType, properties::ObjectProperties, AnyImage, Image, Page, Tombstone},
+ object::{kind::PageType, properties::ObjectProperties, AnyImage, Image, Page},
BaseBox,
};
use activitystreams_ext::Ext1;
+use activitystreams_new::object::Tombstone;
use actix_web::{body::Body, web::Path, HttpResponse, Result};
use diesel::PgConnection;
use failure::Error;
diff --git a/server/src/apub/private_message.rs b/server/src/apub/private_message.rs
index a222b1fe..a700043b 100644
--- a/server/src/apub/private_message.rs
+++ b/server/src/apub/private_message.rs
@@ -18,8 +18,9 @@ use crate::{
use activitystreams::{
activity::{Create, Delete, Undo, Update},
context,
- object::{kind::NoteType, properties::ObjectProperties, Note, Tombstone},
+ object::{kind::NoteType, properties::ObjectProperties, Note},
};
+use activitystreams_new::object::Tombstone;
use actix_web::Result;
use diesel::PgConnection;
use failure::Error;
diff --git a/server/src/apub/user.rs b/server/src/apub/user.rs
index 0a651d1f..c840cc22 100644
--- a/server/src/apub/user.rs
+++ b/server/src/apub/user.rs
@@ -17,13 +17,18 @@ use crate::{
routes::DbPoolParam,
};
use activitystreams::{
- activity::{Follow, Undo},
actor::{properties::ApActorProperties, Person},
context,
endpoint::EndpointProperties,
- object::{properties::ObjectProperties, AnyImage, Image, Tombstone},
+ object::{properties::ObjectProperties, AnyImage, Image},
+ primitives::XsdAnyUri,
};
use activitystreams_ext::Ext2;
+use activitystreams_new::{
+ activity::{Follow, Undo},
+ object::Tombstone,
+ prelude::*,
+};
use actix_web::{body::Body, web::Path, HttpResponse, Result};
use diesel::PgConnection;
use failure::Error;
@@ -101,18 +106,9 @@ impl ActorType for User_ {
/// As a given local user, send out a follow request to a remote community.
fn send_follow(&self, follow_actor_id: &str, conn: &PgConnection) -> Result<(), Error> {
- let mut follow = Follow::new();
-
let id = format!("{}/follow/{}", self.actor_id, uuid::Uuid::new_v4());
-
- follow
- .object_props
- .set_context_xsd_any_uri(context())?
- .set_id(id)?;
- follow
- .follow_props
- .set_actor_xsd_any_uri(self.actor_id.to_owned())?
- .set_object_xsd_any_uri(follow_actor_id)?;
+ let mut follow = Follow::new(self.actor_id.to_owned(), follow_actor_id);
+ follow.set_context(context()).set_id(id.parse()?);
let to = format!("{}/inbox", follow_actor_id);
insert_activity(&conn, self.id, &follow, true)?;
@@ -122,34 +118,17 @@ impl ActorType for User_ {
}
fn send_unfollow(&self, follow_actor_id: &str, conn: &PgConnection) -> Result<(), Error> {
- let mut follow = Follow::new();
-
let id = format!("{}/follow/{}", self.actor_id, uuid::Uuid::new_v4());
+ let mut follow = Follow::new(self.actor_id.to_owned(), follow_actor_id);
+ follow.set_context(context()).set_id(id.parse()?);
- follow
- .object_props
- .set_context_xsd_any_uri(context())?
- .set_id(id)?;
- follow
- .follow_props
- .set_actor_xsd_any_uri(self.actor_id.to_owned())?
- .set_object_xsd_any_uri(follow_actor_id)?;
let to = format!("{}/inbox", follow_actor_id);
// TODO
// Undo that fake activity
let undo_id = format!("{}/undo/follow/{}", self.actor_id, uuid::Uuid::new_v4());
- let mut undo = Undo::default();
-
- undo
- .object_props
- .set_context_xsd_any_uri(context())?
- .set_id(undo_id)?;
-
- undo
- .undo_props
- .set_actor_xsd_any_uri(self.actor_id.to_owned())?
- .set_object_base_box(follow)?;
+ let mut undo = Undo::new(self.actor_id.parse::<XsdAnyUri>()?, follow.into_any_base()?);
+ undo.set_context(context()).set_id(undo_id.parse()?);
insert_activity(&conn, self.id, &undo, true)?;