mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 22:31:20 +00:00
x
This commit is contained in:
parent
a65ccaf665
commit
303cf00257
2 changed files with 5 additions and 4 deletions
|
@ -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()
|
let post_form = PostInsertForm::builder()
|
||||||
.name(data.name.trim().to_string())
|
.name(data.name.trim().to_string())
|
||||||
|
@ -161,6 +161,8 @@ pub async fn create_post(
|
||||||
.await
|
.await
|
||||||
.with_lemmy_type(LemmyErrorType::CouldntCreatePost)?;
|
.with_lemmy_type(LemmyErrorType::CouldntCreatePost)?;
|
||||||
|
|
||||||
|
plugin_hook("api_after_create_post", updated_post.clone())?;
|
||||||
|
|
||||||
generate_post_link_metadata(
|
generate_post_link_metadata(
|
||||||
updated_post.clone(),
|
updated_post.clone(),
|
||||||
custom_thumbnail,
|
custom_thumbnail,
|
||||||
|
@ -230,7 +232,6 @@ fn plugin_hook<T: Serialize>(name: &'static str, data: T) -> LemmyResult<()> {
|
||||||
let res = plugin
|
let res = plugin
|
||||||
.call::<extism_convert::Json<T>, &str>(name, data.into())
|
.call::<extism_convert::Json<T>, &str>(name, data.into())
|
||||||
.map_err(|e| LemmyErrorType::PluginError(e.to_string()));
|
.map_err(|e| LemmyErrorType::PluginError(e.to_string()));
|
||||||
dbg!(&res);
|
|
||||||
println!("{}", res?);
|
println!("{}", res?);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -11,8 +11,8 @@ type CreatePost struct {
|
||||||
// skipping other fields for now
|
// skipping other fields for now
|
||||||
}
|
}
|
||||||
|
|
||||||
//export api_create_post
|
//export api_before_create_post
|
||||||
func api_create_post() int32 {
|
func api_before_create_post() int32 {
|
||||||
params := CreatePost{}
|
params := CreatePost{}
|
||||||
// use json input helper, which automatically unmarshals the plugin input into your struct
|
// use json input helper, which automatically unmarshals the plugin input into your struct
|
||||||
err := pdk.InputJSON(¶ms)
|
err := pdk.InputJSON(¶ms)
|
||||||
|
|
Loading…
Reference in a new issue