From 2fcb449ed88a4bcd2d694afd18b1bfc043829af3 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sat, 11 Sep 2021 23:06:02 +0900 Subject: [PATCH] Define plume_models::migrate_data() --- plume-models/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index a3d10755..f5009adc 100755 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -17,6 +17,8 @@ extern crate serde_json; #[macro_use] extern crate tantivy; +use db_conn::DbPool; +use instance::Instance; use once_cell::sync::Lazy; use plume_common::activity_pub::inbox::InboxError; use posts::PostEvent; @@ -295,6 +297,15 @@ pub fn ap_url(url: &str) -> String { format!("https://{}", url) } +pub fn migrate_data(dbpool: &DbPool) -> Result<()> { + ensure_local_instance_keys(&dbpool.get().unwrap()) +} + +fn ensure_local_instance_keys(conn: &Connection) -> Result<()> { + let instance = Instance::get_local()?; + instance.set_keypair(conn) +} + #[cfg(test)] #[macro_use] mod tests {