Receive likes with ActivityPub

This commit is contained in:
Bat
2018-05-10 17:07:23 +01:00
parent 7b5f0f1704
commit ac7b4441e8
2 changed files with 25 additions and 9 deletions
+11 -2
View File
@@ -6,8 +6,9 @@ use activity_pub::actor::Actor;
use activity_pub::sign::*;
use models::blogs::Blog;
use models::comments::*;
use models::follows::{Follow, NewFollow};
use models::posts::{Post, NewPost};
use models::follows::*;
use models::likes::*;
use models::posts::*;
use models::users::User;
pub trait Inbox: Actor + Sized {
@@ -58,6 +59,14 @@ pub trait Inbox: Actor + Sized {
// TODO: notification
}
"Like" => {
let liker = User::from_url(conn, act["actor"].as_str().unwrap().to_string());
let post = Post::get_by_ap_url(conn, act["object"].as_str().unwrap().to_string());
Like::insert(conn, NewLike {
post_id: post.unwrap().id,
user_id: liker.unwrap().id
});
},
x => println!("Received unknow activity type: {}", x)
}
}