Skip to content

Commit

Permalink
twiq-light: Add simple length check
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Dec 25, 2022
1 parent 0ad6721 commit 850e9b4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions twiq-light/src/enqueue.rs
@@ -1,9 +1,13 @@
use anyhow::bail;
use tracing::instrument;

use crate::{domain::ScheduledTweet, store::TweetQueueStore};

#[instrument(skip_all)]
pub async fn run(store: TweetQueueStore, tweet: String) -> anyhow::Result<()> {
if tweet.chars().count() > 140 {
bail!("The length of the tweet exceeded 140 characters");
}
let mut queue = store.read_all().await?;
queue.push_back(ScheduledTweet { text: tweet });
store.write_all(&queue).await?;
Expand Down

0 comments on commit 850e9b4

Please sign in to comment.