Skip to content

Commit

Permalink
fix(mastodon): fields_attributes as hash instead of array
Browse files Browse the repository at this point in the history
  • Loading branch information
hylobates-agilis committed Dec 20, 2022
1 parent 4f7c1fe commit 554e12d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/mastodon/mastodon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,14 @@ impl megalodon::Megalodon for Mastodon {
}
}
if let Some(fields_attributes) = &options.fields_attributes {
if let Some(json_fields_attributes) = serde_json::to_value(&fields_attributes).ok()
{
let json_fields_attributes = serde_json::map::Map::from_iter(
fields_attributes
.iter()
.enumerate()
.map(|(x, y)| (x.to_string(), serde_json::to_value(y).ok().into())),
);

if let Ok(json_fields_attributes) = serde_json::to_value(json_fields_attributes) {
params.insert("fields_attributes", json_fields_attributes);
}
}
Expand Down

0 comments on commit 554e12d

Please sign in to comment.