fix: emoji shortcodes
This commit is contained in:
parent
570a290954
commit
24cf61c783
7 changed files with 39 additions and 17 deletions
12
crates/app/src/routes/api/v1/communities/emojis.rs
Normal file
12
crates/app/src/routes/api/v1/communities/emojis.rs
Normal 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(),
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
pub mod communities;
|
||||
pub mod emojis;
|
||||
pub mod images;
|
||||
pub mod posts;
|
||||
pub mod questions;
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue