Add a button to write a new article
This commit is contained in:
@@ -35,6 +35,8 @@ use activity_pub::{
|
||||
};
|
||||
use db_conn::DbConn;
|
||||
use models::{
|
||||
blogs::Blog,
|
||||
blog_authors::BlogAuthor,
|
||||
comments::Comment,
|
||||
follows::Follow,
|
||||
instance::Instance,
|
||||
@@ -297,6 +299,15 @@ impl User {
|
||||
.len() > 0
|
||||
}
|
||||
|
||||
pub fn is_author_in(&self, conn: &PgConnection, blog: Blog) -> bool {
|
||||
use schema::blog_authors;
|
||||
blog_authors::table.filter(blog_authors::author_id.eq(self.id))
|
||||
.filter(blog_authors::blog_id.eq(blog.id))
|
||||
.load::<BlogAuthor>(conn)
|
||||
.expect("Couldn't load blog/author relationship")
|
||||
.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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user