From 303cf002574c27f6299aaecccca6ff41275f2463 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 3 May 2024 12:11:58 +0200 Subject: [PATCH] x --- crates/api_crud/src/post/create.rs | 5 +++-- example_plugin/main.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 918ce6b16..1a9a61f7b 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -126,7 +126,7 @@ pub async fn create_post( } }; - plugin_hook("api_create_post", data.clone())?; + plugin_hook("api_before_create_post", data.clone())?; let post_form = PostInsertForm::builder() .name(data.name.trim().to_string()) @@ -161,6 +161,8 @@ pub async fn create_post( .await .with_lemmy_type(LemmyErrorType::CouldntCreatePost)?; + plugin_hook("api_after_create_post", updated_post.clone())?; + generate_post_link_metadata( updated_post.clone(), custom_thumbnail, @@ -230,7 +232,6 @@ fn plugin_hook(name: &'static str, data: T) -> LemmyResult<()> { let res = plugin .call::, &str>(name, data.into()) .map_err(|e| LemmyErrorType::PluginError(e.to_string())); - dbg!(&res); println!("{}", res?); } Ok(()) diff --git a/example_plugin/main.go b/example_plugin/main.go index 59130a76d..ee6e046c9 100644 --- a/example_plugin/main.go +++ b/example_plugin/main.go @@ -11,8 +11,8 @@ type CreatePost struct { // skipping other fields for now } -//export api_create_post -func api_create_post() int32 { +//export api_before_create_post +func api_before_create_post() int32 { params := CreatePost{} // use json input helper, which automatically unmarshals the plugin input into your struct err := pdk.InputJSON(¶ms)