]> Untitled Git - lemmy.git/commitdiff
Merge branch 'main' into move_matrix_and_admin_to_person
authorDessalines <tyhou13@gmx.com>
Tue, 23 Mar 2021 18:16:54 +0000 (14:16 -0400)
committerDessalines <tyhou13@gmx.com>
Tue, 23 Mar 2021 18:16:54 +0000 (14:16 -0400)
1  2 
crates/api/src/comment.rs
crates/api/src/local_user.rs
crates/api/src/post.rs

index 61f9a7040e44744bbbb51ac004e89305c68304c1,bcee72b0942a45dcb7224b6881df1401c614f01c..78bb484f9d0ece58590ff37a62c80d48d31421ee
@@@ -85,7 -85,13 +85,7 @@@ impl Perform for CreateComment 
        parent_id: data.parent_id.to_owned(),
        post_id: data.post_id,
        creator_id: local_user_view.person.id,
 -      removed: None,
 -      deleted: None,
 -      read: None,
 -      published: None,
 -      updated: None,
 -      ap_id: None,
 -      local: true,
 +      ..CommentForm::default()
      };
  
      // Create the comment
@@@ -684,12 -690,14 +684,14 @@@ impl Perform for GetComments 
  
      let community_id = data.community_id;
      let community_name = data.community_name.to_owned();
+     let saved_only = data.saved_only;
      let page = data.page;
      let limit = data.limit;
      let comments = blocking(context.pool(), move |conn| {
        CommentQueryBuilder::create(conn)
          .listing_type(type_)
          .sort(&sort)
+         .saved_only(saved_only)
          .community_id(community_id)
          .community_name(community_name)
          .my_person_id(person_id)
index 5fbbdeec4561d3f25269c7832a745afb9bad355c,6aa8b26c96faa4c24563e67e19f52ac4f56a2fc9..20e7ff979545232a5dbddfa7a7e5719fc6d5b7f6
@@@ -199,13 -199,21 +199,13 @@@ impl Perform for Register 
      // Register the new person
      let person_form = PersonForm {
        name: data.username.to_owned(),
 -      avatar: None,
 -      banner: None,
 -      preferred_username: None,
 -      published: None,
 -      updated: None,
 -      banned: None,
 -      deleted: None,
        actor_id: Some(actor_id.clone()),
 -      bio: None,
 -      local: Some(true),
        private_key: Some(Some(actor_keypair.private_key)),
        public_key: Some(Some(actor_keypair.public_key)),
 -      last_refreshed_at: None,
        inbox_url: Some(generate_inbox_url(&actor_id)?),
        shared_inbox_url: Some(Some(generate_shared_inbox_url(&actor_id)?)),
 +      admin: Some(no_admins),
 +      ..PersonForm::default()
      };
  
      // insert the person
      let local_user_form = LocalUserForm {
        person_id: inserted_person.id,
        email: Some(data.email.to_owned()),
 -      matrix_user_id: None,
        password_encrypted: data.password.to_owned(),
 -      admin: Some(no_admins),
        show_nsfw: Some(data.show_nsfw),
        theme: Some("browser".into()),
        default_sort_type: Some(SortType::Active as i16),
            name: default_community_name.to_string(),
            title: "The Default Community".to_string(),
            description: Some("The Default Community".to_string()),
 -          nsfw: false,
            creator_id: inserted_person.id,
 -          removed: None,
 -          deleted: None,
 -          updated: None,
            actor_id: Some(actor_id.to_owned()),
 -          local: true,
            private_key: Some(main_community_keypair.private_key),
            public_key: Some(main_community_keypair.public_key),
 -          last_refreshed_at: None,
 -          published: None,
 -          icon: None,
 -          banner: None,
            followers_url: Some(generate_followers_url(&actor_id)?),
            inbox_url: Some(generate_inbox_url(&actor_id)?),
            shared_inbox_url: Some(Some(generate_shared_inbox_url(&actor_id)?)),
 +          ..CommunityForm::default()
          };
          blocking(context.pool(), move |conn| {
            Community::create(conn, &community_form)
@@@ -455,12 -473,10 +455,12 @@@ impl Perform for SaveUserSettings 
        actor_id: None,
        bio,
        local: None,
 +      admin: None,
        private_key: None,
        public_key: None,
        last_refreshed_at: None,
        shared_inbox_url: None,
 +      matrix_user_id,
      };
  
      let person_res = blocking(context.pool(), move |conn| {
      let local_user_form = LocalUserForm {
        person_id,
        email,
 -      matrix_user_id,
        password_encrypted,
 -      admin: None,
        show_nsfw: data.show_nsfw,
        theme: data.theme.to_owned(),
        default_sort_type,
@@@ -578,6 -596,7 +578,7 @@@ impl Perform for GetPersonDetails 
          .my_person_id(person_id)
          .sort(&sort)
          .saved_only(saved_only)
+         .community_id(community_id)
          .page(page)
          .limit(limit);
  
@@@ -638,7 -657,7 +639,7 @@@ impl Perform for AddAdmin 
      let added = data.added;
      let added_person_id = data.person_id;
      let added_admin = match blocking(context.pool(), move |conn| {
 -      LocalUser::add_admin(conn, added_person_id, added)
 +      Person::add_admin(conn, added_person_id, added)
      })
      .await?
      {
      // Mod tables
      let form = ModAddForm {
        mod_person_id: local_user_view.person.id,
 -      other_person_id: added_admin.person_id,
 +      other_person_id: added_admin.id,
        removed: Some(!data.added),
      };
  
@@@ -1083,7 -1102,12 +1084,7 @@@ impl Perform for CreatePrivateMessage 
        content: content_slurs_removed.to_owned(),
        creator_id: local_user_view.person.id,
        recipient_id: data.recipient_id,
 -      deleted: None,
 -      read: None,
 -      updated: None,
 -      ap_id: None,
 -      local: true,
 -      published: None,
 +      ..PrivateMessageForm::default()
      };
  
      let inserted_private_message = match blocking(context.pool(), move |conn| {
diff --combined crates/api/src/post.rs
index 48153a86b9d8a5455d2be9c95abd2911c9d38613,bbc3e04bb0e9497e7fd4bc74bbacee908042c7b1..e76cfa18f644513e0c2e4ee248f31f22374fcf89
@@@ -82,12 -82,19 +82,12 @@@ impl Perform for CreatePost 
        body: data.body.to_owned(),
        community_id: data.community_id,
        creator_id: local_user_view.person.id,
 -      removed: None,
 -      deleted: None,
        nsfw: data.nsfw,
 -      locked: None,
 -      stickied: None,
 -      updated: None,
        embed_title: iframely_title,
        embed_description: iframely_description,
        embed_html: iframely_html,
        thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
 -      ap_id: None,
 -      local: true,
 -      published: None,
 +      ..PostForm::default()
      };
  
      let inserted_post =
@@@ -253,6 -260,8 +253,8 @@@ impl Perform for GetPosts 
      let limit = data.limit;
      let community_id = data.community_id;
      let community_name = data.community_name.to_owned();
+     let saved_only = data.saved_only;
      let posts = match blocking(context.pool(), move |conn| {
        PostQueryBuilder::create(conn)
          .listing_type(&type_)
          .show_nsfw(show_nsfw)
          .community_id(community_id)
          .community_name(community_name)
+         .saved_only(saved_only)
          .my_person_id(person_id)
          .page(page)
          .limit(limit)
@@@ -392,18 -402,24 +395,18 @@@ impl Perform for EditPost 
        fetch_iframely_and_pictrs_data(context.client(), data_url).await;
  
      let post_form = PostForm {
 +      creator_id: orig_post.creator_id.to_owned(),
 +      community_id: orig_post.community_id,
        name: data.name.trim().to_owned(),
        url: data_url.map(|u| u.to_owned().into()),
        body: data.body.to_owned(),
        nsfw: data.nsfw,
 -      creator_id: orig_post.creator_id.to_owned(),
 -      community_id: orig_post.community_id,
 -      removed: Some(orig_post.removed),
 -      deleted: Some(orig_post.deleted),
 -      locked: Some(orig_post.locked),
 -      stickied: Some(orig_post.stickied),
        updated: Some(naive_now()),
        embed_title: iframely_title,
        embed_description: iframely_description,
        embed_html: iframely_html,
        thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
 -      ap_id: Some(orig_post.ap_id),
 -      local: orig_post.local,
 -      published: None,
 +      ..PostForm::default()
      };
  
      let post_id = data.post_id;