Skip to content

Instantly share code, notes, and snippets.

@simanacci
Created February 27, 2024 07:20
Show Gist options
  • Save simanacci/5f6150c5023befddfbe03377832e7143 to your computer and use it in GitHub Desktop.
Save simanacci/5f6150c5023befddfbe03377832e7143 to your computer and use it in GitHub Desktop.
FT.CREATE
pub async fn message<T>(
redis: &redis::Client,
sms: T,
gadget: Option<Uuid>,
uuid: Uuid,
) -> Result<Message, CustomError>
where
T: AsRef<str> + ToString,
{
if !helper::index_exists(redis, common::index::MESSAGES).await {
let data = IndexData::messages();
IndexData::create_index(redis, data).await.unwrap();
}
let message = Message {
uuid,
gadget,
sms: sms.to_string(),
added: Utc::now(),
};
let items = message_items(&message);
Cache::hset_multiple(redis, key::message(message.uuid.to_string()), &items)
.await
.unwrap();
Ok(message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment