]> Untitled Git - lemmy.git/blobdiff - src/code_migrations.rs
Making public key required. Fixes #1934
[lemmy.git] / src / code_migrations.rs
index 1f9381986e954fd6486665d3dd8ea7ff663c5236..b7c43508be15e2103c8d0083dc812cf757e57392 100644 (file)
@@ -4,16 +4,12 @@ use diesel::{
   *,
 };
 use lemmy_apub::{
-  generate_apub_endpoint,
   generate_followers_url,
   generate_inbox_url,
+  generate_local_apub_endpoint,
   generate_shared_inbox_url,
   EndpointType,
 };
-use lemmy_db_queries::{
-  source::{comment::Comment_, post::Post_, private_message::PrivateMessage_},
-  Crud,
-};
 use lemmy_db_schema::{
   naive_now,
   source::{
@@ -23,6 +19,7 @@ use lemmy_db_schema::{
     post::Post,
     private_message::PrivateMessage,
   },
+  traits::Crud,
 };
 use lemmy_utils::{apub::generate_actor_keypair, LemmyError};
 use log::info;
@@ -61,13 +58,13 @@ fn user_updates_2020_04_02(
 
     let form = PersonForm {
       name: cperson.name.to_owned(),
-      actor_id: Some(generate_apub_endpoint(
+      actor_id: Some(generate_local_apub_endpoint(
         EndpointType::Person,
         &cperson.name,
         protocol_and_hostname,
       )?),
       private_key: Some(Some(keypair.private_key)),
-      public_key: Some(Some(keypair.public_key)),
+      public_key: keypair.public_key,
       last_refreshed_at: Some(naive_now()),
       ..PersonForm::default()
     };
@@ -96,7 +93,7 @@ fn community_updates_2020_04_02(
 
   for ccommunity in &incorrect_communities {
     let keypair = generate_actor_keypair()?;
-    let community_actor_id = generate_apub_endpoint(
+    let community_actor_id = generate_local_apub_endpoint(
       EndpointType::Community,
       &ccommunity.name,
       protocol_and_hostname,
@@ -112,8 +109,8 @@ fn community_updates_2020_04_02(
       updated: None,
       actor_id: Some(community_actor_id.to_owned()),
       local: Some(ccommunity.local),
-      private_key: Some(keypair.private_key),
-      public_key: Some(keypair.public_key),
+      private_key: Some(Some(keypair.private_key)),
+      public_key: keypair.public_key,
       last_refreshed_at: Some(naive_now()),
       published: None,
       icon: Some(ccommunity.icon.to_owned()),
@@ -146,7 +143,7 @@ fn post_updates_2020_04_03(
     .load::<Post>(conn)?;
 
   for cpost in &incorrect_posts {
-    let apub_id = generate_apub_endpoint(
+    let apub_id = generate_local_apub_endpoint(
       EndpointType::Post,
       &cpost.id.to_string(),
       protocol_and_hostname,
@@ -174,7 +171,7 @@ fn comment_updates_2020_04_03(
     .load::<Comment>(conn)?;
 
   for ccomment in &incorrect_comments {
-    let apub_id = generate_apub_endpoint(
+    let apub_id = generate_local_apub_endpoint(
       EndpointType::Comment,
       &ccomment.id.to_string(),
       protocol_and_hostname,
@@ -202,7 +199,7 @@ fn private_message_updates_2020_05_05(
     .load::<PrivateMessage>(conn)?;
 
   for cpm in &incorrect_pms {
-    let apub_id = generate_apub_endpoint(
+    let apub_id = generate_local_apub_endpoint(
       EndpointType::PrivateMessage,
       &cpm.id.to_string(),
       protocol_and_hostname,