diff --git a/src/lib.rs b/src/lib.rs index f7ca5d7..11674a4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,22 +125,27 @@ impl BlogdorTheAggregator { Ok(feed_results) } + // will also update the successful_runs table if it posts to zulip pub async fn post_entries(&self, posts: &[FeedEntry]) { let FeedEntry { feed_id, received, .. } = posts.last().unwrap(); let mut success = true; for post in posts.iter() { - let body = post - .body - .iter() - .next() - .cloned() - .unwrap_or("Blogdor Says: NO BODY!".to_string()); + let body = post.body.as_deref().unwrap_or("Blogdor Says: NO BODY!"); + + let tail = if body.len() < ZULIP_MESSAGE_CUTOFF { + "" + } else { + "..." + }; + let content = format!( - "{body} ...\n\n---\noriginally posted to {}, on {}", - post.post_url, post.published + "{body}{tail}\n\n---\noriginally published on [{}]({})", + post.published.format("%B %e, %Y"), + post.post_url ); + let msg = ZulipMessage { to: self.channel_id, typ: "stream",