# API tests
api_tests/node_modules
+api_tests/.yalc
+api_tests/yalc.lock
# pictrs data
pictrs/
# when:
# platform: linux/amd64
+ check_diesel_schema:
+ image: jameshiew/diesel-cli
+ environment:
+ CARGO_HOME: .cargo
+ DATABASE_URL: postgres://lemmy:password@database:5432/lemmy
+ commands:
+ - diesel migration run
+ - diesel print-schema --config-file=diesel.toml > tmp.schema
+ - diff tmp.schema crates/db_schema/src/schema.rs
+
cargo_test:
image: *muslrust_image
environment:
"tokio-postgres",
]
+[[package]]
+name = "diesel-derive-enum"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b10c03b954333d05bfd5be1d8a74eae2c9ca77b86e0f1c3a1ea29c49da1d6c2"
+dependencies = [
+ "heck 0.4.0",
+ "proc-macro2 1.0.47",
+ "quote 1.0.21",
+ "syn 1.0.103",
+]
+
[[package]]
name = "diesel-derive-newtype"
version = "2.0.0-rc.0"
"deadpool",
"diesel",
"diesel-async",
+ "diesel-derive-enum",
"diesel-derive-newtype",
"diesel_ltree",
"diesel_migrations",
regex = "1.6.0"
once_cell = "1.15.0"
diesel-derive-newtype = "2.0.0-rc.0"
+diesel-derive-enum = {version = "2.0.1", features = ["postgres"] }
strum = "0.24.1"
strum_macros = "0.24.3"
itertools = "0.10.5"
"eslint": "^8.25.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.0.6",
- "lemmy-js-client": "0.17.2-rc.1",
+ "lemmy-js-client": "0.17.2-rc.6",
"node-fetch": "^2.6.1",
"prettier": "^2.7.1",
"ts-jest": "^27.0.3",
let form: SaveUserSettings = {
show_nsfw: true,
theme: "darkly",
- default_sort_type: Object.keys(SortType).indexOf(SortType.Active),
- default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
+ default_sort_type: SortType.Active,
+ default_listing_type: ListingType.All,
interface_language: "en",
show_avatars: true,
send_notifications_to_email: false,
let bio = "a changed bio";
let form: SaveUserSettings = {
show_nsfw: false,
- default_sort_type: Object.keys(SortType).indexOf(SortType.Hot),
- default_listing_type: Object.keys(ListingType).indexOf(ListingType.All),
+ default_sort_type: SortType.Hot,
+ default_listing_type: ListingType.All,
interface_language: "",
avatar,
banner,
jest.setTimeout(120000);
-import { PersonViewSafe } from "lemmy-js-client";
+import { PersonView } from "lemmy-js-client";
import {
alpha,
let apShortname: string;
-function assertUserFederation(
- userOne?: PersonViewSafe,
- userTwo?: PersonViewSafe
-) {
+function assertUserFederation(userOne?: PersonView, userTwo?: PersonView) {
expect(userOne?.person.name).toBe(userTwo?.person.name);
expect(userOne?.person.display_name).toBe(userTwo?.person.display_name);
expect(userOne?.person.bio).toBe(userTwo?.person.bio);
dependencies:
safe-buffer "~5.1.1"
+cross-fetch@^3.1.5:
+ version "3.1.5"
+ resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.5.tgz#e1389f44d9e7ba767907f7af8454787952ab534f"
+ integrity sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==
+ dependencies:
+ node-fetch "2.6.7"
+
cross-spawn@^7.0.2, cross-spawn@^7.0.3:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
combined-stream "^1.0.8"
mime-types "^2.1.12"
+form-data@^4.0.0:
+ version "4.0.0"
+ resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
+ integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==
+ dependencies:
+ asynckit "^0.4.0"
+ combined-stream "^1.0.8"
+ mime-types "^2.1.12"
+
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e"
integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==
-lemmy-js-client@0.17.2-rc.1:
- version "0.17.2-rc.1"
- resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.1.tgz#fe8d1508311bbf245acc98c2c3e47e2165a95b14"
- integrity sha512-YrOXuCofgkqp28krmPTQZAfUWL5zEDA0sRJ0abKcgf/I8YYkYkUkPS9TOORN5Lv3bc8RAAz4+2/zLHqYL/Tnow==
+lemmy-js-client@0.17.2-rc.6:
+ version "0.17.2-rc.6"
+ resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.2-rc.6.tgz#cd488bc30edf7b65a02b91f1bc295d1b958e9b86"
+ integrity sha512-/EdzpLJpYOq3ypCQA1MyI7sX0DmHUIA1ZUIda2XTCUUP7a5pltF7WHTicFrQ9j6JwCiFMTVkw6S/L8LzfD6cGA==
dependencies:
- node-fetch "2.6.6"
+ cross-fetch "^3.1.5"
+ form-data "^4.0.0"
leven@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==
-node-fetch@2.6.6:
- version "2.6.6"
- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
- integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
- dependencies:
- whatwg-url "^5.0.0"
-
-node-fetch@^2.6.1:
+node-fetch@2.6.7, node-fetch@^2.6.1:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
mod_person_id: local_user_view.person.id,
other_person_id: data.person_id,
community_id: data.community_id,
- removed: Some(false),
};
ModTransferCommunity::create(context.pool(), &form).await?;
person::{LoginResponse, PasswordChangeAfterReset},
utils::password_length_check,
};
-use lemmy_db_schema::source::{
- local_site::RegistrationMode,
- local_user::LocalUser,
- password_reset_request::PasswordResetRequest,
+use lemmy_db_schema::{
+ source::{local_user::LocalUser, password_reset_request::PasswordResetRequest},
+ RegistrationMode,
};
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{claims::Claims, error::LemmyError, ConnectionId};
use lemmy_db_schema::{
newtypes::{CommentReplyId, CommunityId, LanguageId, PersonId, PersonMentionId},
CommentSortType,
+ ListingType,
SortType,
};
use lemmy_db_views::structs::{CommentView, PostView};
pub show_nsfw: Option<bool>,
pub show_scores: Option<bool>,
pub theme: Option<String>,
- pub default_sort_type: Option<i16>,
- pub default_listing_type: Option<i16>,
+ pub default_sort_type: Option<SortType>,
+ pub default_listing_type: Option<ListingType>,
pub interface_language: Option<String>,
pub avatar: Option<String>,
pub banner: Option<String>,
use crate::sensitive::Sensitive;
use lemmy_db_schema::{
newtypes::{CommentId, CommunityId, LanguageId, PersonId, PostId},
- source::{
- instance::Instance,
- language::Language,
- local_site::RegistrationMode,
- tagline::Tagline,
- },
+ source::{instance::Instance, language::Language, tagline::Tagline},
ListingType,
ModlogActionType,
+ RegistrationMode,
SearchType,
SortType,
};
pub application_question: Option<String>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
- pub default_post_listing_type: Option<String>,
+ pub default_post_listing_type: Option<ListingType>,
pub legal_information: Option<String>,
pub application_email_admins: Option<bool>,
pub hide_modlog_mod_names: Option<bool>,
pub application_question: Option<String>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
- pub default_post_listing_type: Option<String>,
+ pub default_post_listing_type: Option<ListingType>,
pub legal_information: Option<String>,
pub application_email_admins: Option<bool>,
pub hide_modlog_mod_names: Option<bool>,
community::{Community, CommunityModerator, CommunityUpdateForm},
email_verification::{EmailVerification, EmailVerificationForm},
instance::Instance,
- local_site::{LocalSite, RegistrationMode},
+ local_site::LocalSite,
local_site_rate_limit::LocalSiteRateLimit,
password_reset_request::PasswordResetRequest,
person::{Person, PersonUpdateForm},
},
traits::{Crud, Readable},
utils::DbPool,
+ RegistrationMode,
};
use lemmy_db_views::{comment_view::CommentQuery, structs::LocalUserView};
use lemmy_db_views_actor::structs::{
.application_question(application_question)
.private_instance(data.private_instance)
.default_theme(data.default_theme.clone())
- .default_post_listing_type(data.default_post_listing_type.clone())
+ .default_post_listing_type(data.default_post_listing_type)
.legal_information(diesel_option_overwrite(&data.legal_information))
.application_email_admins(data.application_email_admins)
.hide_modlog_mod_names(data.hide_modlog_mod_names)
-use lemmy_db_schema::source::local_site::RegistrationMode;
+use lemmy_db_schema::RegistrationMode;
use lemmy_utils::error::LemmyError;
mod create;
actor_language::SiteLanguage,
federation_allowlist::FederationAllowList,
federation_blocklist::FederationBlockList,
- local_site::{LocalSite, LocalSiteUpdateForm, RegistrationMode},
+ local_site::{LocalSite, LocalSiteUpdateForm},
local_site_rate_limit::{LocalSiteRateLimit, LocalSiteRateLimitUpdateForm},
local_user::LocalUser,
site::{Site, SiteUpdateForm},
traits::Crud,
utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now},
ListingType,
+ RegistrationMode,
};
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
utils::{slurs::check_slurs_opt, validation::is_valid_body_field},
ConnectionId,
};
-use std::str::FromStr;
#[async_trait::async_trait(?Send)]
impl PerformCrud for EditSite {
.unwrap_or(local_site.registration_mode),
)?;
- if let Some(default_post_listing_type) = &data.default_post_listing_type {
+ if let Some(listing_type) = &data.default_post_listing_type {
// only allow all or local as default listing types
- let val = ListingType::from_str(default_post_listing_type);
- if val != Ok(ListingType::All) && val != Ok(ListingType::Local) {
+ if listing_type != &ListingType::All && listing_type != &ListingType::Local {
return Err(LemmyError::from_message(
"invalid_default_post_listing_type",
));
.application_question(application_question)
.private_instance(data.private_instance)
.default_theme(data.default_theme.clone())
- .default_post_listing_type(data.default_post_listing_type.clone())
+ .default_post_listing_type(data.default_post_listing_type)
.legal_information(diesel_option_overwrite(&data.legal_information))
.application_email_admins(data.application_email_admins)
.hide_modlog_mod_names(data.hide_modlog_mod_names)
use lemmy_db_schema::{
aggregates::structs::PersonAggregates,
source::{
- local_site::RegistrationMode,
local_user::{LocalUser, LocalUserInsertForm},
person::{Person, PersonInsertForm},
registration_application::{RegistrationApplication, RegistrationApplicationInsertForm},
},
traits::Crud,
+ RegistrationMode,
};
use lemmy_db_views::structs::{LocalUserView, SiteView};
use lemmy_utils::{
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::{newtypes::CommunityId, source::local_site::LocalSite, ListingType};
use lemmy_utils::{error::LemmyError, ConnectionId};
-use std::str::FromStr;
mod list_comments;
mod list_posts;
) -> Result<ListingType, LemmyError> {
// On frontpage use listing type from param or admin configured default
let listing_type = if community_id.is_none() {
- type_.unwrap_or(ListingType::from_str(
- &local_site.default_post_listing_type,
- )?)
+ type_.unwrap_or(local_site.default_post_listing_type)
} else {
// inside of community show everything
ListingType::All
.into();
let activity = Activity::read_from_apub_id(context.pool(), &activity_id).await?;
- let sensitive = activity.sensitive.unwrap_or(true);
+ let sensitive = activity.sensitive;
if !activity.local {
Err(err_object_not_local())
} else if sensitive {
doctest = false
[features]
-full = ["diesel", "diesel-derive-newtype", "diesel_migrations", "bcrypt", "lemmy_utils",
+full = ["diesel", "diesel-derive-newtype", "diesel-derive-enum", "diesel_migrations", "bcrypt", "lemmy_utils",
"activitypub_federation", "sha2", "regex", "once_cell", "serde_json", "diesel_ltree",
"diesel-async", "deadpool"]
bcrypt = { workspace = true, optional = true }
diesel = { workspace = true, features = ["postgres","chrono", "serde_json"], optional = true }
diesel-derive-newtype = { workspace = true, optional = true }
+diesel-derive-enum = { workspace = true, optional = true }
diesel_migrations = { workspace = true, optional = true }
diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true }
sha2 = { workspace = true, optional = true }
--- /dev/null
+diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs
+index 255c6422..f2ccf5e2 100644
+--- a/crates/db_schema/src/schema.rs
++++ b/crates/db_schema/src/schema.rs
+@@ -2,16 +2,12 @@
+
+ pub mod sql_types {
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "listing_type_enum"))]
+ pub struct ListingTypeEnum;
+
+- #[derive(diesel::sql_types::SqlType)]
+- #[diesel(postgres_type(name = "ltree"))]
+- pub struct Ltree;
+-
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "registration_mode_enum"))]
+ pub struct RegistrationModeEnum;
+
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "sort_type_enum"))]
+@@ -67,13 +63,13 @@ diesel::table! {
+ when_ -> Timestamp,
+ }
+ }
+
+ diesel::table! {
+ use diesel::sql_types::*;
+- use super::sql_types::Ltree;
++ use diesel_ltree::sql_types::Ltree;
+
+ comment (id) {
+ id -> Int4,
+ creator_id -> Int4,
+ post_id -> Int4,
+ content -> Text,
id: inserted_activity.id,
data: test_json,
local: true,
- sensitive: Some(false),
+ sensitive: false,
published: inserted_activity.published,
updated: None,
};
use crate::{
schema::local_site::dsl::local_site,
- source::local_site::{
- LocalSite,
- LocalSiteInsertForm,
- LocalSiteUpdateForm,
- RegistrationMode,
- RegistrationModeType,
- },
+ source::local_site::{LocalSite, LocalSiteInsertForm, LocalSiteUpdateForm},
utils::{get_conn, DbPool},
};
-use diesel::{
- deserialize,
- deserialize::FromSql,
- dsl::insert_into,
- pg::{Pg, PgValue},
- result::Error,
- serialize,
- serialize::{IsNull, Output, ToSql},
-};
+use diesel::{dsl::insert_into, result::Error};
use diesel_async::RunQueryDsl;
-use std::io::Write;
impl LocalSite {
pub async fn create(pool: &DbPool, form: &LocalSiteInsertForm) -> Result<Self, Error> {
diesel::delete(local_site).execute(conn).await
}
}
-
-impl ToSql<RegistrationModeType, Pg> for RegistrationMode {
- fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> serialize::Result {
- match *self {
- RegistrationMode::Closed => out.write_all(b"closed")?,
- RegistrationMode::RequireApplication => out.write_all(b"require_application")?,
- RegistrationMode::Open => out.write_all(b"open")?,
- }
- Ok(IsNull::No)
- }
-}
-
-impl FromSql<RegistrationModeType, Pg> for RegistrationMode {
- fn from_sql(bytes: PgValue<'_>) -> deserialize::Result<Self> {
- match bytes.as_bytes() {
- b"closed" => Ok(RegistrationMode::Closed),
- b"require_application" => Ok(RegistrationMode::RequireApplication),
- b"open" => Ok(RegistrationMode::Open),
- _ => Err("Unrecognized enum variant".into()),
- }
- }
-}
post_id: inserted_post.id,
mod_person_id: inserted_mod.id,
reason: None,
- removed: Some(true),
+ removed: true,
when_: inserted_mod_remove_post.when_,
};
id: inserted_mod_lock_post.id,
post_id: inserted_post.id,
mod_person_id: inserted_mod.id,
- locked: Some(true),
+ locked: true,
when_: inserted_mod_lock_post.when_,
};
comment_id: inserted_comment.id,
mod_person_id: inserted_mod.id,
reason: None,
- removed: Some(true),
+ removed: true,
when_: inserted_mod_remove_comment.when_,
};
community_id: inserted_community.id,
mod_person_id: inserted_mod.id,
reason: None,
- removed: Some(true),
+ removed: true,
expires: None,
when_: inserted_mod_remove_community.when_,
};
mod_person_id: inserted_mod.id,
other_person_id: inserted_person.id,
reason: None,
- banned: Some(true),
+ banned: true,
expires: None,
when_: inserted_mod_ban_from_community.when_,
};
mod_person_id: inserted_mod.id,
other_person_id: inserted_person.id,
reason: None,
- banned: Some(true),
+ banned: true,
expires: None,
when_: inserted_mod_ban.when_,
};
community_id: inserted_community.id,
mod_person_id: inserted_mod.id,
other_person_id: inserted_person.id,
- removed: Some(false),
+ removed: false,
when_: inserted_mod_add_community.when_,
};
id: inserted_mod_add.id,
mod_person_id: inserted_mod.id,
other_person_id: inserted_person.id,
- removed: Some(false),
+ removed: false,
when_: inserted_mod_add.when_,
};
traits::{ApubActor, Crud, Followable},
utils::{functions::lower, get_conn, naive_now, DbPool},
};
-use diesel::{dsl::insert_into, result::Error, ExpressionMethods, QueryDsl, TextExpressionMethods};
+use diesel::{
+ dsl::insert_into,
+ result::Error,
+ ExpressionMethods,
+ JoinOnDsl,
+ QueryDsl,
+ TextExpressionMethods,
+};
use diesel_async::RunQueryDsl;
#[async_trait]
use crate::schema::{person, person_follower, person_follower::person_id};
let conn = &mut get_conn(pool).await?;
person_follower::table
- .inner_join(person::table)
+ .inner_join(person::table.on(person_follower::follower_id.eq(person::id)))
.filter(person_id.eq(person_id_))
.select(person::all_columns)
.load(conn)
#[cfg(feature = "full")]
#[macro_use]
extern crate diesel_derive_newtype;
+
+#[cfg(feature = "full")]
+#[macro_use]
+extern crate diesel_derive_enum;
+
// this is used in tests
#[cfg(feature = "full")]
#[macro_use]
pub mod impls;
pub mod newtypes;
#[cfg(feature = "full")]
+#[rustfmt::skip]
pub mod schema;
pub mod source;
#[cfg(feature = "full")]
use serde::{Deserialize, Serialize};
use strum_macros::{Display, EnumString};
-#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
+#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
+#[cfg_attr(feature = "full", derive(DbEnum))]
+#[cfg_attr(
+ feature = "full",
+ ExistingTypePath = "crate::schema::sql_types::SortTypeEnum"
+)]
+#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
pub enum SortType {
Active,
Hot,
}
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
+#[cfg_attr(feature = "full", derive(DbEnum))]
+#[cfg_attr(
+ feature = "full",
+ ExistingTypePath = "crate::schema::sql_types::ListingTypeEnum"
+)]
+#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
pub enum ListingType {
All,
Local,
Subscribed,
}
+#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
+#[cfg_attr(feature = "full", derive(DbEnum))]
+#[cfg_attr(
+ feature = "full",
+ ExistingTypePath = "crate::schema::sql_types::RegistrationModeEnum"
+)]
+#[cfg_attr(feature = "full", DbValueStyle = "verbatim")]
+pub enum RegistrationMode {
+ Closed,
+ RequireApplication,
+ Open,
+}
+
#[derive(EnumString, Display, Debug, Serialize, Deserialize, Clone, Copy)]
pub enum SearchType {
All,
-table! {
+// @generated automatically by Diesel CLI.
+
+pub mod sql_types {
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "listing_type_enum"))]
+ pub struct ListingTypeEnum;
+
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "registration_mode_enum"))]
+ pub struct RegistrationModeEnum;
+
+ #[derive(diesel::sql_types::SqlType)]
+ #[diesel(postgres_type(name = "sort_type_enum"))]
+ pub struct SortTypeEnum;
+}
+
+diesel::table! {
activity (id) {
id -> Int4,
data -> Jsonb,
published -> Timestamp,
updated -> Nullable<Timestamp>,
ap_id -> Text,
- sensitive -> Nullable<Bool>,
+ sensitive -> Bool,
+ }
+}
+
+diesel::table! {
+ admin_purge_comment (id) {
+ id -> Int4,
+ admin_person_id -> Int4,
+ post_id -> Int4,
+ reason -> Nullable<Text>,
+ when_ -> Timestamp,
+ }
+}
+
+diesel::table! {
+ admin_purge_community (id) {
+ id -> Int4,
+ admin_person_id -> Int4,
+ reason -> Nullable<Text>,
+ when_ -> Timestamp,
}
}
-table! {
- use diesel_ltree::sql_types::Ltree;
- use diesel::sql_types::*;
+diesel::table! {
+ admin_purge_person (id) {
+ id -> Int4,
+ admin_person_id -> Int4,
+ reason -> Nullable<Text>,
+ when_ -> Timestamp,
+ }
+}
+
+diesel::table! {
+ admin_purge_post (id) {
+ id -> Int4,
+ admin_person_id -> Int4,
+ community_id -> Int4,
+ reason -> Nullable<Text>,
+ when_ -> Timestamp,
+ }
+}
+
+diesel::table! {
+ use diesel::sql_types::*;
+ use diesel_ltree::sql_types::Ltree;
comment (id) {
id -> Int4,
}
}
-table! {
+diesel::table! {
comment_aggregates (id) {
id -> Int4,
comment_id -> Int4,
upvotes -> Int8,
downvotes -> Int8,
published -> Timestamp,
- child_count -> Int4,
+ child_count -> Int4,
}
}
-table! {
+diesel::table! {
comment_like (id) {
id -> Int4,
person_id -> Int4,
}
}
-table! {
+diesel::table! {
+ comment_reply (id) {
+ id -> Int4,
+ recipient_id -> Int4,
+ comment_id -> Int4,
+ read -> Bool,
+ published -> Timestamp,
+ }
+}
+
+diesel::table! {
comment_report (id) {
id -> Int4,
creator_id -> Int4,
}
}
-table! {
+diesel::table! {
comment_saved (id) {
id -> Int4,
comment_id -> Int4,
}
}
-table! {
+diesel::table! {
community (id) {
id -> Int4,
name -> Varchar,
private_key -> Nullable<Text>,
public_key -> Text,
last_refreshed_at -> Timestamp,
- icon -> Nullable<Varchar>,
- banner -> Nullable<Varchar>,
+ icon -> Nullable<Text>,
+ banner -> Nullable<Text>,
followers_url -> Varchar,
inbox_url -> Varchar,
shared_inbox_url -> Nullable<Varchar>,
- moderators_url -> Nullable<Varchar>,
- featured_url -> Nullable<Varchar>,
hidden -> Bool,
posting_restricted_to_mods -> Bool,
instance_id -> Int4,
+ moderators_url -> Nullable<Varchar>,
+ featured_url -> Nullable<Varchar>,
}
}
-table! {
+diesel::table! {
community_aggregates (id) {
id -> Int4,
community_id -> Int4,
}
}
-table! {
+diesel::table! {
+ community_block (id) {
+ id -> Int4,
+ person_id -> Int4,
+ community_id -> Int4,
+ published -> Timestamp,
+ }
+}
+
+diesel::table! {
community_follower (id) {
id -> Int4,
community_id -> Int4,
}
}
-table! {
+diesel::table! {
+ community_language (id) {
+ id -> Int4,
+ community_id -> Int4,
+ language_id -> Int4,
+ }
+}
+
+diesel::table! {
community_moderator (id) {
id -> Int4,
community_id -> Int4,
}
}
-table! {
+diesel::table! {
community_person_ban (id) {
id -> Int4,
community_id -> Int4,
}
}
-table! {
+diesel::table! {
+ custom_emoji (id) {
+ id -> Int4,
+ local_site_id -> Int4,
+ shortcode -> Varchar,
+ image_url -> Text,
+ alt_text -> Text,
+ category -> Text,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ }
+}
+
+diesel::table! {
+ custom_emoji_keyword (id) {
+ id -> Int4,
+ custom_emoji_id -> Int4,
+ keyword -> Varchar,
+ }
+}
+
+diesel::table! {
+ email_verification (id) {
+ id -> Int4,
+ local_user_id -> Int4,
+ email -> Text,
+ verification_token -> Text,
+ published -> Timestamp,
+ }
+}
+
+diesel::table! {
+ federation_allowlist (id) {
+ id -> Int4,
+ instance_id -> Int4,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ }
+}
+
+diesel::table! {
+ federation_blocklist (id) {
+ id -> Int4,
+ instance_id -> Int4,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ }
+}
+
+diesel::table! {
+ instance (id) {
+ id -> Int4,
+ domain -> Varchar,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ software -> Nullable<Varchar>,
+ version -> Nullable<Varchar>,
+ }
+}
+
+diesel::table! {
+ language (id) {
+ id -> Int4,
+ code -> Varchar,
+ name -> Text,
+ }
+}
+
+diesel::table! {
+ use diesel::sql_types::*;
+ use super::sql_types::ListingTypeEnum;
+ use super::sql_types::RegistrationModeEnum;
+
+ local_site (id) {
+ id -> Int4,
+ site_id -> Int4,
+ site_setup -> Bool,
+ enable_downvotes -> Bool,
+ enable_nsfw -> Bool,
+ community_creation_admin_only -> Bool,
+ require_email_verification -> Bool,
+ application_question -> Nullable<Text>,
+ private_instance -> Bool,
+ default_theme -> Text,
+ default_post_listing_type -> ListingTypeEnum,
+ legal_information -> Nullable<Text>,
+ hide_modlog_mod_names -> Bool,
+ application_email_admins -> Bool,
+ slur_filter_regex -> Nullable<Text>,
+ actor_name_max_length -> Int4,
+ federation_enabled -> Bool,
+ federation_debug -> Bool,
+ federation_worker_count -> Int4,
+ captcha_enabled -> Bool,
+ captcha_difficulty -> Varchar,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ registration_mode -> RegistrationModeEnum,
+ reports_email_admins -> Bool,
+ }
+}
+
+diesel::table! {
+ local_site_rate_limit (id) {
+ id -> Int4,
+ local_site_id -> Int4,
+ message -> Int4,
+ message_per_second -> Int4,
+ post -> Int4,
+ post_per_second -> Int4,
+ register -> Int4,
+ register_per_second -> Int4,
+ image -> Int4,
+ image_per_second -> Int4,
+ comment -> Int4,
+ comment_per_second -> Int4,
+ search -> Int4,
+ search_per_second -> Int4,
+ published -> Timestamp,
+ updated -> Nullable<Timestamp>,
+ }
+}
+
+diesel::table! {
+ use diesel::sql_types::*;
+ use super::sql_types::SortTypeEnum;
+ use super::sql_types::ListingTypeEnum;
+
local_user (id) {
id -> Int4,
person_id -> Int4,
email -> Nullable<Text>,
show_nsfw -> Bool,
theme -> Varchar,
- default_sort_type -> Int2,
- default_listing_type -> Int2,
+ default_sort_type -> SortTypeEnum,
+ default_listing_type -> ListingTypeEnum,
interface_language -> Varchar,
show_avatars -> Bool,
send_notifications_to_email -> Bool,
validator_time -> Timestamp,
- show_bot_accounts -> Bool,
show_scores -> Bool,
+ show_bot_accounts -> Bool,
show_read_posts -> Bool,
show_new_post_notifs -> Bool,
email_verified -> Bool,
}
}
-table! {
- mod_add (id) {
+diesel::table! {
+ local_user_language (id) {
id -> Int4,
- mod_person_id -> Int4,
- other_person_id -> Int4,
- removed -> Nullable<Bool>,
- when_ -> Timestamp,
+ local_user_id -> Int4,
+ language_id -> Int4,
}
}
-table! {
- mod_add_community (id) {
+diesel::table! {
+ mod_add (id) {
id -> Int4,
mod_person_id -> Int4,
other_person_id -> Int4,
- community_id -> Int4,
- removed -> Nullable<Bool>,
+ removed -> Bool,
when_ -> Timestamp,
}
}
-table! {
- mod_transfer_community (id) {
+diesel::table! {
+ mod_add_community (id) {
id -> Int4,
mod_person_id -> Int4,
other_person_id -> Int4,
community_id -> Int4,
- removed -> Nullable<Bool>,
+ removed -> Bool,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
mod_ban (id) {
id -> Int4,
mod_person_id -> Int4,
other_person_id -> Int4,
reason -> Nullable<Text>,
- banned -> Nullable<Bool>,
+ banned -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
mod_ban_from_community (id) {
id -> Int4,
mod_person_id -> Int4,
other_person_id -> Int4,
community_id -> Int4,
reason -> Nullable<Text>,
- banned -> Nullable<Bool>,
+ banned -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
+ mod_feature_post (id) {
+ id -> Int4,
+ mod_person_id -> Int4,
+ post_id -> Int4,
+ featured -> Bool,
+ when_ -> Timestamp,
+ is_featured_community -> Bool,
+ }
+}
+
+diesel::table! {
+ mod_hide_community (id) {
+ id -> Int4,
+ community_id -> Int4,
+ mod_person_id -> Int4,
+ when_ -> Timestamp,
+ reason -> Nullable<Text>,
+ hidden -> Bool,
+ }
+}
+
+diesel::table! {
mod_lock_post (id) {
id -> Int4,
mod_person_id -> Int4,
post_id -> Int4,
- locked -> Nullable<Bool>,
+ locked -> Bool,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
mod_remove_comment (id) {
id -> Int4,
mod_person_id -> Int4,
comment_id -> Int4,
reason -> Nullable<Text>,
- removed -> Nullable<Bool>,
+ removed -> Bool,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
mod_remove_community (id) {
id -> Int4,
mod_person_id -> Int4,
community_id -> Int4,
reason -> Nullable<Text>,
- removed -> Nullable<Bool>,
+ removed -> Bool,
expires -> Nullable<Timestamp>,
when_ -> Timestamp,
}
}
-table! {
+diesel::table! {
mod_remove_post (id) {
id -> Int4,
mod_person_id -> Int4,
post_id -> Int4,
reason -> Nullable<Text>,
- removed -> Nullable<Bool>,
+ removed -> Bool,
when_ -> Timestamp,
}
}
-table! {
- mod_feature_post (id) {
+diesel::table! {
+ mod_transfer_community (id) {
id -> Int4,
mod_person_id -> Int4,
- post_id -> Int4,
- featured -> Bool,
+ other_person_id -> Int4,
+ community_id -> Int4,
when_ -> Timestamp,
- is_featured_community -> Bool,
}
}
-table! {
+diesel::table! {
password_reset_request (id) {
id -> Int4,
token_encrypted -> Text,
}
}
-table! {
+diesel::table! {
person (id) {
id -> Int4,
name -> Varchar,
display_name -> Nullable<Varchar>,
- avatar -> Nullable<Varchar>,
+ avatar -> Nullable<Text>,
banned -> Bool,
published -> Timestamp,
updated -> Nullable<Timestamp>,
private_key -> Nullable<Text>,
public_key -> Text,
last_refreshed_at -> Timestamp,
- banner -> Nullable<Varchar>,
+ banner -> Nullable<Text>,
deleted -> Bool,
inbox_url -> Varchar,
shared_inbox_url -> Nullable<Varchar>,
}
}
-table! {
+diesel::table! {
person_aggregates (id) {
id -> Int4,
person_id -> Int4,
}
}
-table! {
+diesel::table! {
person_ban (id) {
id -> Int4,
person_id -> Int4,
}
}
-table! {
+diesel::table! {
+ person_block (id) {
+ id -> Int4,
+ person_id -> Int4,
+ target_id -> Int4,
+ published -> Timestamp,
+ }
+}
+
+diesel::table! {
+ person_follower (id) {
+ id -> Int4,
+ person_id -> Int4,
+ follower_id -> Int4,
+ published -> Timestamp,
+ pending -> Bool,
+ }
+}
+
+diesel::table! {
person_mention (id) {
id -> Int4,
recipient_id -> Int4,
}
}
-table! {
- comment_reply (id) {
+diesel::table! {
+ person_post_aggregates (id) {
id -> Int4,
- recipient_id -> Int4,
- comment_id -> Int4,
- read -> Bool,
+ person_id -> Int4,
+ post_id -> Int4,
+ read_comments -> Int8,
published -> Timestamp,
}
}
-table! {
+diesel::table! {
post (id) {
id -> Int4,
name -> Varchar,
- url -> Nullable<Varchar>,
+ url -> Nullable<Text>,
body -> Nullable<Text>,
creator_id -> Int4,
community_id -> Int4,
nsfw -> Bool,
embed_title -> Nullable<Text>,
embed_description -> Nullable<Text>,
- embed_video_url -> Nullable<Text>,
thumbnail_url -> Nullable<Text>,
ap_id -> Varchar,
local -> Bool,
+ embed_video_url -> Nullable<Text>,
language_id -> Int4,
featured_community -> Bool,
featured_local -> Bool,
}
}
-table! {
- person_post_aggregates (id) {
- id -> Int4,
- person_id -> Int4,
- post_id -> Int4,
- read_comments -> Int8,
- published -> Timestamp,
- }
-}
-
-table! {
+diesel::table! {
post_aggregates (id) {
id -> Int4,
post_id -> Int4,
}
}
-table! {
+diesel::table! {
post_like (id) {
id -> Int4,
post_id -> Int4,
}
}
-table! {
+diesel::table! {
post_read (id) {
id -> Int4,
post_id -> Int4,
}
}
-table! {
+diesel::table! {
post_report (id) {
id -> Int4,
creator_id -> Int4,
}
}
-table! {
+diesel::table! {
post_saved (id) {
id -> Int4,
post_id -> Int4,
}
}
-table! {
+diesel::table! {
private_message (id) {
id -> Int4,
creator_id -> Int4,
}
}
-table! {
+diesel::table! {
private_message_report (id) {
id -> Int4,
creator_id -> Int4,
}
}
-table! {
+diesel::table! {
+ registration_application (id) {
+ id -> Int4,
+ local_user_id -> Int4,
+ answer -> Text,
+ admin_id -> Nullable<Int4>,
+ deny_reason -> Nullable<Text>,
+ published -> Timestamp,
+ }
+}
+
+diesel::table! {
+ secret (id) {
+ id -> Int4,
+ jwt_secret -> Varchar,
+ }
+}
+
+diesel::table! {
site (id) {
id -> Int4,
name -> Varchar,
sidebar -> Nullable<Text>,
published -> Timestamp,
updated -> Nullable<Timestamp>,
- icon -> Nullable<Varchar>,
- banner -> Nullable<Varchar>,
- description -> Nullable<Text>,
- actor_id -> Text,
+ icon -> Nullable<Text>,
+ banner -> Nullable<Text>,
+ description -> Nullable<Varchar>,
+ actor_id -> Varchar,
last_refreshed_at -> Timestamp,
- inbox_url -> Text,
+ inbox_url -> Varchar,
private_key -> Nullable<Text>,
public_key -> Text,
instance_id -> Int4,
}
}
-table! {
+diesel::table! {
site_aggregates (id) {
id -> Int4,
site_id -> Int4,
}
}
-table! {
- person_block (id) {
- id -> Int4,
- person_id -> Int4,
- target_id -> Int4,
- published -> Timestamp,
- }
-}
-
-table! {
- community_block (id) {
- id -> Int4,
- person_id -> Int4,
- community_id -> Int4,
- published -> Timestamp,
- }
-}
-
-table! {
- secret(id) {
- id -> Int4,
- jwt_secret -> Varchar,
- }
-}
-
-table! {
- admin_purge_comment (id) {
- id -> Int4,
- admin_person_id -> Int4,
- post_id -> Int4,
- reason -> Nullable<Text>,
- when_ -> Timestamp,
- }
-}
-
-table! {
- email_verification (id) {
- id -> Int4,
- local_user_id -> Int4,
- email -> Text,
- verification_token -> Varchar,
- published -> Timestamp,
- }
-}
-
-table! {
- admin_purge_community (id) {
- id -> Int4,
- admin_person_id -> Int4,
- reason -> Nullable<Text>,
- when_ -> Timestamp,
- }
-}
-
-table! {
- admin_purge_person (id) {
- id -> Int4,
- admin_person_id -> Int4,
- reason -> Nullable<Text>,
- when_ -> Timestamp,
- }
-}
-
-table! {
- admin_purge_post (id) {
- id -> Int4,
- admin_person_id -> Int4,
- community_id -> Int4,
- reason -> Nullable<Text>,
- when_ -> Timestamp,
- }
-}
-
-table! {
- registration_application (id) {
- id -> Int4,
- local_user_id -> Int4,
- answer -> Text,
- admin_id -> Nullable<Int4>,
- deny_reason -> Nullable<Text>,
- published -> Timestamp,
- }
-}
-
-table! {
- mod_hide_community (id) {
- id -> Int4,
- community_id -> Int4,
- mod_person_id -> Int4,
- reason -> Nullable<Text>,
- hidden -> Nullable<Bool>,
- when_ -> Timestamp,
- }
-}
-
-table! {
- language (id) {
- id -> Int4,
- code -> Text,
- name -> Text,
- }
-}
-
-table! {
- local_user_language(id) {
- id -> Int4,
- local_user_id -> Int4,
- language_id -> Int4,
- }
-}
-
-table! {
- site_language(id) {
+diesel::table! {
+ site_language (id) {
id -> Int4,
site_id -> Int4,
language_id -> Int4,
}
}
-table! {
- community_language(id) {
+diesel::table! {
+ tagline (id) {
id -> Int4,
- community_id -> Int4,
- language_id -> Int4,
- }
-}
-
-table! {
- instance(id) {
- id -> Int4,
- domain -> Text,
- software -> Nullable<Text>,
- version -> Nullable<Text>,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- federation_allowlist(id) {
- id -> Int4,
- instance_id -> Int4,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- federation_blocklist(id) {
- id -> Int4,
- instance_id -> Int4,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- use crate::source::local_site::RegistrationModeType;
- use diesel::sql_types::*;
-
- local_site(id) {
- id -> Int4,
- site_id -> Int4,
- site_setup -> Bool,
- enable_downvotes -> Bool,
- enable_nsfw -> Bool,
- community_creation_admin_only -> Bool,
- require_email_verification -> Bool,
- application_question -> Nullable<Text>,
- private_instance -> Bool,
- default_theme -> Text,
- default_post_listing_type -> Text,
- legal_information -> Nullable<Text>,
- hide_modlog_mod_names -> Bool,
- application_email_admins -> Bool,
- slur_filter_regex -> Nullable<Text>,
- actor_name_max_length -> Int4,
- federation_enabled -> Bool,
- federation_debug -> Bool,
- federation_worker_count -> Int4,
- captcha_enabled -> Bool,
- captcha_difficulty -> Text,
- registration_mode -> RegistrationModeType,
- reports_email_admins -> Bool,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- local_site_rate_limit(id) {
- id -> Int4,
- local_site_id -> Int4,
- message -> Int4,
- message_per_second-> Int4,
- post -> Int4,
- post_per_second -> Int4,
- register -> Int4,
- register_per_second -> Int4,
- image -> Int4,
- image_per_second -> Int4,
- comment -> Int4,
- comment_per_second -> Int4,
- search -> Int4,
- search_per_second -> Int4,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- tagline(id) {
- id -> Int4,
- local_site_id -> Int4,
- content -> Text,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- person_follower (id) {
- id -> Int4,
- person_id -> Int4,
- follower_id -> Int4,
+ local_site_id -> Int4,
+ content -> Text,
published -> Timestamp,
- pending -> Bool,
+ updated -> Nullable<Timestamp>,
}
}
-table! {
- custom_emoji (id) {
- id -> Int4,
- local_site_id -> Int4,
- shortcode -> Varchar,
- image_url -> Text,
- alt_text -> Text,
- category -> Text,
- published -> Timestamp,
- updated -> Nullable<Timestamp>,
- }
-}
-
-table! {
- custom_emoji_keyword (id) {
- id -> Int4,
- custom_emoji_id -> Int4,
- keyword -> Varchar,
- }
-}
-
-joinable!(person_block -> person (person_id));
-
-joinable!(comment -> person (creator_id));
-joinable!(comment -> post (post_id));
-joinable!(comment_aggregates -> comment (comment_id));
-joinable!(comment_like -> comment (comment_id));
-joinable!(comment_like -> person (person_id));
-joinable!(comment_like -> post (post_id));
-joinable!(comment_report -> comment (comment_id));
-joinable!(comment_saved -> comment (comment_id));
-joinable!(comment_saved -> person (person_id));
-joinable!(community_aggregates -> community (community_id));
-joinable!(community_block -> community (community_id));
-joinable!(community_block -> person (person_id));
-joinable!(community_follower -> community (community_id));
-joinable!(community_follower -> person (person_id));
-joinable!(community_moderator -> community (community_id));
-joinable!(community_moderator -> person (person_id));
-joinable!(community_person_ban -> community (community_id));
-joinable!(community_person_ban -> person (person_id));
-joinable!(local_user -> person (person_id));
-joinable!(mod_add_community -> community (community_id));
-joinable!(mod_transfer_community -> community (community_id));
-joinable!(mod_ban_from_community -> community (community_id));
-joinable!(mod_lock_post -> person (mod_person_id));
-joinable!(mod_lock_post -> post (post_id));
-joinable!(mod_remove_comment -> comment (comment_id));
-joinable!(mod_remove_comment -> person (mod_person_id));
-joinable!(mod_remove_community -> community (community_id));
-joinable!(mod_remove_community -> person (mod_person_id));
-joinable!(mod_remove_post -> person (mod_person_id));
-joinable!(mod_remove_post -> post (post_id));
-joinable!(mod_feature_post -> person (mod_person_id));
-joinable!(mod_feature_post -> post (post_id));
-joinable!(password_reset_request -> local_user (local_user_id));
-joinable!(person_aggregates -> person (person_id));
-joinable!(person_ban -> person (person_id));
-joinable!(person_mention -> comment (comment_id));
-joinable!(person_mention -> person (recipient_id));
-joinable!(comment_reply -> comment (comment_id));
-joinable!(comment_reply -> person (recipient_id));
-joinable!(post -> community (community_id));
-joinable!(post -> person (creator_id));
-joinable!(person_post_aggregates -> post (post_id));
-joinable!(person_post_aggregates -> person (person_id));
-joinable!(post_aggregates -> post (post_id));
-joinable!(post_like -> person (person_id));
-joinable!(post_like -> post (post_id));
-joinable!(post_read -> person (person_id));
-joinable!(post_read -> post (post_id));
-joinable!(post_report -> post (post_id));
-joinable!(post_saved -> person (person_id));
-joinable!(post_saved -> post (post_id));
-joinable!(site_aggregates -> site (site_id));
-joinable!(email_verification -> local_user (local_user_id));
-joinable!(registration_application -> local_user (local_user_id));
-joinable!(registration_application -> person (admin_id));
-joinable!(mod_hide_community -> person (mod_person_id));
-joinable!(mod_hide_community -> community (community_id));
-joinable!(post -> language (language_id));
-joinable!(comment -> language (language_id));
-joinable!(local_user_language -> language (language_id));
-joinable!(local_user_language -> local_user (local_user_id));
-joinable!(private_message_report -> private_message (private_message_id));
-joinable!(site_language -> language (language_id));
-joinable!(site_language -> site (site_id));
-joinable!(community_language -> language (language_id));
-joinable!(community_language -> community (community_id));
-joinable!(person_follower -> person (follower_id));
-
-joinable!(admin_purge_comment -> person (admin_person_id));
-joinable!(admin_purge_comment -> post (post_id));
-joinable!(admin_purge_community -> person (admin_person_id));
-joinable!(admin_purge_person -> person (admin_person_id));
-joinable!(admin_purge_post -> community (community_id));
-joinable!(admin_purge_post -> person (admin_person_id));
-
-joinable!(site -> instance (instance_id));
-joinable!(person -> instance (instance_id));
-joinable!(community -> instance (instance_id));
-joinable!(federation_allowlist -> instance (instance_id));
-joinable!(federation_blocklist -> instance (instance_id));
-joinable!(local_site -> site (site_id));
-joinable!(local_site_rate_limit -> local_site (local_site_id));
-joinable!(tagline -> local_site (local_site_id));
-joinable!(custom_emoji -> local_site (local_site_id));
-joinable!(custom_emoji_keyword -> custom_emoji (custom_emoji_id));
-
-allow_tables_to_appear_in_same_query!(
- activity,
- comment,
- comment_aggregates,
- community_block,
- comment_like,
- comment_report,
- comment_saved,
- community,
- community_aggregates,
- community_follower,
- community_moderator,
- community_person_ban,
- local_user,
- mod_add,
- mod_add_community,
- mod_transfer_community,
- mod_ban,
- mod_ban_from_community,
- mod_lock_post,
- mod_remove_comment,
- mod_remove_community,
- mod_remove_post,
- mod_feature_post,
- mod_hide_community,
- password_reset_request,
- person,
- person_aggregates,
- person_ban,
- person_block,
- person_mention,
- person_post_aggregates,
- comment_reply,
- post,
- post_aggregates,
- post_like,
- post_read,
- post_report,
- post_saved,
- private_message,
- private_message_report,
- site,
- site_aggregates,
- admin_purge_comment,
- admin_purge_community,
- admin_purge_person,
- admin_purge_post,
- email_verification,
- registration_application,
- language,
- tagline,
- local_user_language,
- site_language,
- community_language,
- instance,
- federation_allowlist,
- federation_blocklist,
- local_site,
- local_site_rate_limit,
- person_follower,
- custom_emoji,
- custom_emoji_keyword,
+diesel::joinable!(admin_purge_comment -> person (admin_person_id));
+diesel::joinable!(admin_purge_comment -> post (post_id));
+diesel::joinable!(admin_purge_community -> person (admin_person_id));
+diesel::joinable!(admin_purge_person -> person (admin_person_id));
+diesel::joinable!(admin_purge_post -> community (community_id));
+diesel::joinable!(admin_purge_post -> person (admin_person_id));
+diesel::joinable!(comment -> language (language_id));
+diesel::joinable!(comment -> person (creator_id));
+diesel::joinable!(comment -> post (post_id));
+diesel::joinable!(comment_aggregates -> comment (comment_id));
+diesel::joinable!(comment_like -> comment (comment_id));
+diesel::joinable!(comment_like -> person (person_id));
+diesel::joinable!(comment_like -> post (post_id));
+diesel::joinable!(comment_reply -> comment (comment_id));
+diesel::joinable!(comment_reply -> person (recipient_id));
+diesel::joinable!(comment_report -> comment (comment_id));
+diesel::joinable!(comment_saved -> comment (comment_id));
+diesel::joinable!(comment_saved -> person (person_id));
+diesel::joinable!(community -> instance (instance_id));
+diesel::joinable!(community_aggregates -> community (community_id));
+diesel::joinable!(community_block -> community (community_id));
+diesel::joinable!(community_block -> person (person_id));
+diesel::joinable!(community_follower -> community (community_id));
+diesel::joinable!(community_follower -> person (person_id));
+diesel::joinable!(community_language -> community (community_id));
+diesel::joinable!(community_language -> language (language_id));
+diesel::joinable!(community_moderator -> community (community_id));
+diesel::joinable!(community_moderator -> person (person_id));
+diesel::joinable!(community_person_ban -> community (community_id));
+diesel::joinable!(community_person_ban -> person (person_id));
+diesel::joinable!(custom_emoji -> local_site (local_site_id));
+diesel::joinable!(custom_emoji_keyword -> custom_emoji (custom_emoji_id));
+diesel::joinable!(email_verification -> local_user (local_user_id));
+diesel::joinable!(federation_allowlist -> instance (instance_id));
+diesel::joinable!(federation_blocklist -> instance (instance_id));
+diesel::joinable!(local_site -> site (site_id));
+diesel::joinable!(local_site_rate_limit -> local_site (local_site_id));
+diesel::joinable!(local_user -> person (person_id));
+diesel::joinable!(local_user_language -> language (language_id));
+diesel::joinable!(local_user_language -> local_user (local_user_id));
+diesel::joinable!(mod_add_community -> community (community_id));
+diesel::joinable!(mod_ban_from_community -> community (community_id));
+diesel::joinable!(mod_feature_post -> person (mod_person_id));
+diesel::joinable!(mod_feature_post -> post (post_id));
+diesel::joinable!(mod_hide_community -> community (community_id));
+diesel::joinable!(mod_hide_community -> person (mod_person_id));
+diesel::joinable!(mod_lock_post -> person (mod_person_id));
+diesel::joinable!(mod_lock_post -> post (post_id));
+diesel::joinable!(mod_remove_comment -> comment (comment_id));
+diesel::joinable!(mod_remove_comment -> person (mod_person_id));
+diesel::joinable!(mod_remove_community -> community (community_id));
+diesel::joinable!(mod_remove_community -> person (mod_person_id));
+diesel::joinable!(mod_remove_post -> person (mod_person_id));
+diesel::joinable!(mod_remove_post -> post (post_id));
+diesel::joinable!(mod_transfer_community -> community (community_id));
+diesel::joinable!(password_reset_request -> local_user (local_user_id));
+diesel::joinable!(person -> instance (instance_id));
+diesel::joinable!(person_aggregates -> person (person_id));
+diesel::joinable!(person_ban -> person (person_id));
+diesel::joinable!(person_mention -> comment (comment_id));
+diesel::joinable!(person_mention -> person (recipient_id));
+diesel::joinable!(person_post_aggregates -> person (person_id));
+diesel::joinable!(person_post_aggregates -> post (post_id));
+diesel::joinable!(post -> community (community_id));
+diesel::joinable!(post -> language (language_id));
+diesel::joinable!(post -> person (creator_id));
+diesel::joinable!(post_aggregates -> post (post_id));
+diesel::joinable!(post_like -> person (person_id));
+diesel::joinable!(post_like -> post (post_id));
+diesel::joinable!(post_read -> person (person_id));
+diesel::joinable!(post_read -> post (post_id));
+diesel::joinable!(post_report -> post (post_id));
+diesel::joinable!(post_saved -> person (person_id));
+diesel::joinable!(post_saved -> post (post_id));
+diesel::joinable!(private_message_report -> private_message (private_message_id));
+diesel::joinable!(registration_application -> local_user (local_user_id));
+diesel::joinable!(registration_application -> person (admin_id));
+diesel::joinable!(site -> instance (instance_id));
+diesel::joinable!(site_aggregates -> site (site_id));
+diesel::joinable!(site_language -> language (language_id));
+diesel::joinable!(site_language -> site (site_id));
+diesel::joinable!(tagline -> local_site (local_site_id));
+
+diesel::allow_tables_to_appear_in_same_query!(
+ activity,
+ admin_purge_comment,
+ admin_purge_community,
+ admin_purge_person,
+ admin_purge_post,
+ comment,
+ comment_aggregates,
+ comment_like,
+ comment_reply,
+ comment_report,
+ comment_saved,
+ community,
+ community_aggregates,
+ community_block,
+ community_follower,
+ community_language,
+ community_moderator,
+ community_person_ban,
+ custom_emoji,
+ custom_emoji_keyword,
+ email_verification,
+ federation_allowlist,
+ federation_blocklist,
+ instance,
+ language,
+ local_site,
+ local_site_rate_limit,
+ local_user,
+ local_user_language,
+ mod_add,
+ mod_add_community,
+ mod_ban,
+ mod_ban_from_community,
+ mod_feature_post,
+ mod_hide_community,
+ mod_lock_post,
+ mod_remove_comment,
+ mod_remove_community,
+ mod_remove_post,
+ mod_transfer_community,
+ password_reset_request,
+ person,
+ person_aggregates,
+ person_ban,
+ person_block,
+ person_follower,
+ person_mention,
+ person_post_aggregates,
+ post,
+ post_aggregates,
+ post_like,
+ post_read,
+ post_report,
+ post_saved,
+ private_message,
+ private_message_report,
+ registration_application,
+ secret,
+ site,
+ site_aggregates,
+ site_language,
+ tagline,
);
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
pub ap_id: DbUrl,
- pub sensitive: Option<bool>,
+ pub sensitive: bool,
}
#[derive(Insertable)]
pub data: Option<Value>,
pub local: Option<bool>,
pub updated: Option<Option<chrono::NaiveDateTime>>,
- pub sensitive: Option<Option<bool>>,
+ pub sensitive: Option<bool>,
}
pub inbox_url: DbUrl,
#[serde(skip)]
pub shared_inbox_url: Option<DbUrl>,
+ pub hidden: bool,
+ pub posting_restricted_to_mods: bool,
+ pub instance_id: InstanceId,
/// Url where moderators collection is served over Activitypub
#[serde(skip)]
pub moderators_url: Option<DbUrl>,
/// Url where featured posts collection is served over Activitypub
#[serde(skip)]
pub featured_url: Option<DbUrl>,
- pub hidden: bool,
- pub posting_restricted_to_mods: bool,
- pub instance_id: InstanceId,
}
#[derive(Debug, Clone, TypedBuilder)]
pub struct Instance {
pub id: InstanceId,
pub domain: String,
- pub software: Option<String>,
- pub version: Option<String>,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
+ pub software: Option<String>,
+ pub version: Option<String>,
}
#[derive(Clone, TypedBuilder)]
-use crate::newtypes::{LocalSiteId, SiteId};
#[cfg(feature = "full")]
use crate::schema::local_site;
+use crate::{
+ newtypes::{LocalSiteId, SiteId},
+ ListingType,
+ RegistrationMode,
+};
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
pub application_question: Option<String>,
pub private_instance: bool,
pub default_theme: String,
- pub default_post_listing_type: String,
+ pub default_post_listing_type: ListingType,
pub legal_information: Option<String>,
pub hide_modlog_mod_names: bool,
pub application_email_admins: bool,
pub federation_worker_count: i32,
pub captcha_enabled: bool,
pub captcha_difficulty: String,
- pub registration_mode: RegistrationMode,
- pub reports_email_admins: bool,
pub published: chrono::NaiveDateTime,
pub updated: Option<chrono::NaiveDateTime>,
+ pub registration_mode: RegistrationMode,
+ pub reports_email_admins: bool,
}
#[derive(Clone, TypedBuilder)]
pub application_question: Option<String>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
- pub default_post_listing_type: Option<String>,
+ pub default_post_listing_type: Option<ListingType>,
pub legal_information: Option<String>,
pub hide_modlog_mod_names: Option<bool>,
pub application_email_admins: Option<bool>,
pub application_question: Option<Option<String>>,
pub private_instance: Option<bool>,
pub default_theme: Option<String>,
- pub default_post_listing_type: Option<String>,
+ pub default_post_listing_type: Option<ListingType>,
pub legal_information: Option<Option<String>>,
pub hide_modlog_mod_names: Option<bool>,
pub application_email_admins: Option<bool>,
pub reports_email_admins: Option<bool>,
pub updated: Option<Option<chrono::NaiveDateTime>>,
}
-
-#[cfg(feature = "full")]
-#[derive(SqlType)]
-#[diesel(postgres_type(name = "registration_mode_enum"))]
-pub struct RegistrationModeType;
-
-#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
-#[cfg_attr(feature = "full", derive(FromSqlRow, AsExpression))]
-#[cfg_attr(feature = "full", diesel(sql_type = RegistrationModeType))]
-#[serde(rename_all = "lowercase")]
-pub enum RegistrationMode {
- Closed,
- RequireApplication,
- Open,
-}
-use crate::newtypes::{LocalUserId, PersonId};
#[cfg(feature = "full")]
use crate::schema::local_user;
+use crate::{
+ newtypes::{LocalUserId, PersonId},
+ ListingType,
+ SortType,
+};
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
pub email: Option<String>,
pub show_nsfw: bool,
pub theme: String,
- pub default_sort_type: i16,
- pub default_listing_type: i16,
+ pub default_sort_type: SortType,
+ pub default_listing_type: ListingType,
pub interface_language: String,
pub show_avatars: bool,
pub send_notifications_to_email: bool,
pub validator_time: chrono::NaiveDateTime,
- pub show_bot_accounts: bool,
pub show_scores: bool,
+ pub show_bot_accounts: bool,
pub show_read_posts: bool,
pub show_new_post_notifs: bool,
pub email_verified: bool,
pub email: Option<String>,
pub show_nsfw: Option<bool>,
pub theme: Option<String>,
- pub default_sort_type: Option<i16>,
- pub default_listing_type: Option<i16>,
+ pub default_sort_type: Option<SortType>,
+ pub default_listing_type: Option<ListingType>,
pub interface_language: Option<String>,
pub show_avatars: Option<bool>,
pub send_notifications_to_email: Option<bool>,
pub email: Option<Option<String>>,
pub show_nsfw: Option<bool>,
pub theme: Option<String>,
- pub default_sort_type: Option<i16>,
- pub default_listing_type: Option<i16>,
+ pub default_sort_type: Option<SortType>,
+ pub default_listing_type: Option<ListingType>,
pub interface_language: Option<String>,
pub show_avatars: Option<bool>,
pub send_notifications_to_email: Option<bool>,
pub mod_person_id: PersonId,
pub post_id: PostId,
pub reason: Option<String>,
- pub removed: Option<bool>,
+ pub removed: bool,
pub when_: chrono::NaiveDateTime,
}
pub id: i32,
pub mod_person_id: PersonId,
pub post_id: PostId,
- pub locked: Option<bool>,
+ pub locked: bool,
pub when_: chrono::NaiveDateTime,
}
pub mod_person_id: PersonId,
pub comment_id: CommentId,
pub reason: Option<String>,
- pub removed: Option<bool>,
+ pub removed: bool,
pub when_: chrono::NaiveDateTime,
}
pub mod_person_id: PersonId,
pub community_id: CommunityId,
pub reason: Option<String>,
- pub removed: Option<bool>,
+ pub removed: bool,
pub expires: Option<chrono::NaiveDateTime>,
pub when_: chrono::NaiveDateTime,
}
pub other_person_id: PersonId,
pub community_id: CommunityId,
pub reason: Option<String>,
- pub banned: Option<bool>,
+ pub banned: bool,
pub expires: Option<chrono::NaiveDateTime>,
pub when_: chrono::NaiveDateTime,
}
pub mod_person_id: PersonId,
pub other_person_id: PersonId,
pub reason: Option<String>,
- pub banned: Option<bool>,
+ pub banned: bool,
pub expires: Option<chrono::NaiveDateTime>,
pub when_: chrono::NaiveDateTime,
}
pub id: i32,
pub community_id: CommunityId,
pub mod_person_id: PersonId,
- pub reason: Option<String>,
- pub hidden: Option<bool>,
pub when_: chrono::NaiveDateTime,
+ pub reason: Option<String>,
+ pub hidden: bool,
}
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
pub mod_person_id: PersonId,
pub other_person_id: PersonId,
pub community_id: CommunityId,
- pub removed: Option<bool>,
+ pub removed: bool,
pub when_: chrono::NaiveDateTime,
}
pub mod_person_id: PersonId,
pub other_person_id: PersonId,
pub community_id: CommunityId,
- pub removed: Option<bool>,
pub when_: chrono::NaiveDateTime,
}
pub mod_person_id: PersonId,
pub other_person_id: PersonId,
pub community_id: CommunityId,
- pub removed: Option<bool>,
}
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub id: i32,
pub mod_person_id: PersonId,
pub other_person_id: PersonId,
- pub removed: Option<bool>,
+ pub removed: bool,
pub when_: chrono::NaiveDateTime,
}
pub nsfw: bool,
pub embed_title: Option<String>,
pub embed_description: Option<String>,
- pub embed_video_url: Option<DbUrl>,
pub thumbnail_url: Option<DbUrl>,
pub ap_id: DbUrl,
pub local: bool,
+ pub embed_video_url: Option<DbUrl>,
pub language_id: LanguageId,
pub featured_community: bool,
pub featured_local: bool,
let target_person_alias = diesel::alias!(person as person1);
let res = person_block::table
- .inner_join(person::table)
+ .inner_join(person::table.on(person_block::person_id.eq(person::id)))
.inner_join(
target_person_alias.on(person_block::target_id.eq(target_person_alias.field(person::id))),
)
use actix_web::{error::ErrorBadRequest, web, Error, HttpResponse, Result};
use anyhow::anyhow;
use lemmy_api_common::context::LemmyContext;
-use lemmy_db_schema::source::local_site::RegistrationMode;
+use lemmy_db_schema::RegistrationMode;
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{error::LemmyError, version};
use serde::{Deserialize, Serialize};
--- /dev/null
+[print_schema]
+file = "crates/db_schema/src/schema.rs"
+patch_file = "crates/db_schema/src/diesel_ltree.patch"
--- /dev/null
+-- Some fixes
+alter table community alter column hidden drop not null;
+alter table community alter column posting_restricted_to_mods drop not null;
+alter table activity alter column sensitive drop not null;
+alter table mod_add alter column removed drop not null;
+alter table mod_add_community alter column removed drop not null;
+alter table mod_ban alter column banned drop not null;
+alter table mod_ban_from_community alter column banned drop not null;
+alter table mod_hide_community alter column hidden drop not null;
+alter table mod_lock_post alter column locked drop not null;
+alter table mod_remove_comment alter column removed drop not null;
+alter table mod_remove_community alter column removed drop not null;
+alter table mod_remove_post alter column removed drop not null;
+alter table mod_transfer_community add column removed boolean default false;
+alter table language alter column code drop not null;
+alter table language alter column name drop not null;
+
+-- Fix the registration mode enums
+ALTER TYPE registration_mode_enum RENAME VALUE 'Closed' TO 'closed';
+ALTER TYPE registration_mode_enum RENAME VALUE 'RequireApplication' TO 'require_application';
+ALTER TYPE registration_mode_enum RENAME VALUE 'Open' TO 'open';
+
+-- add back old columns
+
+-- Alter the local_user table
+alter table local_user alter column default_sort_type drop default;
+alter table local_user alter column default_sort_type type smallint using
+ case default_sort_type
+ when 'Active' then 0
+ when 'Hot' then 1
+ when 'New' then 2
+ when 'Old' then 3
+ when 'TopDay' then 4
+ when 'TopWeek' then 5
+ when 'TopMonth' then 6
+ when 'TopYear' then 7
+ when 'TopAll' then 8
+ when 'MostComments' then 9
+ when 'NewComments' then 10
+ else 0
+ end;
+alter table local_user alter column default_sort_type set default 0;
+
+alter table local_user alter column default_listing_type drop default;
+alter table local_user alter column default_listing_type type smallint using
+ case default_listing_type
+ when 'All' then 0
+ when 'Local' then 1
+ when 'Subscribed' then 2
+ else 1
+ end;
+alter table local_user alter column default_listing_type set default 1;
+
+-- Alter the local site column
+
+alter table local_site alter column default_post_listing_type drop default;
+alter table local_site alter column default_post_listing_type type text;
+alter table local_site alter column default_post_listing_type set default 1;
+
+-- Drop the types
+drop type listing_type_enum;
+drop type sort_type_enum;
--- /dev/null
+-- A few DB fixes
+alter table community alter column hidden set not null;
+alter table community alter column posting_restricted_to_mods set not null;
+alter table activity alter column sensitive set not null;
+alter table mod_add alter column removed set not null;
+alter table mod_add_community alter column removed set not null;
+alter table mod_ban alter column banned set not null;
+alter table mod_ban_from_community alter column banned set not null;
+alter table mod_hide_community alter column hidden set not null;
+alter table mod_lock_post alter column locked set not null;
+alter table mod_remove_comment alter column removed set not null;
+alter table mod_remove_community alter column removed set not null;
+alter table mod_remove_post alter column removed set not null;
+alter table mod_transfer_community drop column removed;
+alter table language alter column code set not null;
+alter table language alter column name set not null;
+
+-- Fix the registration mode enums
+ALTER TYPE registration_mode_enum RENAME VALUE 'closed' TO 'Closed';
+ALTER TYPE registration_mode_enum RENAME VALUE 'require_application' TO 'RequireApplication';
+ALTER TYPE registration_mode_enum RENAME VALUE 'open' TO 'Open';
+
+-- Create the enums
+
+CREATE TYPE sort_type_enum AS ENUM ('Active', 'Hot', 'New', 'Old', 'TopDay', 'TopWeek', 'TopMonth', 'TopYear', 'TopAll', 'MostComments', 'NewComments');
+
+CREATE TYPE listing_type_enum AS ENUM ('All', 'Local', 'Subscribed');
+
+-- Alter the local_user table
+alter table local_user alter column default_sort_type drop default;
+alter table local_user alter column default_sort_type type sort_type_enum using
+ case default_sort_type
+ when 0 then 'Active'
+ when 1 then 'Hot'
+ when 2 then 'New'
+ when 3 then 'Old'
+ when 4 then 'TopDay'
+ when 5 then 'TopWeek'
+ when 6 then 'TopMonth'
+ when 7 then 'TopYear'
+ when 8 then 'TopAll'
+ when 9 then 'MostComments'
+ when 10 then 'NewComments'
+ else 'Active'
+ end :: sort_type_enum;
+alter table local_user alter column default_sort_type set default 'Active';
+
+alter table local_user alter column default_listing_type drop default;
+alter table local_user alter column default_listing_type type listing_type_enum using
+ case default_listing_type
+ when 0 then 'All'
+ when 1 then 'Local'
+ when 2 then 'Subscribed'
+ else 'Local'
+ end :: listing_type_enum;
+alter table local_user alter column default_listing_type set default 'Local';
+
+-- Alter the local site column
+alter table local_site alter column default_post_listing_type drop default;
+alter table local_site alter column default_post_listing_type type listing_type_enum using default_post_listing_type::listing_type_enum;
+alter table local_site alter column default_post_listing_type set default 'Local';