//! # 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> { 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 { Ok(CustomEmoji { id: row.get_u64("id")?, user_id: row.get_int64("user_id")?, shortcut: row.get_str("shortcut")?, path: row.get_str("path")? }) }