Add a route to reshare posts

This commit is contained in:
Bat
2018-05-19 10:51:10 +01:00
parent 0ac3cb4c0f
commit 63eb1a7e98
5 changed files with 103 additions and 8 deletions
+11
View File
@@ -287,6 +287,17 @@ impl User {
.len() > 0
}
pub fn has_reshared(&self, conn: &PgConnection, post: &Post) -> bool {
use schema::reshares;
use models::reshares::Reshare;
reshares::table
.filter(reshares::post_id.eq(post.id))
.filter(reshares::user_id.eq(self.id))
.load::<Reshare>(conn)
.expect("Couldn't load reshares")
.len() > 0
}
pub fn get_keypair(&self) -> PKey<Private> {
PKey::from_rsa(Rsa::private_key_from_pem(self.private_key.clone().unwrap().as_ref()).unwrap()).unwrap()
}