// 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)
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,
.my_person_id(person_id)
.sort(&sort)
.saved_only(saved_only)
+ .community_id(community_id)
.page(page)
.limit(limit);
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),
};
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| {
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 =
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)
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;