Merge pull request #1516 from LemmyNet/move_matrix_and_admin_to_person
Move matrix and admin to person
This commit is contained in:
commit
6ee76e9280
50 changed files with 260 additions and 1039 deletions
12
.drone.yml
12
.drone.yml
|
@ -21,13 +21,7 @@ steps:
|
|||
|
||||
- name: cargo clippy
|
||||
image: ekidd/rust-musl-builder:1.50.0
|
||||
environment:
|
||||
CARGO_HOME: /drone/src/.cargo
|
||||
commands:
|
||||
- whoami
|
||||
- ls -la ~/.cargo
|
||||
- mv ~/.cargo .
|
||||
- ls -la .cargo
|
||||
- cargo clippy --workspace --tests --all-targets --all-features -- -D warnings -D deprecated -D clippy::perf -D clippy::complexity -D clippy::dbg_macro
|
||||
- cargo clippy --workspace -- -D clippy::unwrap_used
|
||||
|
||||
|
@ -37,7 +31,6 @@ steps:
|
|||
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
||||
RUST_BACKTRACE: 1
|
||||
RUST_TEST_THREADS: 1
|
||||
CARGO_HOME: /drone/src/.cargo
|
||||
commands:
|
||||
- sudo apt-get update
|
||||
- sudo apt-get -y install --no-install-recommends espeak postgresql-client
|
||||
|
@ -45,8 +38,6 @@ steps:
|
|||
|
||||
- name: cargo build
|
||||
image: ekidd/rust-musl-builder:1.50.0
|
||||
environment:
|
||||
CARGO_HOME: /drone/src/.cargo
|
||||
commands:
|
||||
- cargo build
|
||||
- mv target/x86_64-unknown-linux-musl/debug/lemmy_server target/lemmy_server
|
||||
|
@ -118,7 +109,6 @@ steps:
|
|||
LEMMY_DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
|
||||
RUST_BACKTRACE: 1
|
||||
RUST_TEST_THREADS: 1
|
||||
CARGO_HOME: /drone/src/.cargo
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get -y install --no-install-recommends espeak postgresql-client libssl-dev pkg-config libpq-dev
|
||||
|
@ -128,8 +118,6 @@ steps:
|
|||
# Using Debian here because there seems to be no official Alpine-based Rust docker image for ARM.
|
||||
- name: cargo build
|
||||
image: rust:1.50-slim-buster
|
||||
environment:
|
||||
CARGO_HOME: /drone/src/.cargo
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get -y install --no-install-recommends libssl-dev pkg-config libpq-dev
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -170,19 +170,14 @@ impl Perform for CreateCommunity {
|
|||
icon,
|
||||
banner,
|
||||
creator_id: local_user_view.person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
nsfw: data.nsfw,
|
||||
updated: None,
|
||||
actor_id: Some(community_actor_id.to_owned()),
|
||||
local: true,
|
||||
private_key: Some(keypair.private_key),
|
||||
public_key: Some(keypair.public_key),
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
followers_url: Some(generate_followers_url(&community_actor_id)?),
|
||||
inbox_url: Some(generate_inbox_url(&community_actor_id)?),
|
||||
shared_inbox_url: Some(Some(generate_shared_inbox_url(&community_actor_id)?)),
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = match blocking(context.pool(), move |conn| {
|
||||
|
@ -265,23 +260,13 @@ impl Perform for EditCommunity {
|
|||
let community_form = CommunityForm {
|
||||
name: read_community.name,
|
||||
title: data.title.to_owned(),
|
||||
creator_id: read_community.creator_id,
|
||||
description: data.description.to_owned(),
|
||||
icon,
|
||||
banner,
|
||||
creator_id: read_community.creator_id,
|
||||
removed: Some(read_community.removed),
|
||||
deleted: Some(read_community.deleted),
|
||||
nsfw: data.nsfw,
|
||||
updated: Some(naive_now()),
|
||||
actor_id: Some(read_community.actor_id),
|
||||
local: read_community.local,
|
||||
private_key: read_community.private_key,
|
||||
public_key: read_community.public_key,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let community_id = data.community_id;
|
||||
|
|
|
@ -79,7 +79,7 @@ pub(crate) async fn is_mod_or_admin(
|
|||
}
|
||||
|
||||
pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> {
|
||||
if !local_user_view.local_user.admin {
|
||||
if !local_user_view.person.admin {
|
||||
return Err(ApiError::err("not_an_admin").into());
|
||||
}
|
||||
Ok(())
|
||||
|
@ -528,38 +528,15 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "Gerry9812".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let local_user_form = LocalUserForm {
|
||||
person_id: inserted_person.id,
|
||||
email: None,
|
||||
matrix_user_id: None,
|
||||
password_encrypted: "123456".to_string(),
|
||||
admin: None,
|
||||
show_nsfw: None,
|
||||
theme: None,
|
||||
default_sort_type: None,
|
||||
default_listing_type: None,
|
||||
lang: None,
|
||||
show_avatars: None,
|
||||
send_notifications_to_email: None,
|
||||
..LocalUserForm::default()
|
||||
};
|
||||
|
||||
let inserted_local_user = LocalUser::create(&conn, &local_user_form).unwrap();
|
||||
|
|
|
@ -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
|
||||
|
@ -232,9 +224,7 @@ impl Perform for Register {
|
|||
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),
|
||||
|
@ -285,22 +275,14 @@ impl Perform for Register {
|
|||
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)
|
||||
|
@ -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| {
|
||||
|
@ -493,9 +477,7 @@ impl Perform for SaveUserSettings {
|
|||
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,
|
||||
|
@ -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?
|
||||
{
|
||||
|
@ -670,7 +652,7 @@ impl Perform for AddAdmin {
|
|||
// 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),
|
||||
};
|
||||
|
||||
|
@ -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| {
|
||||
|
|
|
@ -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 =
|
||||
|
@ -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;
|
||||
|
|
|
@ -28,7 +28,7 @@ pub struct CreateCommunity {
|
|||
pub description: Option<String>,
|
||||
pub icon: Option<String>,
|
||||
pub banner: Option<String>,
|
||||
pub nsfw: bool,
|
||||
pub nsfw: Option<bool>,
|
||||
pub auth: String,
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ pub struct EditCommunity {
|
|||
pub description: Option<String>,
|
||||
pub icon: Option<String>,
|
||||
pub banner: Option<String>,
|
||||
pub nsfw: bool,
|
||||
pub nsfw: Option<bool>,
|
||||
pub auth: String,
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,11 @@ pub(crate) fn lemmy_context() -> Result<Vec<AnyBase>, LemmyError> {
|
|||
"type": "sc:Boolean",
|
||||
"id": "pt:commentsEnabled"
|
||||
},
|
||||
"moderators": "as:moderators"
|
||||
"moderators": "as:moderators",
|
||||
"matrixUserId": {
|
||||
"type": "sc:Text",
|
||||
"id": "as:alsoKnownAs"
|
||||
},
|
||||
}))?;
|
||||
Ok(vec![
|
||||
AnyBase::from(context()),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
pub(crate) mod context;
|
||||
pub(crate) mod group_extensions;
|
||||
pub(crate) mod group_extension;
|
||||
pub(crate) mod page_extension;
|
||||
pub(crate) mod person_extension;
|
||||
pub(crate) mod signatures;
|
||||
|
|
36
crates/apub/src/extensions/person_extension.rs
Normal file
36
crates/apub/src/extensions/person_extension.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use activitystreams::unparsed::UnparsedMutExt;
|
||||
use activitystreams_ext::UnparsedExtension;
|
||||
use lemmy_utils::LemmyError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Activitystreams extension to allow (de)serializing additional Person field
|
||||
/// `also_known_as` (used for Matrix profile link).
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PersonExtension {
|
||||
pub matrix_user_id: Option<String>,
|
||||
}
|
||||
|
||||
impl PersonExtension {
|
||||
pub fn new(matrix_user_id: Option<String>) -> Result<PersonExtension, LemmyError> {
|
||||
Ok(PersonExtension { matrix_user_id })
|
||||
}
|
||||
}
|
||||
|
||||
impl<U> UnparsedExtension<U> for PersonExtension
|
||||
where
|
||||
U: UnparsedMutExt,
|
||||
{
|
||||
type Error = serde_json::Error;
|
||||
|
||||
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
|
||||
Ok(PersonExtension {
|
||||
matrix_user_id: unparsed_mut.remove("matrix_user_id")?,
|
||||
})
|
||||
}
|
||||
|
||||
fn try_into_unparsed(self, unparsed_mut: &mut U) -> Result<(), Self::Error> {
|
||||
unparsed_mut.insert("matrix_user_id", self.matrix_user_id)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
|
@ -11,8 +11,9 @@ pub mod objects;
|
|||
pub mod routes;
|
||||
|
||||
use crate::extensions::{
|
||||
group_extensions::GroupExtension,
|
||||
group_extension::GroupExtension,
|
||||
page_extension::PageExtension,
|
||||
person_extension::PersonExtension,
|
||||
signatures::{PublicKey, PublicKeyExtension},
|
||||
};
|
||||
use activitystreams::{
|
||||
|
@ -46,7 +47,7 @@ use url::{ParseError, Url};
|
|||
/// Activitystreams type for community
|
||||
type GroupExt = Ext2<actor::ApActor<ApObject<actor::Group>>, GroupExtension, PublicKeyExtension>;
|
||||
/// Activitystreams type for person
|
||||
type PersonExt = Ext1<actor::ApActor<ApObject<actor::Person>>, PublicKeyExtension>;
|
||||
type PersonExt = Ext2<actor::ApActor<ApObject<actor::Person>>, PersonExtension, PublicKeyExtension>;
|
||||
/// Activitystreams type for post
|
||||
type PageExt = Ext1<ApObject<Page>, PageExtension>;
|
||||
type NoteExt = ApObject<Note>;
|
||||
|
|
|
@ -203,7 +203,7 @@ impl FromApubToForm<NoteExt> for CommentForm {
|
|||
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
||||
deleted: None,
|
||||
ap_id: Some(check_object_domain(note, expected_domain)?),
|
||||
local: false,
|
||||
local: Some(false),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
extensions::{context::lemmy_context, group_extensions::GroupExtension},
|
||||
extensions::{context::lemmy_context, group_extension::GroupExtension},
|
||||
fetcher::{community::fetch_community_mods, person::get_or_fetch_and_upsert_person},
|
||||
generate_moderators_url,
|
||||
objects::{
|
||||
|
@ -220,9 +220,9 @@ impl FromApubToForm<GroupExt> for CommunityForm {
|
|||
published: group.inner.published().map(|u| u.to_owned().naive_local()),
|
||||
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
||||
deleted: None,
|
||||
nsfw: group.ext_one.sensitive.unwrap_or(false),
|
||||
nsfw: Some(group.ext_one.sensitive.unwrap_or(false)),
|
||||
actor_id: Some(check_object_domain(group, expected_domain)?),
|
||||
local: false,
|
||||
local: Some(false),
|
||||
private_key: None,
|
||||
public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
extensions::context::lemmy_context,
|
||||
extensions::{context::lemmy_context, person_extension::PersonExtension},
|
||||
objects::{
|
||||
check_object_domain,
|
||||
get_source_markdown_value,
|
||||
|
@ -16,7 +16,7 @@ use activitystreams::{
|
|||
object::{ApObject, Image, Tombstone},
|
||||
prelude::*,
|
||||
};
|
||||
use activitystreams_ext::Ext1;
|
||||
use activitystreams_ext::Ext2;
|
||||
use anyhow::Context;
|
||||
use lemmy_api_structs::blocking;
|
||||
use lemmy_db_queries::{ApubObject, DbPool};
|
||||
|
@ -77,7 +77,8 @@ impl ToApub for DbPerson {
|
|||
..Default::default()
|
||||
});
|
||||
|
||||
Ok(Ext1::new(ap_actor, self.get_public_key_ext()?))
|
||||
let person_ext = PersonExtension::new(self.matrix_user_id.to_owned())?;
|
||||
Ok(Ext2::new(ap_actor, person_ext, self.get_public_key_ext()?))
|
||||
}
|
||||
fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
|
||||
unimplemented!()
|
||||
|
@ -190,11 +191,13 @@ impl FromApubToForm<PersonExt> for PersonForm {
|
|||
actor_id: Some(check_object_domain(person, expected_domain)?),
|
||||
bio: Some(bio),
|
||||
local: Some(false),
|
||||
admin: Some(false),
|
||||
private_key: None,
|
||||
public_key: Some(Some(person.ext_one.public_key.to_owned().public_key_pem)),
|
||||
public_key: Some(Some(person.ext_two.public_key.to_owned().public_key_pem)),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: Some(person.inner.inbox()?.to_owned().into()),
|
||||
shared_inbox_url: Some(shared_inbox),
|
||||
matrix_user_id: Some(person.ext_one.matrix_user_id.to_owned()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -238,7 +238,7 @@ impl FromApubToForm<PageExt> for PostForm {
|
|||
embed_html: iframely_html,
|
||||
thumbnail_url: pictrs_thumbnail.map(|u| u.into()),
|
||||
ap_id: Some(ap_id),
|
||||
local: false,
|
||||
local: Some(false),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@ impl FromApubToForm<NoteExt> for PrivateMessageForm {
|
|||
deleted: None,
|
||||
read: None,
|
||||
ap_id: Some(check_object_domain(note, expected_domain)?),
|
||||
local: false,
|
||||
local: Some(false),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,42 +44,14 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy_comment_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let another_person = PersonForm {
|
||||
name: "jerry_comment_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let another_inserted_person = Person::create(&conn, &another_person).unwrap();
|
||||
|
@ -88,45 +60,16 @@ mod tests {
|
|||
name: "TIL_comment_agg".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -135,14 +78,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -151,14 +87,8 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -48,42 +48,14 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy_community_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let another_person = PersonForm {
|
||||
name: "jerry_community_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let another_inserted_person = Person::create(&conn, &another_person).unwrap();
|
||||
|
@ -92,22 +64,7 @@ mod tests {
|
|||
name: "TIL_community_agg".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
@ -116,22 +73,7 @@ mod tests {
|
|||
name: "TIL_community_agg_2".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let another_inserted_community = Community::create(&conn, &another_community).unwrap();
|
||||
|
@ -162,23 +104,9 @@ mod tests {
|
|||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -187,14 +115,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -203,14 +124,8 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -44,42 +44,14 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy_user_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let another_person = PersonForm {
|
||||
name: "jerry_user_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let another_inserted_person = Person::create(&conn, &another_person).unwrap();
|
||||
|
@ -88,45 +60,16 @@ mod tests {
|
|||
name: "TIL_site_agg".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -143,14 +86,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -168,14 +104,8 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -48,42 +48,14 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy_community_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let another_person = PersonForm {
|
||||
name: "jerry_community_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let another_inserted_person = Person::create(&conn, &another_person).unwrap();
|
||||
|
@ -92,45 +64,16 @@ mod tests {
|
|||
name: "TIL_community_agg".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -139,14 +82,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -155,14 +91,8 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -42,21 +42,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy_site_agg".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -79,45 +65,16 @@ mod tests {
|
|||
name: "TIL_site_agg".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
// Insert two of those posts
|
||||
|
@ -128,14 +85,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
// Insert two of those comments
|
||||
|
@ -145,14 +95,8 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let _inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -74,7 +74,7 @@ impl Activity_ for Activity {
|
|||
let activity_form = ActivityForm {
|
||||
ap_id,
|
||||
data: serde_json::to_value(&data)?,
|
||||
local,
|
||||
local: Some(local),
|
||||
sensitive,
|
||||
updated: None,
|
||||
};
|
||||
|
@ -138,21 +138,7 @@ mod tests {
|
|||
|
||||
let creator_form = PersonForm {
|
||||
name: "activity_creator_pm".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_creator = Person::create(&conn, &creator_form).unwrap();
|
||||
|
@ -179,7 +165,7 @@ mod tests {
|
|||
let activity_form = ActivityForm {
|
||||
ap_id: ap_id.clone(),
|
||||
data: test_json.to_owned(),
|
||||
local: true,
|
||||
local: Some(true),
|
||||
sensitive: false,
|
||||
updated: None,
|
||||
};
|
||||
|
|
|
@ -246,21 +246,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "terry".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -268,23 +254,8 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: "test community".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
banner: None,
|
||||
icon: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
followers_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
@ -292,22 +263,8 @@ mod tests {
|
|||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
creator_id: inserted_person.id,
|
||||
url: None,
|
||||
body: None,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -316,14 +273,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -348,13 +298,7 @@ mod tests {
|
|||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
parent_id: Some(inserted_comment.id),
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_child_comment = Comment::create(&conn, &child_comment_form).unwrap();
|
||||
|
|
|
@ -356,21 +356,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "bobbee".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -379,22 +365,7 @@ mod tests {
|
|||
name: "TIL".into(),
|
||||
creator_id: inserted_person.id,
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
nsfw: false,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
|
|
@ -6,7 +6,6 @@ use lemmy_db_schema::{
|
|||
schema::local_user::dsl::*,
|
||||
source::local_user::{LocalUser, LocalUserForm},
|
||||
LocalUserId,
|
||||
PersonId,
|
||||
};
|
||||
|
||||
mod safe_settings_type {
|
||||
|
@ -17,7 +16,6 @@ mod safe_settings_type {
|
|||
id,
|
||||
person_id,
|
||||
email,
|
||||
admin,
|
||||
show_nsfw,
|
||||
theme,
|
||||
default_sort_type,
|
||||
|
@ -25,7 +23,6 @@ mod safe_settings_type {
|
|||
lang,
|
||||
show_avatars,
|
||||
send_notifications_to_email,
|
||||
matrix_user_id,
|
||||
validator_time,
|
||||
);
|
||||
|
||||
|
@ -38,7 +35,6 @@ mod safe_settings_type {
|
|||
id,
|
||||
person_id,
|
||||
email,
|
||||
admin,
|
||||
show_nsfw,
|
||||
theme,
|
||||
default_sort_type,
|
||||
|
@ -46,7 +42,6 @@ mod safe_settings_type {
|
|||
lang,
|
||||
show_avatars,
|
||||
send_notifications_to_email,
|
||||
matrix_user_id,
|
||||
validator_time,
|
||||
)
|
||||
}
|
||||
|
@ -60,7 +55,6 @@ pub trait LocalUser_ {
|
|||
local_user_id: LocalUserId,
|
||||
new_password: &str,
|
||||
) -> Result<LocalUser, Error>;
|
||||
fn add_admin(conn: &PgConnection, person_id: PersonId, added: bool) -> Result<LocalUser, Error>;
|
||||
}
|
||||
|
||||
impl LocalUser_ for LocalUser {
|
||||
|
@ -87,12 +81,6 @@ impl LocalUser_ for LocalUser {
|
|||
))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn add_admin(conn: &PgConnection, for_person_id: PersonId, added: bool) -> Result<Self, Error> {
|
||||
diesel::update(local_user.filter(person_id.eq(for_person_id)))
|
||||
.set(admin.eq(added))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
}
|
||||
|
||||
impl Crud<LocalUserForm, LocalUserId> for LocalUser {
|
||||
|
|
|
@ -209,42 +209,14 @@ mod tests {
|
|||
|
||||
let new_mod = PersonForm {
|
||||
name: "the mod".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_mod = Person::create(&conn, &new_mod).unwrap();
|
||||
|
||||
let new_person = PersonForm {
|
||||
name: "jim2".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -252,46 +224,17 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: "mod_community".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post thweep".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -300,14 +243,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
|
|
@ -95,21 +95,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "thommy prw".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -117,16 +103,7 @@ mod tests {
|
|||
let new_local_user = LocalUserForm {
|
||||
person_id: inserted_person.id,
|
||||
password_encrypted: "pass".to_string(),
|
||||
email: None,
|
||||
matrix_user_id: None,
|
||||
admin: None,
|
||||
show_nsfw: None,
|
||||
theme: None,
|
||||
default_sort_type: None,
|
||||
default_listing_type: None,
|
||||
lang: None,
|
||||
show_avatars: None,
|
||||
send_notifications_to_email: None,
|
||||
..LocalUserForm::default()
|
||||
};
|
||||
|
||||
let inserted_local_user = LocalUser::create(&conn, &new_local_user).unwrap();
|
||||
|
|
|
@ -27,6 +27,8 @@ mod safe_type {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
);
|
||||
|
||||
impl ToSafe for Person {
|
||||
|
@ -47,6 +49,8 @@ mod safe_type {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +75,8 @@ mod safe_type_alias_1 {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
);
|
||||
|
||||
impl ToSafe for PersonAlias1 {
|
||||
|
@ -91,6 +97,8 @@ mod safe_type_alias_1 {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +123,8 @@ mod safe_type_alias_2 {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
);
|
||||
|
||||
impl ToSafe for PersonAlias2 {
|
||||
|
@ -135,6 +145,8 @@ mod safe_type_alias_2 {
|
|||
deleted,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
matrix_user_id,
|
||||
admin,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +193,7 @@ impl ApubObject<PersonForm> for Person {
|
|||
|
||||
pub trait Person_ {
|
||||
fn ban_person(conn: &PgConnection, person_id: PersonId, ban: bool) -> Result<Person, Error>;
|
||||
fn add_admin(conn: &PgConnection, person_id: PersonId, added: bool) -> Result<Person, Error>;
|
||||
fn find_by_name(conn: &PgConnection, name: &str) -> Result<Person, Error>;
|
||||
fn mark_as_updated(conn: &PgConnection, person_id: PersonId) -> Result<Person, Error>;
|
||||
fn delete_account(conn: &PgConnection, person_id: PersonId) -> Result<Person, Error>;
|
||||
|
@ -193,6 +206,12 @@ impl Person_ for Person {
|
|||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn add_admin(conn: &PgConnection, person_id: PersonId, added: bool) -> Result<Self, Error> {
|
||||
diesel::update(person.find(person_id))
|
||||
.set(admin.eq(added))
|
||||
.get_result::<Self>(conn)
|
||||
}
|
||||
|
||||
fn find_by_name(conn: &PgConnection, from_name: &str) -> Result<Person, Error> {
|
||||
person
|
||||
.filter(deleted.eq(false))
|
||||
|
@ -212,16 +231,14 @@ impl Person_ for Person {
|
|||
|
||||
// Set the local user info to none
|
||||
diesel::update(local_user::table.filter(local_user::person_id.eq(person_id)))
|
||||
.set((
|
||||
local_user::email.eq::<Option<String>>(None),
|
||||
local_user::matrix_user_id.eq::<Option<String>>(None),
|
||||
))
|
||||
.set((local_user::email.eq::<Option<String>>(None),))
|
||||
.execute(conn)?;
|
||||
|
||||
diesel::update(person.find(person_id))
|
||||
.set((
|
||||
preferred_username.eq::<Option<String>>(None),
|
||||
bio.eq::<Option<String>>(None),
|
||||
matrix_user_id.eq::<Option<String>>(None),
|
||||
deleted.eq(true),
|
||||
updated.eq(naive_now()),
|
||||
))
|
||||
|
@ -239,21 +256,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "holly".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -271,11 +274,13 @@ mod tests {
|
|||
actor_id: inserted_person.actor_id.to_owned(),
|
||||
bio: None,
|
||||
local: true,
|
||||
admin: false,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: inserted_person.published,
|
||||
inbox_url: inserted_person.inbox_url.to_owned(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
};
|
||||
|
||||
let read_person = Person::read(&conn, inserted_person.id).unwrap();
|
||||
|
|
|
@ -90,42 +90,14 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "terrylake".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
||||
let recipient_form = PersonForm {
|
||||
name: "terrylakes recipient".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_recipient = Person::create(&conn, &recipient_form).unwrap();
|
||||
|
@ -133,23 +105,8 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: "test community lake".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
@ -157,22 +114,8 @@ mod tests {
|
|||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
creator_id: inserted_person.id,
|
||||
url: None,
|
||||
body: None,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -181,14 +124,7 @@ mod tests {
|
|||
content: "A test comment".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
parent_id: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
|
|
@ -273,21 +273,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "jim".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -295,46 +281,17 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: "test community_3".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: "A test post".into(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
nsfw: false,
|
||||
updated: None,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
|
|
@ -150,42 +150,14 @@ mod tests {
|
|||
|
||||
let creator_form = PersonForm {
|
||||
name: "creator_pm".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_creator = Person::create(&conn, &creator_form).unwrap();
|
||||
|
||||
let recipient_form = PersonForm {
|
||||
name: "recipient_pm".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_recipient = Person::create(&conn, &recipient_form).unwrap();
|
||||
|
@ -194,12 +166,7 @@ mod tests {
|
|||
content: "A test private message".into(),
|
||||
creator_id: inserted_creator.id,
|
||||
recipient_id: inserted_recipient.id,
|
||||
deleted: None,
|
||||
read: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..PrivateMessageForm::default()
|
||||
};
|
||||
|
||||
let inserted_private_message = PrivateMessage::create(&conn, &private_message_form).unwrap();
|
||||
|
|
|
@ -22,7 +22,9 @@ use url::Url;
|
|||
pub mod schema;
|
||||
pub mod source;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||
#[derive(
|
||||
Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
|
||||
)]
|
||||
pub struct PostId(pub i32);
|
||||
|
||||
impl fmt::Display for PostId {
|
||||
|
@ -31,7 +33,9 @@ impl fmt::Display for PostId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||
#[derive(
|
||||
Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
|
||||
)]
|
||||
pub struct PersonId(pub i32);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||
|
@ -43,7 +47,9 @@ impl fmt::Display for CommentId {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||
#[derive(
|
||||
Debug, Copy, Clone, Hash, Eq, PartialEq, Default, Serialize, Deserialize, DieselNewType,
|
||||
)]
|
||||
pub struct CommunityId(pub i32);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, DieselNewType)]
|
||||
|
|
|
@ -146,7 +146,6 @@ table! {
|
|||
person_id -> Int4,
|
||||
password_encrypted -> Text,
|
||||
email -> Nullable<Text>,
|
||||
admin -> Bool,
|
||||
show_nsfw -> Bool,
|
||||
theme -> Varchar,
|
||||
default_sort_type -> Int2,
|
||||
|
@ -154,7 +153,6 @@ table! {
|
|||
lang -> Varchar,
|
||||
show_avatars -> Bool,
|
||||
send_notifications_to_email -> Bool,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
validator_time -> Timestamp,
|
||||
}
|
||||
}
|
||||
|
@ -287,6 +285,8 @@ table! {
|
|||
deleted -> Bool,
|
||||
inbox_url -> Varchar,
|
||||
shared_inbox_url -> Nullable<Varchar>,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,6 +485,8 @@ table! {
|
|||
deleted -> Bool,
|
||||
inbox_url -> Varchar,
|
||||
shared_inbox_url -> Nullable<Varchar>,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,6 +509,8 @@ table! {
|
|||
deleted -> Bool,
|
||||
inbox_url -> Varchar,
|
||||
shared_inbox_url -> Nullable<Varchar>,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
admin -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ pub struct Activity {
|
|||
#[table_name = "activity"]
|
||||
pub struct ActivityForm {
|
||||
pub data: Value,
|
||||
pub local: bool,
|
||||
pub local: Option<bool>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub ap_id: DbUrl,
|
||||
pub sensitive: bool,
|
||||
|
|
|
@ -51,7 +51,7 @@ pub struct CommentAlias1 {
|
|||
pub local: bool,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset, Clone)]
|
||||
#[derive(Insertable, AsChangeset, Clone, Default)]
|
||||
#[table_name = "comment"]
|
||||
pub struct CommentForm {
|
||||
pub creator_id: PersonId,
|
||||
|
@ -64,7 +64,7 @@ pub struct CommentForm {
|
|||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub deleted: Option<bool>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: bool,
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug, Clone)]
|
||||
|
|
|
@ -51,7 +51,7 @@ pub struct CommunitySafe {
|
|||
pub banner: Option<DbUrl>,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset, Debug)]
|
||||
#[derive(Insertable, AsChangeset, Debug, Default)]
|
||||
#[table_name = "community"]
|
||||
pub struct CommunityForm {
|
||||
pub name: String,
|
||||
|
@ -62,9 +62,9 @@ pub struct CommunityForm {
|
|||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub deleted: Option<bool>,
|
||||
pub nsfw: bool,
|
||||
pub nsfw: Option<bool>,
|
||||
pub actor_id: Option<DbUrl>,
|
||||
pub local: bool,
|
||||
pub local: Option<bool>,
|
||||
pub private_key: Option<String>,
|
||||
pub public_key: Option<String>,
|
||||
pub last_refreshed_at: Option<chrono::NaiveDateTime>,
|
||||
|
|
|
@ -8,7 +8,6 @@ pub struct LocalUser {
|
|||
pub person_id: PersonId,
|
||||
pub password_encrypted: String,
|
||||
pub email: Option<String>,
|
||||
pub admin: bool,
|
||||
pub show_nsfw: bool,
|
||||
pub theme: String,
|
||||
pub default_sort_type: i16,
|
||||
|
@ -16,18 +15,16 @@ pub struct LocalUser {
|
|||
pub lang: String,
|
||||
pub show_avatars: bool,
|
||||
pub send_notifications_to_email: bool,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub validator_time: chrono::NaiveDateTime,
|
||||
}
|
||||
|
||||
// TODO redo these, check table defaults
|
||||
#[derive(Insertable, AsChangeset, Clone)]
|
||||
#[derive(Insertable, AsChangeset, Clone, Default)]
|
||||
#[table_name = "local_user"]
|
||||
pub struct LocalUserForm {
|
||||
pub person_id: PersonId,
|
||||
pub password_encrypted: String,
|
||||
pub email: Option<Option<String>>,
|
||||
pub admin: Option<bool>,
|
||||
pub show_nsfw: Option<bool>,
|
||||
pub theme: Option<String>,
|
||||
pub default_sort_type: Option<i16>,
|
||||
|
@ -35,7 +32,6 @@ pub struct LocalUserForm {
|
|||
pub lang: Option<String>,
|
||||
pub show_avatars: Option<bool>,
|
||||
pub send_notifications_to_email: Option<bool>,
|
||||
pub matrix_user_id: Option<Option<String>>,
|
||||
}
|
||||
|
||||
/// A local user view that removes password encrypted
|
||||
|
@ -45,7 +41,6 @@ pub struct LocalUserSettings {
|
|||
pub id: LocalUserId,
|
||||
pub person_id: PersonId,
|
||||
pub email: Option<String>,
|
||||
pub admin: bool,
|
||||
pub show_nsfw: bool,
|
||||
pub theme: String,
|
||||
pub default_sort_type: i16,
|
||||
|
@ -53,6 +48,5 @@ pub struct LocalUserSettings {
|
|||
pub lang: String,
|
||||
pub show_avatars: bool,
|
||||
pub send_notifications_to_email: bool,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub validator_time: chrono::NaiveDateTime,
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ pub struct Person {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
/// A safe representation of person, without the sensitive info
|
||||
|
@ -45,6 +47,8 @@ pub struct PersonSafe {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -67,6 +71,8 @@ pub struct PersonAlias1 {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -86,6 +92,8 @@ pub struct PersonSafeAlias1 {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -108,6 +116,8 @@ pub struct PersonAlias2 {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
|
||||
|
@ -127,9 +137,11 @@ pub struct PersonSafeAlias2 {
|
|||
pub deleted: bool,
|
||||
pub inbox_url: DbUrl,
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
pub matrix_user_id: Option<String>,
|
||||
pub admin: bool,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset, Clone)]
|
||||
#[derive(Insertable, AsChangeset, Clone, Default)]
|
||||
#[table_name = "person"]
|
||||
pub struct PersonForm {
|
||||
pub name: String,
|
||||
|
@ -148,4 +160,6 @@ pub struct PersonForm {
|
|||
pub deleted: Option<bool>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<Option<DbUrl>>,
|
||||
pub matrix_user_id: Option<Option<String>>,
|
||||
pub admin: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub struct Post {
|
|||
pub local: bool,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset)]
|
||||
#[derive(Insertable, AsChangeset, Default)]
|
||||
#[table_name = "post"]
|
||||
pub struct PostForm {
|
||||
pub name: String,
|
||||
|
@ -51,7 +51,7 @@ pub struct PostForm {
|
|||
pub embed_html: Option<String>,
|
||||
pub thumbnail_url: Option<DbUrl>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: bool,
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Identifiable, Queryable, Associations, PartialEq, Debug)]
|
||||
|
|
|
@ -16,7 +16,7 @@ pub struct PrivateMessage {
|
|||
pub local: bool,
|
||||
}
|
||||
|
||||
#[derive(Insertable, AsChangeset)]
|
||||
#[derive(Insertable, AsChangeset, Default)]
|
||||
#[table_name = "private_message"]
|
||||
pub struct PrivateMessageForm {
|
||||
pub creator_id: PersonId,
|
||||
|
@ -27,5 +27,5 @@ pub struct PrivateMessageForm {
|
|||
pub published: Option<chrono::NaiveDateTime>,
|
||||
pub updated: Option<chrono::NaiveDateTime>,
|
||||
pub ap_id: Option<DbUrl>,
|
||||
pub local: bool,
|
||||
pub local: Option<bool>,
|
||||
}
|
||||
|
|
|
@ -454,21 +454,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: "timmy".into(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -476,23 +462,8 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: "test community 5".to_string(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
@ -500,22 +471,8 @@ mod tests {
|
|||
let new_post = PostForm {
|
||||
name: "A test post 2".into(),
|
||||
creator_id: inserted_person.id,
|
||||
url: None,
|
||||
body: None,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -524,14 +481,7 @@ mod tests {
|
|||
content: "A test comment 32".into(),
|
||||
creator_id: inserted_person.id,
|
||||
post_id: inserted_post.id,
|
||||
parent_id: None,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
read: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
..CommentForm::default()
|
||||
};
|
||||
|
||||
let inserted_comment = Comment::create(&conn, &comment_form).unwrap();
|
||||
|
@ -576,11 +526,13 @@ mod tests {
|
|||
local: true,
|
||||
banned: false,
|
||||
deleted: false,
|
||||
admin: false,
|
||||
bio: None,
|
||||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_person.inbox_url.to_owned(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
},
|
||||
recipient: None,
|
||||
post: Post {
|
||||
|
|
|
@ -454,21 +454,7 @@ mod tests {
|
|||
|
||||
let new_person = PersonForm {
|
||||
name: person_name.to_owned(),
|
||||
preferred_username: None,
|
||||
avatar: None,
|
||||
banner: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
actor_id: None,
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
let inserted_person = Person::create(&conn, &new_person).unwrap();
|
||||
|
@ -476,46 +462,17 @@ mod tests {
|
|||
let new_community = CommunityForm {
|
||||
name: community_name.to_owned(),
|
||||
title: "nada".to_owned(),
|
||||
description: None,
|
||||
creator_id: inserted_person.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
actor_id: None,
|
||||
local: true,
|
||||
private_key: None,
|
||||
public_key: None,
|
||||
last_refreshed_at: None,
|
||||
published: None,
|
||||
icon: None,
|
||||
banner: None,
|
||||
followers_url: None,
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..CommunityForm::default()
|
||||
};
|
||||
|
||||
let inserted_community = Community::create(&conn, &new_community).unwrap();
|
||||
|
||||
let new_post = PostForm {
|
||||
name: post_name.to_owned(),
|
||||
url: None,
|
||||
body: None,
|
||||
creator_id: inserted_person.id,
|
||||
community_id: inserted_community.id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
locked: None,
|
||||
stickied: None,
|
||||
updated: None,
|
||||
nsfw: false,
|
||||
embed_title: None,
|
||||
embed_description: None,
|
||||
embed_html: None,
|
||||
thumbnail_url: None,
|
||||
ap_id: None,
|
||||
local: true,
|
||||
published: None,
|
||||
..PostForm::default()
|
||||
};
|
||||
|
||||
let inserted_post = Post::create(&conn, &new_post).unwrap();
|
||||
|
@ -589,6 +546,7 @@ mod tests {
|
|||
avatar: None,
|
||||
actor_id: inserted_person.actor_id.to_owned(),
|
||||
local: true,
|
||||
admin: false,
|
||||
banned: false,
|
||||
deleted: false,
|
||||
bio: None,
|
||||
|
@ -596,6 +554,7 @@ mod tests {
|
|||
updated: None,
|
||||
inbox_url: inserted_person.inbox_url.to_owned(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
},
|
||||
creator_banned_from_community: false,
|
||||
community: CommunitySafe {
|
||||
|
|
|
@ -9,7 +9,7 @@ use lemmy_db_queries::{
|
|||
ViewToVec,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
schema::{local_user, person, person_aggregates},
|
||||
schema::{person, person_aggregates},
|
||||
source::person::{Person, PersonSafe},
|
||||
PersonId,
|
||||
};
|
||||
|
@ -36,9 +36,8 @@ impl PersonViewSafe {
|
|||
pub fn admins(conn: &PgConnection) -> Result<Vec<Self>, Error> {
|
||||
let admins = person::table
|
||||
.inner_join(person_aggregates::table)
|
||||
.inner_join(local_user::table)
|
||||
.select((Person::safe_columns_tuple(), person_aggregates::all_columns))
|
||||
.filter(local_user::admin.eq(true))
|
||||
.filter(person::admin.eq(true))
|
||||
.order_by(person::published)
|
||||
.load::<PersonViewSafeTuple>(conn)?;
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
pub const VERSION: &str = "0.10.0-rc.7";
|
||||
pub const VERSION: &str = "0.10.0-rc.10";
|
||||
|
|
|
@ -17,7 +17,7 @@ services:
|
|||
- iframely
|
||||
|
||||
lemmy-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
ports:
|
||||
- "1235:1234"
|
||||
restart: always
|
||||
|
|
|
@ -29,7 +29,7 @@ services:
|
|||
- ./volumes/pictrs_alpha:/mnt
|
||||
|
||||
lemmy-alpha-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
environment:
|
||||
- LEMMY_INTERNAL_HOST=lemmy-alpha:8541
|
||||
- LEMMY_EXTERNAL_HOST=localhost:8541
|
||||
|
@ -58,7 +58,7 @@ services:
|
|||
- ./volumes/postgres_alpha:/var/lib/postgresql/data
|
||||
|
||||
lemmy-beta-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
environment:
|
||||
- LEMMY_INTERNAL_HOST=lemmy-beta:8551
|
||||
- LEMMY_EXTERNAL_HOST=localhost:8551
|
||||
|
@ -87,7 +87,7 @@ services:
|
|||
- ./volumes/postgres_beta:/var/lib/postgresql/data
|
||||
|
||||
lemmy-gamma-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
environment:
|
||||
- LEMMY_INTERNAL_HOST=lemmy-gamma:8561
|
||||
- LEMMY_EXTERNAL_HOST=localhost:8561
|
||||
|
@ -117,7 +117,7 @@ services:
|
|||
|
||||
# An instance with only an allowlist for beta
|
||||
lemmy-delta-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
environment:
|
||||
- LEMMY_INTERNAL_HOST=lemmy-delta:8571
|
||||
- LEMMY_EXTERNAL_HOST=localhost:8571
|
||||
|
@ -147,7 +147,7 @@ services:
|
|||
|
||||
# An instance who has a blocklist, with lemmy-alpha blocked
|
||||
lemmy-epsilon-ui:
|
||||
image: dessalines/lemmy-ui:0.9.9
|
||||
image: dessalines/lemmy-ui:0.10.0-rc.10
|
||||
environment:
|
||||
- LEMMY_INTERNAL_HOST=lemmy-epsilon:8581
|
||||
- LEMMY_EXTERNAL_HOST=localhost:8581
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
alter table local_user add column matrix_user_id text;
|
||||
alter table local_user add column admin boolean default false not null;
|
||||
|
||||
update local_user lu
|
||||
set
|
||||
matrix_user_id = p.matrix_user_id,
|
||||
admin = p.admin
|
||||
from person p
|
||||
where p.id = lu.person_id;
|
||||
|
||||
drop view person_alias_1, person_alias_2;
|
||||
alter table person drop column matrix_user_id;
|
||||
alter table person drop column admin;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
17
migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql
Normal file
17
migrations/2021-03-20-185321_move_matrix_id_to_person/up.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
alter table person add column matrix_user_id text;
|
||||
alter table person add column admin boolean default false not null;
|
||||
|
||||
update person p
|
||||
set
|
||||
matrix_user_id = lu.matrix_user_id,
|
||||
admin = lu.admin
|
||||
from local_user lu
|
||||
where p.id = lu.person_id;
|
||||
|
||||
alter table local_user drop column matrix_user_id;
|
||||
alter table local_user drop column admin;
|
||||
|
||||
-- Regenerate the person_alias views
|
||||
drop view person_alias_1, person_alias_2;
|
||||
create view person_alias_1 as select * from person;
|
||||
create view person_alias_2 as select * from person;
|
|
@ -55,21 +55,11 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
|
||||
let form = PersonForm {
|
||||
name: cperson.name.to_owned(),
|
||||
avatar: None,
|
||||
banner: None,
|
||||
preferred_username: None,
|
||||
published: None,
|
||||
updated: None,
|
||||
banned: None,
|
||||
deleted: None,
|
||||
actor_id: Some(generate_apub_endpoint(EndpointType::Person, &cperson.name)?),
|
||||
bio: None,
|
||||
local: None,
|
||||
private_key: Some(Some(keypair.private_key)),
|
||||
public_key: Some(Some(keypair.public_key)),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: None,
|
||||
shared_inbox_url: None,
|
||||
..PersonForm::default()
|
||||
};
|
||||
|
||||
Person::update(&conn, cperson.id, &form)?;
|
||||
|
@ -102,10 +92,10 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
|||
creator_id: ccommunity.creator_id,
|
||||
removed: None,
|
||||
deleted: None,
|
||||
nsfw: ccommunity.nsfw,
|
||||
nsfw: None,
|
||||
updated: None,
|
||||
actor_id: Some(community_actor_id.to_owned()),
|
||||
local: ccommunity.local,
|
||||
local: Some(ccommunity.local),
|
||||
private_key: Some(keypair.private_key),
|
||||
public_key: Some(keypair.public_key),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
|
|
Loading…
Reference in a new issue