Fix local notifications
This commit is contained in:
@@ -86,7 +86,7 @@ impl Instance {
|
||||
|
||||
impl Inbox for Instance {
|
||||
fn received(&self, conn: &PgConnection, act: serde_json::Value) {
|
||||
self.save(conn, act.clone()).unwrap();
|
||||
self.save(conn, act.clone()).expect("Shared Inbox: Couldn't save activity");
|
||||
|
||||
// TODO: add to stream, or whatever needs to be done
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use rocket::{
|
||||
};
|
||||
use rocket_contrib::Template;
|
||||
|
||||
use activity_pub::broadcast;
|
||||
use activity_pub::{broadcast, IntoId, inbox::Notify};
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
comments::*,
|
||||
@@ -53,6 +53,7 @@ fn create(blog: String, slug: String, query: CommentQuery, data: Form<NewComment
|
||||
spoiler_text: "".to_string()
|
||||
});
|
||||
|
||||
Comment::notify(&*conn, comment.into_activity(&*conn), user.clone().into_id());
|
||||
broadcast(&*conn, &user, comment.create_activity(&*conn), user.get_followers(&*conn));
|
||||
|
||||
Redirect::to(format!("/~/{}/{}/#comment-{}", blog, slug, comment.id))
|
||||
|
||||
+5
-4
@@ -1,6 +1,6 @@
|
||||
use rocket::response::{Redirect, Flash};
|
||||
|
||||
use activity_pub::broadcast;
|
||||
use activity_pub::{broadcast, IntoId, inbox::Notify};
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
likes,
|
||||
@@ -16,12 +16,13 @@ fn create(blog: String, slug: String, user: User, conn: DbConn) -> Redirect {
|
||||
|
||||
if !user.has_liked(&*conn, &post) {
|
||||
let like = likes::Like::insert(&*conn, likes::NewLike {
|
||||
post_id: post.id,
|
||||
user_id: user.id,
|
||||
ap_url: "".to_string()
|
||||
post_id: post.id,
|
||||
user_id: user.id,
|
||||
ap_url: "".to_string()
|
||||
});
|
||||
like.update_ap_url(&*conn);
|
||||
|
||||
likes::Like::notify(&*conn, like.into_activity(&*conn), user.clone().into_id());
|
||||
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();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rocket::response::{Redirect, Flash};
|
||||
|
||||
use activity_pub::broadcast;
|
||||
use activity_pub::{broadcast, IntoId, inbox::Notify};
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
posts::Post,
|
||||
@@ -22,6 +22,7 @@ fn create(blog: String, slug: String, user: User, conn: DbConn) -> Redirect {
|
||||
});
|
||||
reshare.update_ap_url(&*conn);
|
||||
|
||||
Reshare::notify(&*conn, reshare.into_activity(&*conn), user.clone().into_id());
|
||||
broadcast(&*conn, &user, reshare.into_activity(&*conn), user.get_followers(&*conn));
|
||||
} else {
|
||||
let reshare = Reshare::find_by_user_on_post(&*conn, &user, &post).unwrap();
|
||||
|
||||
+3
-1
@@ -10,7 +10,7 @@ use serde_json;
|
||||
|
||||
use activity_pub::{
|
||||
activity_pub, ActivityPub, ActivityStream, context, broadcast, Id, IntoId,
|
||||
inbox::Inbox,
|
||||
inbox::{Inbox, Notify},
|
||||
actor::Actor
|
||||
};
|
||||
use db_conn::DbConn;
|
||||
@@ -103,6 +103,8 @@ fn follow(name: String, conn: DbConn, user: User) -> Redirect {
|
||||
act.follow_props.set_actor_link::<Id>(user.clone().into_id()).unwrap();
|
||||
act.follow_props.set_object_object(user.into_activity(&*conn)).unwrap();
|
||||
act.object_props.set_id_string(format!("{}/follow/{}", user.ap_url, target.ap_url)).unwrap();
|
||||
|
||||
follows::Follow::notify(&*conn, act.clone(), user.clone().into_id());
|
||||
broadcast(&*conn, &user, act, vec![target]);
|
||||
Redirect::to(format!("/@/{}/", name))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user