coord-e / misskey-rs

:v: Client library for Misskey :smiling_face_with_three_hearts:
Apache License 2.0
59 stars 7 forks source link

get_note from a string (or an example in general) #50

Open IoIxD opened 2 years ago

IoIxD commented 2 years ago

I'm sorry if this is an obvious question and not even really a bug report but there must be something I'm missing (especially because I don't use misskey).

I'm making a site that generates embeds for Mastodon, Pleroma, and Misskey, for Discord, and Misskey could very much benefit from it seeing as its embeds don't even show the post contents at all. The library I chose doesn't seem to support misskey and it would be a large undertaking for it to do so, and an equally large undertaking would be dealing with ActivityPub which would seemingly be just as hard as just supporting the sites individually, so i'd like to use this in conjunction with it.

What I'm missing is:

If I have https://misskey.bubbletea.dev/notes/8s27fg0gok, 8s27fg0gok being the id, and the usage for get_note is get_note(&self, Id<Post>), and all the implementations for Id can only have numbers fields...how am I supposed to get the note from that id?

If nothing else it would be nice to see an example for get_note in the docs.

coord-e commented 2 years ago

Thank you for the feedback. You can use FromStr implementation of Id<T> to get Id<T> from string. In other words, you can use parse:

let note = client.get_note("8s27fg0gok".parse()?).await?;
println!("{}", note.text.unwrap());

An example of get_note would be added in #51.