diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index 8f33563fe..01b6eaa3a 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -860,6 +860,22 @@ pub async fn purge_user_account(person_id: PersonId, context: &LemmyContext) -> Ok(()) } +pub fn generate_followers_url(actor_id: &DbUrl) -> Result { + Ok(Url::parse(&format!("{actor_id}/followers"))?.into()) +} + +pub fn generate_outbox_url(actor_id: &DbUrl) -> Result { + Ok(Url::parse(&format!("{actor_id}/outbox"))?.into()) +} + +pub fn generate_featured_url(actor_id: &DbUrl) -> Result { + Ok(Url::parse(&format!("{actor_id}/featured"))?.into()) +} + +pub fn generate_moderators_url(community_id: &DbUrl) -> LemmyResult { + Ok(Url::parse(&format!("{community_id}/moderators"))?.into()) +} + /// Ensure that ban/block expiry is in valid range. If its in past, throw error. If its more /// than 10 years in future, convert to permanent ban. Otherwise return the same value. pub fn check_expire_time(expires_unix_opt: Option) -> LemmyResult>> { diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 51ebcc687..36ab8eb63 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -13,7 +13,6 @@ use lemmy_api_common::{ local_site_to_slur_regex, process_markdown, update_read_comments, - EndpointType, }, }; use lemmy_db_schema::{ diff --git a/crates/api_crud/src/community/create.rs b/crates/api_crud/src/community/create.rs index 74c7cfcf7..8b19ebb99 100644 --- a/crates/api_crud/src/community/create.rs +++ b/crates/api_crud/src/community/create.rs @@ -5,15 +5,11 @@ use lemmy_api_common::{ community::{CommunityResponse, CreateCommunity}, context::LemmyContext, utils::{ - generate_followers_url, - generate_inbox_url, - generate_shared_inbox_url, get_url_blocklist, is_admin, local_site_to_slur_regex, process_markdown_opt, proxy_image_link_api, - EndpointType, }, }; use lemmy_db_schema::{ diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 5a1a47ccc..fadfb8aa1 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -13,7 +13,6 @@ use lemmy_api_common::{ local_site_to_slur_regex, mark_post_as_read, process_markdown_opt, - EndpointType, }, }; use lemmy_db_schema::{ @@ -147,7 +146,7 @@ pub async fn create_post( .with_lemmy_type(LemmyErrorType::CouldntCreatePost)?; generate_post_link_metadata( - updated_post.clone(), + inserted_post.clone(), custom_thumbnail.map(Into::into), |post| Some(SendActivityData::CreatePost(post)), Some(local_site), diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index 4eb6cd9d1..03afe91da 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -11,7 +11,6 @@ use lemmy_api_common::{ local_site_to_slur_regex, process_markdown, send_email_to_user, - EndpointType, }, }; use lemmy_db_schema::{ diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index a77deddaa..457f4ed95 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -5,7 +5,6 @@ use lemmy_api_common::{ context::LemmyContext, site::{CreateSite, SiteResponse}, utils::{ - generate_shared_inbox_url, get_url_blocklist, is_admin, local_site_rate_limit_to_rate_limit_config, diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index e5a794763..88beacf9b 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -5,14 +5,11 @@ use lemmy_api_common::{ context::LemmyContext, person::{LoginResponse, Register}, utils::{ - generate_inbox_url, - generate_shared_inbox_url, honeypot_check, local_site_to_slur_regex, password_length_check, send_new_applicant_email_to_admins, send_verification_email, - EndpointType, }, }; use lemmy_db_schema::{ diff --git a/crates/db_schema/replaceable_schema/triggers.sql b/crates/db_schema/replaceable_schema/triggers.sql index 29e35687e..3ca2bda29 100644 --- a/crates/db_schema/replaceable_schema/triggers.sql +++ b/crates/db_schema/replaceable_schema/triggers.sql @@ -552,7 +552,8 @@ CREATE TRIGGER delete_follow FOR EACH ROW EXECUTE FUNCTION r.delete_follow_before_person (); --- Triggers that change values before insert or update +-- Triggers that change values before insert or update (they can't be for insert only, because regenerating +-- the values using update must be possible) CREATE FUNCTION r.comment_change_values () RETURNS TRIGGER LANGUAGE plpgsql diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 4e7ed2eb9..ec95796e6 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -22,7 +22,7 @@ use diesel_async::{ AsyncDieselConnectionManager, ManagerConfig, }, - SimpleAsyncConnection, + RunQueryDsl, }; use futures_util::{future::BoxFuture, Future, FutureExt}; use i_love_jesus::CursorKey; @@ -348,7 +348,7 @@ fn establish_connection(config: &str) -> BoxFuture(x: diesel::sql_types::Nullable, y: T) -> T); - sql_function(fn set_config(setting_name: Text, new_value: Text, is_local: Bool) -> Text); + sql_function!(fn set_config(setting_name: Text, new_value: Text, is_local: Bool) -> Text); } pub const DELETED_REPLACEMENT_TEXT: &str = "*Permanently Deleted*";