Resolve activitystream TODOs
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use activitystreams_types::activity::Create;
|
||||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket_contrib::Template;
|
||||
@@ -41,8 +40,8 @@ fn create(blog: String, slug: String, query: CommentQuery, data: Form<NewComment
|
||||
sensitive: false,
|
||||
spoiler_text: "".to_string()
|
||||
});
|
||||
// TODO: let act = Create::new(&user, &comment, &*conn);
|
||||
// broadcast(&*conn, &user, act, user.get_followers(&*conn));
|
||||
|
||||
broadcast(&*conn, &user, comment.create_activity(&*conn), user.get_followers(&*conn));
|
||||
|
||||
Redirect::to(format!("/~/{}/{}/#comment-{}", blog, slug, comment.id).as_ref())
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,4 +1,3 @@
|
||||
use activitystreams_types::activity::{Like, Undo};
|
||||
use rocket::response::Redirect;
|
||||
|
||||
use activity_pub::broadcast;
|
||||
@@ -18,12 +17,12 @@ fn create(blog: String, slug: String, user: User, conn: DbConn) -> Redirect {
|
||||
ap_url: "".to_string()
|
||||
});
|
||||
like.update_ap_url(&*conn);
|
||||
// TODO: let act = Like::new(&user, &post, &*conn);
|
||||
// TODO: broadcast(&*conn, &user, act, user.get_followers(&*conn));
|
||||
|
||||
broadcast(&*conn, &user, like.into_activity(&*conn), user.get_followers(&*conn));
|
||||
} else {
|
||||
let like = likes::Like::find_by_user_on_post(&*conn, &user, &post).unwrap();
|
||||
// TODO: like.delete(&*conn);
|
||||
// TODO: broadcast(&*conn, &user, Undo::new(&user, &like, &*conn), user.get_followers(&*conn));
|
||||
let delete_act = like.delete(&*conn);
|
||||
broadcast(&*conn, &user, delete_act, user.get_followers(&*conn));
|
||||
}
|
||||
|
||||
Redirect::to(format!("/~/{}/{}/", blog, slug).as_ref())
|
||||
|
||||
+4
-9
@@ -1,11 +1,10 @@
|
||||
use activitystreams_types::activity::Create;
|
||||
use heck::KebabCase;
|
||||
use rocket::request::Form;
|
||||
use rocket::response::Redirect;
|
||||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{broadcast, context, activity_pub, ActivityPub, Id};
|
||||
use activity_pub::{broadcast, context, activity_pub, ActivityPub};
|
||||
use activity_pub::object::Object;
|
||||
use db_conn::DbConn;
|
||||
use models::blogs::*;
|
||||
@@ -38,7 +37,7 @@ fn details(blog: String, slug: String, conn: DbConn, user: Option<User>) -> Temp
|
||||
|
||||
#[get("/~/<_blog>/<slug>", rank = 3, format = "application/activity+json")]
|
||||
fn activity_details(_blog: String, slug: String, conn: DbConn) -> ActivityPub {
|
||||
// TODO: posts in different blogs may have the same slug
|
||||
// FIXME: posts in different blogs may have the same slug
|
||||
let post = Post::find_by_slug(&*conn, slug).unwrap();
|
||||
|
||||
let mut act = post.serialize(&*conn);
|
||||
@@ -85,12 +84,8 @@ fn create(blog_name: String, data: Form<NewPostForm>, user: User, conn: DbConn)
|
||||
author_id: user.id
|
||||
});
|
||||
|
||||
// TODO: use Post -> Create conversion
|
||||
// let act = Create::default();
|
||||
// act.object_props.set_id_string(format!("{}/activity", post.compute_id(&*conn)));
|
||||
// act.set_actor_link(Id::new(user.ap_url));
|
||||
// act.set_object_object();
|
||||
// broadcast(&*conn, &user, act, user.get_followers(&*conn));
|
||||
let act = post.create_activity(&*conn);
|
||||
broadcast(&*conn, &user, act, user.get_followers(&*conn));
|
||||
|
||||
Redirect::to(format!("/~/{}/{}", blog_name, slug).as_str())
|
||||
}
|
||||
|
||||
+5
-3
@@ -7,7 +7,7 @@ use rocket::response::Redirect;
|
||||
use rocket_contrib::Template;
|
||||
use serde_json;
|
||||
|
||||
use activity_pub::{activity_pub, ActivityPub, ActivityStream, context, broadcast};
|
||||
use activity_pub::{activity_pub, ActivityPub, ActivityStream, context, broadcast, Id, IntoId};
|
||||
use activity_pub::actor::Actor;
|
||||
use activity_pub::inbox::Inbox;
|
||||
use db_conn::DbConn;
|
||||
@@ -56,8 +56,10 @@ fn follow(name: String, conn: DbConn, user: User) -> Redirect {
|
||||
follower_id: user.id,
|
||||
following_id: target.id
|
||||
});
|
||||
let act = Follow::default();
|
||||
// TODO
|
||||
let mut act = Follow::default();
|
||||
act.set_actor_link::<Id>(user.clone().into_id()).unwrap();
|
||||
act.set_object_object(user.into_activity(&*conn)).unwrap();
|
||||
act.object_props.set_id_string(format!("{}/follow/{}", user.ap_url, target.ap_url)).unwrap();
|
||||
broadcast(&*conn, &user, act, vec![target]);
|
||||
Redirect::to(format!("/@/{}", name).as_ref())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user