diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 5e1e69d49..f5ddec35b 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -76,5 +76,7 @@ pub async fn leave_admin( admin_oauth_providers: None, blocked_urls, tagline, + taglines: vec![], + custom_emojis: vec![], })) } diff --git a/crates/api_common/src/oauth_provider.rs b/crates/api_common/src/oauth_provider.rs index c51edc7a4..14847edf1 100644 --- a/crates/api_common/src/oauth_provider.rs +++ b/crates/api_common/src/oauth_provider.rs @@ -5,6 +5,7 @@ use serde_with::skip_serializing_none; use ts_rs::TS; use url::Url; +#[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] @@ -19,11 +20,12 @@ pub struct CreateOAuthProvider { pub client_id: String, pub client_secret: String, pub scopes: String, - pub auto_verify_email: bool, - pub account_linking_enabled: bool, - pub enabled: bool, + pub auto_verify_email: Option, + pub account_linking_enabled: Option, + pub enabled: Option, } +#[skip_serializing_none] #[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(feature = "full", derive(TS))] #[cfg_attr(feature = "full", ts(export))] diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index 1ffabb75a..d82303327 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -306,6 +306,8 @@ pub struct EditSite { /// The response for a site. pub struct SiteResponse { pub site_view: SiteView, + /// deprecated, use field `tagline` or /api/v3/tagline/list + pub taglines: Vec<()>, } #[skip_serializing_none] @@ -320,6 +322,10 @@ pub struct GetSiteResponse { pub my_user: Option, pub all_languages: Vec, pub discussion_languages: Vec, + /// deprecated, use field `tagline` or /api/v3/tagline/list + pub taglines: Vec<()>, + /// deprecated, use /api/v3/custom_emoji/list + pub custom_emojis: Vec<()>, /// If the site has any taglines, a random one is included here for displaying pub tagline: Option, /// A list of external auth methods your site supports. diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index 28faa0aac..9b0439da8 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -139,7 +139,10 @@ pub async fn create_site( local_site_rate_limit_to_rate_limit_config(&site_view.local_site_rate_limit); context.rate_limit_cell().set_config(rate_limit_config); - Ok(Json(SiteResponse { site_view })) + Ok(Json(SiteResponse { + site_view, + taglines: vec![], + })) } fn validate_create_payload(local_site: &LocalSite, create_site: &CreateSite) -> LemmyResult<()> { diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index 0901b9186..20c10c415 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -59,6 +59,8 @@ pub async fn get_site( tagline, oauth_providers: Some(oauth_providers), admin_oauth_providers: Some(admin_oauth_providers), + taglines: vec![], + custom_emojis: vec![], }) }) .await diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 8b1934572..495a5cc98 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -193,7 +193,10 @@ pub async fn update_site( local_site_rate_limit_to_rate_limit_config(&site_view.local_site_rate_limit); context.rate_limit_cell().set_config(rate_limit_config); - Ok(Json(SiteResponse { site_view })) + Ok(Json(SiteResponse { + site_view, + taglines: vec![], + })) } fn validate_update_payload(local_site: &LocalSite, edit_site: &EditSite) -> LemmyResult<()> { diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 6125144f0..9064416be 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -258,9 +258,9 @@ impl Post { post::table .inner_join(person::table) .inner_join(community::table) - // find all posts which have scheduled_publish_time that is in the past + // find all posts which have scheduled_publish_time that is in the future .filter(post::scheduled_publish_time.is_not_null()) - .filter(coalesce(post::scheduled_publish_time, now()).lt(now())) + .filter(coalesce(post::scheduled_publish_time, now()).gt(now())) // make sure the post and community are still around .filter(not(post::deleted.or(post::removed))) .filter(not(community::removed.or(community::deleted))) @@ -413,6 +413,7 @@ mod tests { traits::{Crud, Likeable, Saveable}, utils::build_db_pool_for_tests, }; + use chrono::DateTime; use lemmy_utils::error::LemmyResult; use pretty_assertions::assert_eq; use serial_test::serial; @@ -454,6 +455,12 @@ mod tests { ); let inserted_post2 = Post::create(pool, &new_post2).await?; + let new_scheduled_post = PostInsertForm { + scheduled_publish_time: Some(DateTime::from_timestamp_nanos(i64::MAX)), + ..PostInsertForm::new("beans".into(), inserted_person.id, inserted_community.id) + }; + let inserted_scheduled_post = Post::create(pool, &new_scheduled_post).await?; + let expected_post = Post { id: inserted_post.id, name: "A test post".into(), @@ -528,6 +535,10 @@ mod tests { }; let updated_post = Post::update(pool, inserted_post.id, &new_post_update).await?; + // Scheduled post count + let scheduled_post_count = Post::user_scheduled_post_count(inserted_person.id, pool).await?; + assert_eq!(1, scheduled_post_count); + let like_removed = PostLike::remove(pool, inserted_person.id, inserted_post.id).await?; assert_eq!(1, like_removed); let saved_removed = PostSaved::unsave(pool, &post_saved_form).await?; @@ -540,9 +551,10 @@ mod tests { .await?; assert_eq!(2, read_removed); - let num_deleted = - Post::delete(pool, inserted_post.id).await? + Post::delete(pool, inserted_post2.id).await?; - assert_eq!(2, num_deleted); + let num_deleted = Post::delete(pool, inserted_post.id).await? + + Post::delete(pool, inserted_post2.id).await? + + Post::delete(pool, inserted_scheduled_post.id).await?; + assert_eq!(3, num_deleted); Community::delete(pool, inserted_community.id).await?; Person::delete(pool, inserted_person.id).await?; Instance::delete(pool, inserted_instance.id).await?; @@ -555,4 +567,4 @@ mod tests { Ok(()) } -} +} \ No newline at end of file diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index ab636c7d7..9617d9954 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -769,7 +769,7 @@ diesel::table! { featured_local -> Bool, url_content_type -> Nullable, alt_text -> Nullable, - scheduled_publish_time -> Nullable + scheduled_publish_time -> Nullable, } } diff --git a/crates/db_schema/src/source/oauth_provider.rs b/crates/db_schema/src/source/oauth_provider.rs index 40046c83c..75b989805 100644 --- a/crates/db_schema/src/source/oauth_provider.rs +++ b/crates/db_schema/src/source/oauth_provider.rs @@ -87,39 +87,30 @@ impl Serialize for PublicOAuthProvider { } #[derive(Debug, Clone)] -#[cfg_attr(feature = "full", derive(Insertable, AsChangeset, TS))] +#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] #[cfg_attr(feature = "full", diesel(table_name = oauth_provider))] -#[cfg_attr(feature = "full", ts(export))] pub struct OAuthProviderInsertForm { pub display_name: String, - #[cfg_attr(feature = "full", ts(type = "string"))] pub issuer: DbUrl, - #[cfg_attr(feature = "full", ts(type = "string"))] pub authorization_endpoint: DbUrl, - #[cfg_attr(feature = "full", ts(type = "string"))] pub token_endpoint: DbUrl, - #[cfg_attr(feature = "full", ts(type = "string"))] pub userinfo_endpoint: DbUrl, pub id_claim: String, pub client_id: String, pub client_secret: String, pub scopes: String, - pub auto_verify_email: bool, - pub account_linking_enabled: bool, - pub enabled: bool, + pub auto_verify_email: Option, + pub account_linking_enabled: Option, + pub enabled: Option, } #[derive(Debug, Clone)] -#[cfg_attr(feature = "full", derive(Insertable, AsChangeset, TS))] +#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))] #[cfg_attr(feature = "full", diesel(table_name = oauth_provider))] -#[cfg_attr(feature = "full", ts(export))] pub struct OAuthProviderUpdateForm { pub display_name: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] pub authorization_endpoint: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] pub token_endpoint: Option, - #[cfg_attr(feature = "full", ts(type = "string"))] pub userinfo_endpoint: Option, pub id_claim: Option, pub client_secret: Option, diff --git a/migrations/2024-09-16-174833_create_oauth_provider/up.sql b/migrations/2024-09-16-174833_create_oauth_provider/up.sql index a75f01228..308d86cce 100644 --- a/migrations/2024-09-16-174833_create_oauth_provider/up.sql +++ b/migrations/2024-09-16-174833_create_oauth_provider/up.sql @@ -14,7 +14,7 @@ CREATE TABLE oauth_provider ( scopes text NOT NULL, auto_verify_email boolean DEFAULT TRUE NOT NULL, account_linking_enabled boolean DEFAULT FALSE NOT NULL, - enabled boolean DEFAULT FALSE NOT NULL, + enabled boolean DEFAULT TRUE NOT NULL, published timestamp with time zone DEFAULT now() NOT NULL, updated timestamp with time zone );