mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-01-31 06:22:59 +00:00
26 lines
809 B
Rust
26 lines
809 B
Rust
//! # Custom emojies helper
|
|
//!
|
|
//! @author Pierre Hubert
|
|
|
|
use crate::data::user::UserID;
|
|
use crate::data::error::ResultBoxError;
|
|
use crate::data::custom_emoji::CustomEmoji;
|
|
use crate::helpers::database;
|
|
use crate::constants::database_tables_names::EMOJIS_TABLE;
|
|
|
|
/// Get the list of emojies of a user
|
|
pub fn get_list_user(user_id: UserID) -> ResultBoxError<Vec<CustomEmoji>> {
|
|
database::QueryInfo::new(EMOJIS_TABLE)
|
|
.cond_i64("user_id", user_id)
|
|
.exec(db_to_custom_emoji)
|
|
}
|
|
|
|
/// Turn a database entry into a [CustomEmoji]
|
|
fn db_to_custom_emoji(row: &database::RowResult) -> ResultBoxError<CustomEmoji> {
|
|
Ok(CustomEmoji {
|
|
id: row.get_u64("id")?,
|
|
user_id: row.get_int64("user_id")?,
|
|
shortcut: row.get_str("shortcut")?,
|
|
path: row.get_str("path")?
|
|
})
|
|
} |