mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +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()
|
||||
.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<T: Serialize>(name: &'static str, data: T) -> LemmyResult<()> {
|
|||
let res = plugin
|
||||
.call::<extism_convert::Json<T>, &str>(name, data.into())
|
||||
.map_err(|e| LemmyErrorType::PluginError(e.to_string()));
|
||||
dbg!(&res);
|
||||
println!("{}", res?);
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue