mirror of
https://git.joinplu.me/Plume/Plume.git
synced 2025-06-05 13:38:49 +00:00
Define Instance::set_keypair()
This commit is contained in:
parent
64f0333497
commit
218bc54a5f
1 changed files with 14 additions and 0 deletions
|
@ -242,6 +242,20 @@ impl Instance {
|
||||||
})
|
})
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_keypair(&self, conn: &Connection) -> Result<()> {
|
||||||
|
let (pub_key, priv_key) = gen_keypair();
|
||||||
|
let private_key = String::from_utf8(priv_key).or(Err(Error::Signature))?;
|
||||||
|
let public_key = String::from_utf8(pub_key).or(Err(Error::Signature))?;
|
||||||
|
diesel::update(self)
|
||||||
|
.set((
|
||||||
|
instances::private_key.eq(Some(private_key)),
|
||||||
|
instances::public_key.eq(Some(public_key)),
|
||||||
|
))
|
||||||
|
.execute(conn)
|
||||||
|
.and(Ok(()))
|
||||||
|
.map_err(Error::from)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl NewInstance {
|
impl NewInstance {
|
||||||
|
|
Loading…
Reference in a new issue