fix: emoji shortcodes

This commit is contained in:
trisua 2025-05-05 23:44:10 -04:00
parent 570a290954
commit 24cf61c783
7 changed files with 39 additions and 17 deletions

View file

@ -0,0 +1,12 @@
use axum::response::IntoResponse;
/// Expand a unicode emoji into its Gemoji shortcode.
pub async fn get_emoji_shortcode(emoji: String) -> impl IntoResponse {
match emojis::get(&emoji) {
Some(e) => match e.shortcode() {
Some(s) => s.to_string(),
None => e.name().replace(" ", "-"),
},
None => String::new(),
}
}

View file

@ -1,4 +1,5 @@
pub mod communities;
pub mod emojis;
pub mod images;
pub mod posts;
pub mod questions;

View file

@ -311,6 +311,11 @@ pub fn routes() -> Router {
)
.route("/messages", post(channels::messages::create_request))
.route("/messages/{id}", delete(channels::messages::delete_request))
// emojis
.route(
"/lookup_emoji",
post(communities::emojis::get_emoji_shortcode),
)
}
#[derive(Deserialize)]